简体   繁体   中英

Programmatically created products doesn't show on WooCommerce

I created a cron job to fetch wholesaler product list and insert them into the database.

But when I create a product in this way, it's doesn't show in the shop, only in the admin. After I enter into the edit page of any product and click the save button without make changes on the product, this product apear in the shop.

What would be the problem with the products?

When inserting a product to the database, If you want it to appear on front end, you need in wp_posts table to set 'post_status' key with a value of 'publish' .
Without it, it doesn't appear on front end.

Also the 'post_date' and 'post_date_gmt' need to have a date lower than "today"

Check also in wp_postmeta table that you are also setting:

  • '_visibility' key to 'visible' value
  • '_stock_status' key to 'instock' value
  • '_stock' with some value…

Once done, your products should appear on shop page , without editing them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM