woocommerce: add value to a product attribute
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How do I add value to a woocommerce attribute through code? I have created an attribute called 'Dispatch time' (taxonomy: pa_dispatch) and now I want to add value to a particular product's Dispatch attribute. How to do this programmatically? 回答1: I found the answer, you need to use wp_set_object_terms to set the terms of object of a taxonomy, wp_set_object_terms( $object_id, $terms, $taxonomy, $append); Where, $append can be true or false , if true, the tag will be appended to existing tag, if false, the tag is replaced. In my example, wp