• Resolved tanner96

    (@tanner96)


    After a few hours we have narrowed down our issue to the FDP

    We have this code in our functions.php that quite simply takes $350 off all package rates if the cart is over 4500. However, with FDP enabled – you will notice that the $350 deduction is visible on first load of the Checkout Page, but the cart contents will be refreshed by another ajax call and reset to their original state, removing the $350 discount.

    I have enabled all plugins on the checkout page
    I have disabled all plugins on the checkout page
    I have toggled off the checkout page
    Does not work

    The only thing that works is disabling FDP altogether. Code is below

    
    // [DO NOT ENQUE] $350 Discount on Shipping if Cart is Over 4500 [Shipping Pages Only]
    function apply_shipping_discount( $rates ) {
        
        if ( ! is_checkout() ) {
            return $rates;
        }
        
        $cart_total = WC()->cart->get_subtotal();
        if ( $cart_total > 4500 ) {
            $discount_amount = 350;
            foreach( $rates as $key => $rate ) {
                $rates[$key]->cost = $rates[$key]->cost - $discount_amount;
    
            }
        }
        return $rates;
    }
    add_filter( 'woocommerce_package_rates', 'apply_shipping_discount' );

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter tanner96

    (@tanner96)

    I had a revelation after posting this, but it seems it should still be something that is looked into.

    After turning this on: https://i.imgur.com/VO1TRNX.png

    The issue is resolved

    Plugin Author Jose Mortellaro

    (@giuse)

    Hi @tanner96

    a little late, but better than never.

    If you put your code in functions.php it means it’s in your theme.
    The theme on the row shown in your screenshot must be active or your code will not run during the order update.

    Have a great day!

    Jose

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Cart Refresh Disabling Functions.php’ is closed to new replies.