Automattic\WooCommerce\StoreApi\Utilities

OrderController::validate_order_before_paymentpublicWC 1.0

Final validation ran before payment is taken.

By this point we have an order populated with customer data and items.

Method of the class: OrderController{}

No Hooks.

Returns

null. Nothing (null).

Usage

$OrderController = new OrderController();
$OrderController->validate_order_before_payment( $order );
$order(WC_Order) (required)
Order object.

OrderController::validate_order_before_payment() code WC 9.9.3

public function validate_order_before_payment( \WC_Order $order ) {
	$needs_shipping          = wc()->cart->needs_shipping();
	$chosen_shipping_methods = wc()->session->get( 'chosen_shipping_methods', [] );

	$this->validate_coupons( $order );
	$this->validate_email( $order );
	$this->validate_selected_shipping_methods( $needs_shipping, $chosen_shipping_methods );
	$this->validate_addresses( $order, $needs_shipping );

	// Perform custom validations.
	$this->perform_custom_order_validation( $order );
}