• Resolved Marius Schulte

    (@mariusiscoding)


    I have the following Code but the output of the hooks is not what I think it should be.
    The discount_price is outputting 0 and save_amount outputting 1.

    I want have some custom coupon validations going on and need the discounted price for that.

    Thanks for helping out!

    add_filter('woocommerce_coupon_is_valid', 'custom_coupon_validation', 10, 2);
    function custom_coupon_validation($is_valid, $coupon)
    {
        $cart = WC()->cart;
        $cart_items = $cart->get_cart();
    
        foreach ($cart_items as $cart_item_key => $cart_item) {	
    
            //these ones are not outputing the right results in my case
    	$discount_price = apply_filters('advanced_woo_discount_rules_get_cart_item_discount_price', false, $cart_item);
    	
    	$save_amount = apply_filters('advanced_woo_discount_rules_get_cart_item_saved_amount', false, $cart_item);
    
    	//Debug Output:
            throw new Exception(__('Discount: '.$save_amount, 'woocommerce'), 100);
            //also using print_r outputs 0
            throw new Exception(__('Test' . print_r($discount_price), 'woocommerce'), 100);
        
        }
        //...
    }
    
Viewing 1 replies (of 1 total)
  • sangeethasrinivasan

    (@sangeethasrinivasan)

    Hi,

    Thank you for reaching out.

    We had a check in our local with the given code and it seems discount_price?and?save_amount is outputting correctly in cart.

    To assist you further, we kindly request that you open a support ticket at the following link:?https://www.flycart.org/support?with the below details:

    • Version of Discount Rules for Woocommerce plugin you are using
    • Screenshots of discount rules you have configured
    • Screenshots of woocommerce coupon configuration
    • Cart page screenshot indicating the issue
    • Site URL

    So that our dedicated support engineers will promptly provide you with solutions by reproducing the same in our local.

    We greatly appreciate your cooperation.

    Thanks

    Team Flycart

Viewing 1 replies (of 1 total)
  • The topic ‘Getting Cart Values’ is closed to new replies.