prevent checkout with invalid package

This commit is contained in:
Bilal Catic
2018-10-10 14:41:57 +02:00
parent 63c1ee945f
commit 8d2b1e52b4

View File

@@ -16,6 +16,20 @@ class Wiaas_Checkout {
wc_set_time_limit( 0 );
do_action( 'woocommerce_before_checkout_process' );
$customer = wp_get_current_user();
//check if any package became invalid
$items = WC()->cart->get_cart();
foreach($items as $item) {
$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)){
return false;
}
}
$order_id = WC()->checkout()->create_order(array());
$order = wc_get_order( $order_id );
// Check if cart empty before proceeding
if (WC()->cart->is_empty()) {