Auto add all product attributes when adding a new product in Dokan Woocommerce
-
i use this code to Auto add all product attributes when adding a new product in admin
function wpa_120062_scripts(){ ?> <script type="text/javascript"> jQuery(document).ready(function($) { $('.product_attributes > div').removeClass('closed').show(); $('#product_attributes a.expand_all').click(); }); </script> <?php } add_action('admin_print_footer_scripts', 'wpa_120062_scripts'); ## --- HIDE PRODUCT TYPES IN WOOCOMMERCE --- ## add_filter( 'product_type_selector', 'remove_product_types' );function remove_product_types( $types ){ unset( $types['grouped'] ); unset( $types['external'] ); unset( $types['simple'] ); return $types;} function wpa_120062_new_product($new_status, $old_status, $post){ if ( $new_status == "auto-draft" && isset( $post->post_type ) && $post->post_type == 'product' ){ if( function_exists( 'wc_get_attribute_taxonomies' ) && ( $attribute_taxonomies = wc_get_attribute_taxonomies() ) ) { $defaults = array(); foreach ( $attribute_taxonomies as $tax ) { $name = wc_attribute_taxonomy_name( $tax->attribute_name ); // do stuff here $defaults[ $name ] = array ( 'name' => $name, 'value' => '', 'position' => 1, 'is_visible' => 1, 'is_variation' => 1, 'is_taxonomy' => 1, ); update_post_meta( $post->ID , '_product_attributes', $defaults ); } } } } add_action('transition_post_status', 'wpa_120062_new_product', 10, 3);
how i can use it in dokan vendor add new product or product edit?
- The topic ‘Auto add all product attributes when adding a new product in Dokan Woocommerce’ is closed to new replies.