以编程方式创建的产品不会显示在 WooCommerce 上
Programmatically created products doesn't show on WooCommerce
我创建了一个 cron 作业来获取批发商产品列表并将它们插入数据库。
但是当我以这种方式创建产品时,它不会显示在商店中,只显示在管理员中。我进入任意商品的编辑页面,不对商品做任何修改,点击保存按钮后,店铺中就出现了这个商品。
产品会出现什么问题?
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"…
同时检查 wp_postmeta
table 您还设置了:
'_visibility'
键到'visible'
值
'_stock_status'
键到'instock'
值
'_stock'
有一些值…
完成后,您的产品应该会出现在商店页面,无需编辑。
我创建了一个 cron 作业来获取批发商产品列表并将它们插入数据库。
但是当我以这种方式创建产品时,它不会显示在商店中,只显示在管理员中。我进入任意商品的编辑页面,不对商品做任何修改,点击保存按钮后,店铺中就出现了这个商品。
产品会出现什么问题?
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"…
同时检查 wp_postmeta
table 您还设置了:
'_visibility'
键到'visible'
值'_stock_status'
键到'instock'
值'_stock'
有一些值…
完成后,您的产品应该会出现在商店页面,无需编辑。