vendredi 27 février 2015

Programatically added attribute, set to 'show on product page' automatically. Woocommerce


Ive written a script to import products to a new install of Woocommerce.


The products have attributes set up in the admin. This bit of code adds the attributes on import.



update_post_meta($product_id, 'common_name', $product['common_name']);
wp_set_object_terms($product_id, $product['flowering_period'], 'pa_flowering');
wp_set_object_terms($product_id, $product['native_plant'], 'pa_native');


However when I look at the product attribute in admin, the tick box for 'show on product page' is unticked.


Is there a way to set this as ticked using the above function? OR Does it matter if this is ticked or not, if I call the attribute in the template directly using something like get_the_term_list (although most of my attributes have a single term) will it show, or does having this box ticked overide it showing up?





Aucun commentaire:

Enregistrer un commentaire