ACF\Pro\Forms
WC_Order::save_order
Saves ACF fields to the current order.
Method of the class: WC_Order{}
No Hooks.
Returns
null. Nothing (null).
Usage
$WC_Order = new WC_Order(); $WC_Order->save_order( $order_id );
- $order_id(int) (required)
- The order ID.
Changelog
| Since 6.4 | Introduced. |
WC_Order::save_order() WC Order::save order code ACF 6.8.8
public function save_order( int $order_id ) {
// Bail if not using HPOS to prevent a double-save.
if ( ! $this->is_hpos_enabled() ) {
return;
}
if ( empty( $_POST['acf'] ) || ! acf_verify_nonce( 'post' ) ) {
return;
}
// Remove the action to prevent an infinite loop via $order->save().
remove_action( 'woocommerce_update_order', array( $this, 'save_order' ), 10 );
acf_save_post( 'woo_order_' . $order_id );
}