脚本宝典收集整理的这篇文章主要介绍了php – Woocommence`update_post_meta`没有更新数据库值,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
如果我有产品x(id:5)和变体y(id:400)并且我运行update_post_Meta(400,“_ regular_PRice”,13.00);它没有更新数据库.这是非常奇怪的,因为当我点击编辑产品(wp-admin)时,更新价格13.00显示在变体面板中,我必须单击更新以便更新以供客户查看.这是常规行为,如果是,如何在update_post_Meta函数执行后立即更新数据库?
(图片)update_post_Meta()摘要页面后的价格
.
这是我进行批量更新的代码
// $attribute_value/$VARiation_value are set correctly! while ($loop->have_posts() ) : $loop->the_post(); global $product; $variations = new WC_Product_Variable($product->post->ID); $variations = $variations->get_available_variations(); foreach ($variations as $key => $variation){ foreach ($variation["attributes"] as $key => $attribute_value): if($attribute_value == $variation_value): update_post_Meta( $variation['variation_id'],'_regular_price',$regular_price); endif; enDForeach; } endwhile;
我问了同样的问题,但没有回复wordpress论坛
http://wordpress.org/support/topic/update_post_meta-is-not-updating-the-actual-values?replies=1#post-5742842
woocommerce /包括/ WC-产品的functions.PHP:417
$regular_price = get_post_meta( $product_id,true ); update_post_Meta( $product_id,'_price',$regular_price ); update_post_Meta( $product_id,'_sale_price','' ); update_post_Meta( $product_id,'_sale_price_dates_From','_sale_price_dates_to','' ); wc_delete_product_transients( $product_id );
您似乎必须更新“_price”元,甚至删除瞬态以更新产品价格.
要删除产品临时呼叫:
wc_delete_product_transients( $product_id );
以上是脚本宝典为你收集整理的php – Woocommence`update_post_meta`没有更新数据库值全部内容,希望文章能够帮你解决php – Woocommence`update_post_meta`没有更新数据库值所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。