woocommerce_ajax_add_order_item_validation

woocommerce_ajax_add_order_item_validation

Appears in: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
Hook Type: filter

See hook in core

Displaying hooks found in version: woocommerce.9.7.1

apply_filters('woocommerce_ajax_add_order_item_validation') is found 1 times:

  • /includes/class-wc-ajax.php line 1068
    1064
    1065
    1066
    1067
    1068
    1069
    1070
    1071
    1072
    1073
    1074
        /* translators: %s product name */
        throw new Exception( sprintf( __( '%s is a variable product parent and cannot be added.', 'woocommerce' ), $product->get_name() ) );
    }
    $validation_error = new WP_Error();
    $validation_error = apply_filters( 'woocommerce_ajax_add_order_item_validation', $validation_error, $product, $order, $qty );
     
    if ( $validation_error->get_error_code() ) {
        /* translators: %s: error message */
        throw new Exception( sprintf( __( 'Error: %s', 'woocommerce' ), $validation_error->get_error_message() ) );
    }
    $item_id                 = $order->add_product( $product, $qty, array( 'order' => $order ) );