add notice instead of throwing error

This commit is contained in:
Bilal Catic
2018-10-14 14:24:06 +02:00
parent 8df4ec3dc7
commit 14eda981b7

View File

@@ -13,7 +13,8 @@ class Wiaas_Checkout {
$item_id = $item['data']->get_id();
if (wc_pb_is_bundle_container_cart_item($item) &&
(Wiaas_Package_Status::get_package_status($item_id) !== Wiaas_Package_Status::AVAILABLE)){
throw new Exception('Package ' . $item['data']->get_title() . ' cannot be purchased at the moment');
wc_add_notice( 'Package ' . $item['data']->get_title() . ' cannot be purchased at the moment', 'error' );
return false;
}
}
}
@@ -32,6 +33,9 @@ class Wiaas_Checkout {
wc_set_time_limit( 0 );
do_action( 'woocommerce_before_checkout_process' );
if(wc_notice_count( 'error' ) > 0) {
return false;
}
$customer = wp_get_current_user();
$order_id = WC()->checkout()->create_order(array());