dan*_*nyo 4 wordpress woocommerce
我目前有一个表单,管理员可以在一个屏幕内批量更新产品的销售价格.
提交表单时,我只需使用update_post_meta,如下所示:
update_post_meta($id,'_sale_price', 'new sale price here');
Run Code Online (Sandbox Code Playgroud)
这会更新_sale_price元键.当我进入管理员检查时,已插入新的销售价格.当我在前端查看产品时,该商品未标记为待售.我必须回去重新保存产品.
我的问题是,woocommerce是否添加了一些其他meta_key来标记产品的销售情况?我在数据库中搜索了所有插入的自定义字段,但只能看到_sale_price.
任何帮助将不胜感激
Dan*_*rly 11
看看WooCommerce中的Product抽象类,下面的php代码可以判断产品是否在销售中:
return ( $this->sale_price != $this->regular_price && $this->sale_price == $this->price );
Run Code Online (Sandbox Code Playgroud)
这似乎表明_price必须与sale_price相同才能将其归类为出售.所以就
update_post_meta($id, '_price', 'new sale price here too');
Run Code Online (Sandbox Code Playgroud)
以及你问题中的代码,它应该工作.
| 归档时间: |
|
| 查看次数: |
7030 次 |
| 最近记录: |