Skip to content

Commit

Permalink
Merge pull request woocommerce#24758 from TimothyBJacobs/patch-1
Browse files Browse the repository at this point in the history
Use a separate first parameter for the WP_Error
  • Loading branch information
claudiosanches authored Oct 2, 2019
2 parents fb0c9e5 + b9bb4a7 commit 4d1f776
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions includes/class-wc-ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -898,10 +898,11 @@ public static function add_order_item() {
if ( ! $product ) {
throw new Exception( __( 'Invalid product ID', 'woocommerce' ) . ' ' . $product_id );
}
$check = apply_filters( 'woocommerce_ajax_add_order_item_validation', $product, $order, $qty );
$validation_error = new WP_Error();
$validation_error = apply_filters( 'woocommerce_ajax_add_order_item_validation', $validation_error, $product, $order, $qty );

if ( is_wp_error( $check ) ) {
throw new Exception( $check->get_error_message() );
if ( $validation_error->get_error_code() ) {
throw new Exception( '<strong>' . __( 'Error:', 'woocommerce' ) . '</strong> ' . $validation_error->get_error_message() );
}
$item_id = $order->add_product( $product, $qty );
$item = apply_filters( 'woocommerce_ajax_order_item', $order->get_item( $item_id ), $item_id, $order, $product );
Expand Down

0 comments on commit 4d1f776

Please sign in to comment.