Added a check to prevent variable product parents from being added to orders.
This commit is contained in:
parent
928ec871fa
commit
baeae0652c
|
@ -898,6 +898,10 @@ class WC_AJAX {
|
|||
if ( ! $product ) {
|
||||
throw new Exception( __( 'Invalid product ID', 'woocommerce' ) . ' ' . $product_id );
|
||||
}
|
||||
if ( 'variable' === $product->get_type() ) {
|
||||
/* 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 );
|
||||
|
||||
|
|
Loading…
Reference in New Issue