Switch spaces with tabs
This commit is contained in:
parent
836c7e2821
commit
ca14643194
|
@ -172,40 +172,39 @@ class OrderController {
|
||||||
$this->validate_selected_shipping_methods( $needs_shipping, $chosen_shipping_methods );
|
$this->validate_selected_shipping_methods( $needs_shipping, $chosen_shipping_methods );
|
||||||
$this->validate_addresses( $order );
|
$this->validate_addresses( $order );
|
||||||
|
|
||||||
// Perform custom validations
|
// Perform custom validations
|
||||||
$this->perform_custom_order_validation( $order );
|
$this->perform_custom_order_validation( $order );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform custom order validation via WooCommerce hooks.
|
* Perform custom order validation via WooCommerce hooks.
|
||||||
*
|
*
|
||||||
* Allows plugins to perform custom validation before payment.
|
* Allows plugins to perform custom validation before payment.
|
||||||
*
|
*
|
||||||
* @param \WC_Order $order Order object.
|
* @param \WC_Order $order Order object.
|
||||||
* @throws RouteException if validation fails.
|
* @throws RouteException if validation fails.
|
||||||
*/
|
*/
|
||||||
protected function perform_custom_order_validation( \WC_Order $order ) {
|
protected function perform_custom_order_validation( \WC_Order $order ) {
|
||||||
$validation_errors = new \WP_Error();
|
$validation_errors = new \WP_Error();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow plugins to perform custom validation before payment.
|
* Allow plugins to perform custom validation before payment.
|
||||||
*
|
*
|
||||||
* Plugins can add errors to the $validation_errors object.
|
* Plugins can add errors to the $validation_errors object.
|
||||||
*
|
*
|
||||||
* @param \WC_Order $order The order object.
|
* @param \WC_Order $order The order object.
|
||||||
* @param \WP_Error $validation_errors WP_Error object to add custom errors to.
|
* @param \WP_Error $validation_errors WP_Error object to add custom errors to.
|
||||||
*/
|
*/
|
||||||
do_action( 'woocommerce_checkout_validate_order_before_payment', $order, $validation_errors );
|
do_action( 'woocommerce_checkout_validate_order_before_payment', $order, $validation_errors );
|
||||||
|
|
||||||
// Check if there are any errors after custom validation
|
// Check if there are any errors after custom validation
|
||||||
if ( $validation_errors->has_errors() ) {
|
if ( $validation_errors->has_errors() ) {
|
||||||
throw new RouteException(
|
throw new RouteException(
|
||||||
'woocommerce_rest_checkout_custom_validation_error',
|
'woocommerce_rest_checkout_custom_validation_error',
|
||||||
implode( ' ', $validation_errors->get_error_messages() ),
|
implode( ' ', $validation_errors->get_error_messages() ),
|
||||||
400
|
400
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue