Backoffice - max cost margin #31

Merged
bilal.catic merged 22 commits from backoffice-max-cost-margin into master 2018-10-15 00:24:34 +02:00
Showing only changes of commit 8df4ec3dc7 - Show all commits

View File

@@ -2,6 +2,22 @@
class Wiaas_Checkout {
public static function init(){
add_action( 'woocommerce_before_checkout_process', array(__CLASS__, 'validate_wiaas_packages'));
}
public static function validate_wiaas_packages(){
//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)){
throw new Exception('Package ' . $item['data']->get_title() . ' cannot be purchased at the moment');
}
}
}
/**
* Process the order checkout.
*
@@ -18,16 +34,6 @@ class Wiaas_Checkout {
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)){
throw new Exception('Package ' . $item['data']->get_title() . ' cannot be purchased at the moment');
}
}
$order_id = WC()->checkout()->create_order(array());
$order = wc_get_order( $order_id );
@@ -101,3 +107,5 @@ class Wiaas_Checkout {
}
}
}
Wiaas_Checkout::init();