[英]Add multiple New products to website programmatically woocommerce Using PHP code
i have 3000 products to upload to the website so am trying to add products programmatically to my woocommerce website got some code which add's products programmatically am new to this i have no idea how to run this and where to run this am stucked in between the a small help will be appreciated a lot where to run the code and how to add the multiple products to website . 我有3000种产品要上传到网站,所以我试图以编程方式将产品添加到我的woocommerce网站上,获得了一些代码,以编程方式添加了产品,这是我的新手,我不知道如何运行它以及在哪里运行它在哪里可以运行代码以及如何将多种产品添加到网站上,可以得到很多小小的帮助。
$post = array(
'post_author' => $user_id,
'post_content' => '',
'post_status' => "publish",
'post_title' => $product->part_num,
'post_parent' => '',
'post_type' => "product",
);
//Create post
$post_id = wp_insert_post( $post, $wp_error );
if($post_id){
$attach_id = get_post_meta($product->parent_id, "_thumbnail_id", true);
add_post_meta($post_id, '_thumbnail_id', $attach_id);
}
wp_set_object_terms( $post_id, 'Races', 'product_cat' );
wp_set_object_terms($post_id, 'simple', 'product_type');
update_post_meta( $post_id, '_visibility', 'visible' );
update_post_meta( $post_id, '_stock_status', 'instock');
update_post_meta( $post_id, 'total_sales', '0');
update_post_meta( $post_id, '_stock', "" );
该问题的答案显示了如何以编程方式将产品添加到Woocommerce: https ://wordpress.stackexchange.com/questions/137501/how-to-add-product-in-woocommerce-with-php-code
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.