From 14eda981b79d0880adeaad96752aa8c1ce9df965 Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Sun, 14 Oct 2018 14:24:06 +0200 Subject: [PATCH] add notice instead of throwing error --- backend/app/plugins/wiaas/includes/class-wiaas-checkout.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-checkout.php b/backend/app/plugins/wiaas/includes/class-wiaas-checkout.php index e202e1a..8976880 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-checkout.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-checkout.php @@ -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());