Title: Cart Refresh Disabling Functions.php
Last modified: May 16, 2023

---

# Cart Refresh Disabling Functions.php

 *  Resolved [tanner96](https://wordpress.org/support/users/tanner96/)
 * (@tanner96)
 * [3 years ago](https://wordpress.org/support/topic/cart-refresh-disabling-functions-php/)
 * 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 pageI have toggled off the checkout page**Does not work**
 * The only thing that works is disabling FDP altogether. Code is below
 *     ```wp-block-code
       // [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](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fcart-refresh-disabling-functions-php%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Thread Starter [tanner96](https://wordpress.org/support/users/tanner96/)
 * (@tanner96)
 * [3 years ago](https://wordpress.org/support/topic/cart-refresh-disabling-functions-php/#post-16742154)
 * 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](https://i.imgur.com/VO1TRNX.png)
 * The issue is resolved
 *  Plugin Author [Jose Mortellaro](https://wordpress.org/support/users/giuse/)
 * (@giuse)
 * [3 years ago](https://wordpress.org/support/topic/cart-refresh-disabling-functions-php/#post-16779193)
 * Hi [@tanner96](https://wordpress.org/support/users/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.

 * ![](https://ps.w.org/freesoul-deactivate-plugins/assets/icon-256x256.png?rev=
   2847508)
 * [Freesoul Deactivate Plugins - Disable plugins on individual WordPress pages](https://wordpress.org/plugins/freesoul-deactivate-plugins/)
 * [Support Threads](https://wordpress.org/support/plugin/freesoul-deactivate-plugins/)
 * [Active Topics](https://wordpress.org/support/plugin/freesoul-deactivate-plugins/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/freesoul-deactivate-plugins/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/freesoul-deactivate-plugins/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Jose Mortellaro](https://wordpress.org/support/users/giuse/)
 * Last activity: [3 years ago](https://wordpress.org/support/topic/cart-refresh-disabling-functions-php/#post-16779193)
 * Status: resolved