Merge pull request #24518 from pinalj/master

Add new hook for add-order-item
This commit is contained in:
Claudio Sanches 2019-08-29 16:48:13 -03:00 committed by GitHub
commit df887bccc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -898,7 +898,11 @@ class WC_AJAX {
if ( ! $product ) {
throw new Exception( __( 'Invalid product ID', 'woocommerce' ) . ' ' . $product_id );
}
$check = apply_filters( 'woocommerce_ajax_add_order_item_validation', $product, $order, $qty );
if ( is_wp_error( $check ) ) {
throw new Exception( $check->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 );
$added_items[ $item_id ] = $item;