ACF\Pro\Forms

WC_Order::save_order │ public │ ACF 6.4

Saves ACF fields to the current order.

Метод класса: WC_Order{}

Хуков нет.

Возвращает

void. Ничего (null).

Использование

$WC_Order = new WC_Order();
$WC_Order->save_order( $order_id );
$order_id(int) (обязательный)
The order ID.

Список изменений

С версии 6.4 Введена.

Код WC_Order::save_order() ACF 6.8.11

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;
	}

	// Only accept fields rendered for this order, or from field groups located on it.
	acf_restrict_save_input(
		array(
			'context'    => 'woo_order',
			'post_id'    => 'woo_order_' . $order_id,
			'render_ids' => array( 'woo_order_' . $order_id ),
			'screen'     => array(
				'post_id'   => $order_id,
				'post_type' => $this->get_order_location_type( $order_id ),
			),
		)
	);

	// 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 );
}