remove double code, change hook for validation
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
class Wiaas_Checkout {
|
class Wiaas_Checkout {
|
||||||
|
|
||||||
public static function init(){
|
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(){
|
public static function validate_wiaas_packages(){
|
||||||
@@ -33,13 +33,8 @@ class Wiaas_Checkout {
|
|||||||
wc_set_time_limit( 0 );
|
wc_set_time_limit( 0 );
|
||||||
|
|
||||||
do_action( 'woocommerce_before_checkout_process' );
|
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());
|
$customer = wp_get_current_user();
|
||||||
$order = wc_get_order( $order_id );
|
|
||||||
|
|
||||||
// Check if cart empty before proceeding
|
// Check if cart empty before proceeding
|
||||||
if (WC()->cart->is_empty()) {
|
if (WC()->cart->is_empty()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user