Closed. This question is off-topic. It is not currently accepting answers.admin管理员组文章数量:1315981
Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 4 years ago.
Improve this questioni want to create a function which will add to specific products an attribute programmatically. i use the below code but it doesnt seem to work.
$attributedata = Array(
'pa_color'=>Array(
'name'=>'pa_color',
'value'=>'black',
'is_visible' => '1',
'is_taxonomy' => '1'
)
);
update_post_meta( $productID,'_product_attributes',$attributedata );
if i set taxonomy to 0 the attribute is passed to the product but it doesnt appear in the front end unless i press update manually to each product. what can i do to add attributes to product? i want to mention that the products are simple products not variable.
Closed. This question is off-topic. It is not currently accepting answers.Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 4 years ago.
Improve this questioni want to create a function which will add to specific products an attribute programmatically. i use the below code but it doesnt seem to work.
$attributedata = Array(
'pa_color'=>Array(
'name'=>'pa_color',
'value'=>'black',
'is_visible' => '1',
'is_taxonomy' => '1'
)
);
update_post_meta( $productID,'_product_attributes',$attributedata );
if i set taxonomy to 0 the attribute is passed to the product but it doesnt appear in the front end unless i press update manually to each product. what can i do to add attributes to product? i want to mention that the products are simple products not variable.
Share Improve this question asked Jun 6, 2018 at 18:58 Agis SoleasAgis Soleas 1651 gold badge2 silver badges5 bronze badges1 Answer
Reset to default 10wp_set_object_terms( $productID, 'black', 'pa_color', true );
$att_color = Array('pa_color' =>Array(
'name'=>'pa_color',
'value'=>'black',
'is_visible' => '1',
'is_taxonomy' => '1'
));
update_post_meta( $productID, '_product_attributes', $att_color);
本文标签: functionsWoocommerce add to simple product attribute programmatically
版权声明:本文标题:functions - Woocommerce add to simple product attribute programmatically 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741974872a2408059.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论