【发布时间】:2021-11-21 03:35:00
【问题描述】:
根据表单的填充方式,我想更新预先存在的 Woocommerce 订单。有没有人试过这个?我正在考虑使用Woocommerce REST API for updating orders,但是当所有内容都在同一个站点上时,似乎应该有另一种方式。
【问题讨论】:
标签: wordpress woocommerce
根据表单的填充方式,我想更新预先存在的 Woocommerce 订单。有没有人试过这个?我正在考虑使用Woocommerce REST API for updating orders,但是当所有内容都在同一个站点上时,似乎应该有另一种方式。
【问题讨论】:
标签: wordpress woocommerce
您可以结合使用 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 );
}
}
【讨论】: