doumeng06063991 2015-08-31 13:53
浏览 52

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

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 .

$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', "" );
  • 写回答

1条回答 默认 最新

  • dongliang1654 2015-11-18 18:06
    关注

    The answer to this question shows how to programmatically add products to Woocommerce: https://wordpress.stackexchange.com/questions/137501/how-to-add-product-in-woocommerce-with-php-code

    评论

报告相同问题?

悬赏问题

  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上