From d7c34c3b0b90adbb1723bf58d442e54c0fc10f2b Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Sun, 14 Oct 2018 23:38:38 +0200 Subject: [PATCH] remove double code, change hook for validation --- .../app/plugins/wiaas/includes/class-wiaas-checkout.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-checkout.php b/backend/app/plugins/wiaas/includes/class-wiaas-checkout.php index 8976880..facf552 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-checkout.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-checkout.php @@ -3,7 +3,7 @@ class Wiaas_Checkout { public static function init(){ - add_action( 'woocommerce_before_checkout_process', array(__CLASS__, 'validate_wiaas_packages')); + add_action( 'woocommerce_check_cart_items', array(__CLASS__, 'validate_wiaas_packages')); } public static function validate_wiaas_packages(){ @@ -33,13 +33,8 @@ 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()); - $order = wc_get_order( $order_id ); + $customer = wp_get_current_user(); // Check if cart empty before proceeding if (WC()->cart->is_empty()) {