doudui1850 2015-07-14 05:59
浏览 16

Update_post_meta函数缺少进程

I am writing a simple plugin which updates meta values for woocommerce products. Did some good research and worked on it, got 90% of what I wanted, a simple process is missing though. Let me explain the issue with a simple example.

Product A with Variations

 --------------------------------------
 variations:      500 gms | 1 kg | 2 kg
  --------------------------------------
 Regular Price:   100     | 200  | 400
 --------------------------------------
 Sale Price :     90      | 180  | 360  

Now I am using the function update_post_meta to update the prices from my plugin. It works perfectly for filled values, but let say if we don't want to use that variation and make both values (sale price and regular price) blank and do the same process,database values updated blank but in display it shows 0 value.

Where as If we make blank value from product edit page Wordpress, it works as expected.

Can anybody please tell me what I am missing here ?

  • 写回答

1条回答 默认 最新

  • dongyong1400 2015-07-14 10:38
    关注

    I think I figured this out. As I was saying something was missing , this is it.

    $id = get_the_ID(); WC_Product_Variable::sync( $id );
    

    variables sync process is needed in order to make this work.

    I hope it helps.

    评论

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程