WooCommerce前端产品创建


WooCommerce front-end product creation

我尽量用一种不会让大家被我的困惑所迷惑的方式来问这个问题

我正试图为WooCommerce制作一个前端表单,以便客户可以从前端制作产品。到目前为止,我想实现的所有其他部分都在工作中。标题、内容和价格所有张贴在正确的帖子类型。但无法将其发布到产品类别

WooCommerce分类是一个名为product_cat <的自定义分类法——几乎100%确定。>

product_cat子类是术语,我有三个->基础,设计和用户设计

我想从这个表单的所有帖子自动在用户设计。这就是我现在的结果

$post_information = array(
        'post_title' => esc_attr(strip_tags($_POST['postTitle'])),
        'post_content' => esc_attr(strip_tags($_POST['postContent'])),
        'post_type' => 'product',
        'post_status' => 'publish',

    );
$post_id = wp_insert_post($post_information);
  update_post_meta( $post_id, '_regular_price', strip_tags($_POST['_regular_price'] ) ) ;

    if($post_id)
    {
        wp_redirect(home_url());
        exit;
    }
};

我已经尝试了很多变体来设置像

这样的术语
 wp_set_object_terms($post_id, 'designs', 'product_cat', false);
 wp_set_post_terms($post_id, 'designs', 'product_cat', false);
 wp_set_object_terms($post_id, $designs ,'product_cat');
 wp_set_post_terms( $post_id, $designs, 'product_cat', true );
 wp_set_object_terms($post_id, $base, 'product_cat');           
不去,我知道我错过了什么,但我不知道是什么。我盯着屏幕太久了,我的眼睛都交叉了,

任何帮助都将非常感激提前感谢

使用如下:

wp_set_post_terms( $product_id, '343', 'product_cat');

其中$product_id是您正在制造的产品的post_id, 343是分类法id(您可以从其中一个分类法表中获得它)