最近两天,我一直在对此进行研究,
我尝试使用_product_attributes
元数据,自定义分类法,但似乎都没有作用或没有任何意义。
给出woocommerce中的可变产品,向其添加属性和术语以用于变体(产品范围)的最简单方法是什么?
$post = array(
'post_title' => $product_data['name'],
'post_parent' => '',
'post_status' => 'publish',
'post_type' => 'product',
);
$product_id = wp_insert_post( $post );
wp_set_object_terms( $product_id, 'variable', 'product_type', true );
$attributes = array(
array(
'name' => 'Material',
'option' => 'Cotton'
)
);
// Add the attributes with terms
谢谢!