【发布时间】:2018-05-04 23:11:21
【问题描述】:
我正在努力为产品添加属性。
我有一组关键字要添加到产品中:
$clean_keywords = array('cake','cup cakes');
$term_taxonomy_ids = wp_set_object_terms( get_the_ID(), $clean_keywords, 'pa_keywords', true );
$thedata = Array('pa_keywords' => Array(
'name' => 'pa_keywords',
'value' => '',
'is_visible' => '0',
'is_taxonomy' => '1'
));
update_post_meta( get_the_ID(),'_product_attributes',$thedata);
这很好用,但它会删除我附加到产品的所有其他属性。
我认为解决方案是获取当前属性并将其与$thedata 变量合并...但不确定如何执行此操作。
有什么想法吗?
谢谢
【问题讨论】:
标签: php wordpress woocommerce attributes product