简体   繁体   English

使用PHP代码以编程方式将多个新产品添加到网站woocommerce

[英]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.

相关问题 在 WooCommerce 中以编程方式添加多个产品 - Adding multiple products programmatically in WooCommerce 将PHP代码添加到在woocommerce支持的网站中使用Visual Composer创建的按钮中 - Add PHP code to a button created using Visual Composer in a woocommerce powered website 在访问WooCommerce时自动将多种产品添加到购物车 - Automatically add multiple products to cart on visit WooCommerce 用于Woocommerce变量产品的混合php和jQuery代码 - Mixed php and jQuery code for Woocommerce variable products Woocommerce:如果产品具有贡品价值,则以编程方式添加链接 - Woocommerce: programmatically add links if products has a tribute value 以编程方式添加具有自定义选项的多个产品 - Programmatically Add multiple Products with Custom Options 如何在 woocommerce 上的 php 代码上添加更多 id 以用于产品的自定义内容? - how can i add more ids on php code on woocommerce for custom content for products? WooCommerce-如何使用具有相同购物车按钮的Ajax将多种不同的产品添加到购物车? - WooCommerce - How can I add multiple, different products to cart using ajax with same add-to-cart-Button? 以编程方式向Woocommerce添加新的送货方式 - Add new shipping method to Woocommerce programmatically 以编程方式将购物车内容添加到新订单(Woocommerce) - Programmatically add cart content to new order (Woocommerce)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM