remove double code, change hook for validation

This commit is contained in:
Bilal Catic
2018-10-14 23:38:38 +02:00
parent 55dc87e174
commit d7c34c3b0b

View File

@@ -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()) {