Fix conflict with shipping while auto add free product

Fix conflict with shipping while auto add free product

add_filter('advanced_woo_discount_rules_free_product_cart_item_data', function ($cart_item_data){
    remove_all_actions('woocommerce_add_to_cart');

    return $cart_item_data;
});
add_action('advanced_woo_discount_rules_after_free_product_added_to_cart', function ($cart_item_key){
    if (!WC()->cart->is_empty()){
        if(class_exists("\Wdr\App\Helpers\Woocommerce")){
            $cart_items = \Wdr\App\Helpers\Woocommerce::getCart();
            if(!empty($cart_items)){
                foreach ($cart_items as $key => $item){
                    if ( !empty( $item['wdr_free_product'] ) ){
                        if(!empty($item["data"])){
                            if($item['wdr_free_product'] == 'Free'){
                                \Wdr\App\Helpers\Woocommerce::setCartProductPrice($item["data"], 0);
                            }
                        }
                    }
                }
            }
        }

    }
});