[Resolved] Visible on the product page, Change selected by default

Home Forums Support Visible on the product page, Change selected by default

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1105722
    林鴻木

    Because there are more than 300 ~ 400 products, a small step can save a lot of time

    Visible on the product page, selected by default. Can I change the preset without selecting it?
    Used for variations, which is not selected by default. Can I change the preset to select it?

    thanksgiving

    https://drive.google.com/file/d/1V4niMYfkhLKIhtuusP6XXQ8Lk5U-bGvC/view?usp=sharing

    #1105966
    David
    Staff
    Customer Support

    Hi there,

    you would need to ask Woocommerce Support – i know that the two filters that existed for those options were removed and i am unsure of what code would be required today.

    #1109443
    林鴻木

    Thank you for your help

    #1109637
    David
    Staff
    Customer Support

    You’re welcome – let us know what you find 🙂

    #1109703
    林鴻木

    class-wc-ajax.php

    /**
    * Add an attribute row.
    */
    public static function add_attribute() {
    ob_start();

    check_ajax_referer( ‘add-attribute’, ‘security’ );

    if ( ! current_user_can( ‘edit_products’ ) || ! isset( $_POST[‘taxonomy’], $_POST[‘i’] ) ) {
    wp_die( -1 );
    }

    $i = absint( $_POST[‘i’] );
    $metabox_class = array();
    $attribute = new WC_Product_Attribute();

    $attribute->set_id( wc_attribute_taxonomy_id_by_name( sanitize_text_field( wp_unslash( $_POST[‘taxonomy’] ) ) ) );
    $attribute->set_name( sanitize_text_field( wp_unslash( $_POST[‘taxonomy’] ) ) );
    $attribute->set_visible( apply_filters( ‘woocommerce_attribute_default_visibility’, 1 ) );
    $attribute->set_variation( apply_filters( ‘woocommerce_attribute_default_is_variation’, 0 ) );

    if ( $attribute->is_taxonomy() ) {
    $metabox_class[] = ‘taxonomy’;
    $metabox_class[] = $attribute->get_name();
    }

    include ‘admin/meta-boxes/views/html-product-attribute.php’;
    wp_die();
    }

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.