【问题标题】:Woocommerce: updating an order based on (Gravity) form submissionWoocommerce:根据(重力)表单提交更新订单
【发布时间】:2021-11-21 03:35:00
【问题描述】:

根据表单的填充方式,我想更新预先存在的 Woocommerce 订单。有没有人试过这个?我正在考虑使用Woocommerce REST API for updating orders,但是当所有内容都在同一个站点上时,似乎应该有另一种方式。

【问题讨论】:

    标签: wordpress woocommerce


    【解决方案1】:

    您可以结合使用 gform_after_submission 和 update_post_meta。一个很好的技巧是,如果您可以将需要更新的订单号存储在重力表单本身中:

    add_action( 'gform_after_submission_3', 'update_woocommerce_order', 10, 2 );//replace 3 with your form id
        function update_woocommerce_order($entry, $form ){
         if($entry['2'] == 'Test Value'){//This could be your form condition to trigger update
           $order_id = $entry['6'];// replace 6 with the form field number that contains the order number
           $phone = $entry['7'];// replace 7 with the form field number that contains the phone number
           update_post_meta( $order_id, '_billing_phone', $phone );   
         }
        }
    

    【讨论】:

      猜你喜欢
      • 2022-01-07
      • 2021-04-08
      • 2019-11-11
      • 2021-07-31
      • 2016-03-06
      • 2014-02-13
      • 1970-01-01
      • 2021-01-29
      • 2018-05-12
      相关资源
      最近更新 更多