Site logo

Archived topic

Visible on the product page, Change selected by default

4 replies · Started by 林鴻木 on December 16, 2019

Viewing posts 1–5 of 5

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

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.

Thank you for your help

You're welcome - let us know what you find :)

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();
}

This archived topic is closed to new replies.