WooCommerce: Hide Coupon Code @ Cart & Checkout Page

 When you apply a coupon code programmatically, or when you really need it anyway, you may want to hide the coupon code on the cart page.

This is simply because you want to avoid that certain customers will know the coupon code and try to give it to someone else.

woocommerce-hide-coupon-code-cart-page
WooCommerce: hide coupon codes on the cart page

Snippet (PHP): Remove / Rename Coupon Code from Cart Totals – WooCommerce

/**
 * @snippet       Hide WooCommerce Coupon Code - WooCommerce Cart & Checkout
 * @how-to        Get CustomizeWoo.com FREE
 * @sourcecode    https://businessbloomer.com/?p=536
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 3.5.3
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */
 
add_filter( 'woocommerce_cart_totals_coupon_label', 'bbloomer_hide_coupon_code', 99, 2 );
 
function bbloomer_hide_coupon_code( $label, $coupon ) {
    return 'Coupon Applied!';
}

Order by 6pm and get it delivered tomorrow!” notice @ Single Product Page

Order by 6pm and get it delivered tomorrow!” notice @ Single Product Page

/**
 * @snippet       Pressure notice @ Single Product Page
 * @how-to        Get CustomizeWoo.com FREE
 * @sourcecode    https://businessbloomer.com/?p=111758
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 3.5.4
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */
 
add_action( 'woocommerce_single_product_summary', 'bbloomer_display_pressure_badge', 6 );
   
function bbloomer_display_pressure_badge() {
    echo '<div class="woocommerce-message">Order by 6pm and get it delivered tomorrow!</div>';
}
Adding some “pressure” to the WooCommerce single product page



WooCommerce: Hide Shipping Rates if Free Shipping Available

 If Free Shipping is available, you possibly don’t want to show the other paid shipping options. WooCommerce shows by default all shipping rates that match a given shipping zone, so it’s not possible to achieve this from the settings alone.

You need PHP for that. In this example, we will disable all shipping methods but “Free Shipping” so that free shipping remains the only possible choice. And here’s the code to add to your functions.php 🙂

Remove a given Flat Rate when Free Shipping is available @ WooCommerce Cart / Checkout

PHP Snippet #1: Unset Specific Shipping Rate When Free Shipping rate is available

To find the new “shipping method names” e.g. “free_shipping:8“, please see the screenshot at the bottom of this other tutorial: https://businessbloomer.com/woocommerce-disable-free-shipping-if-cart-has-shipping-class/
/**
 * @snippet       Hide one shipping option in one zone when Free Shipping is available
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 3.6.3
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */
  
add_filter( 'woocommerce_package_rates', 'bbloomer_unset_shipping_when_free_is_available_in_zone', 10, 2 );
   
function bbloomer_unset_shipping_when_free_is_available_in_zone( $rates, $package ) {
      
// Only unset rates if free_shipping is available
if ( isset( $rates['free_shipping:8'] ) ) {
     unset( $rates['flat_rate:1'] );
}    
     
return $rates;
  
}

PHP Snippet #2: Unset ALL Shipping Rates in ALL Zones when ANY Free Shipping Rate is Available

/**
 * @snippet       Hide ALL shipping rates in ALL zones when Free Shipping is available
 * @how-to        Get CustomizeWoo.com FREE
 * @sourcecode    https://businessbloomer.com/?p=260
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 3.6.3
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */
  
add_filter( 'woocommerce_package_rates', 'bbloomer_unset_shipping_when_free_is_available_all_zones', 10, 2 );
   
function bbloomer_unset_shipping_when_free_is_available_all_zones( $rates, $package ) {
      
$all_free_rates = array();
     
foreach ( $rates as $rate_id => $rate ) {
      if ( 'free_shipping' === $rate->method_id ) {
         $all_free_rates[ $rate_id ] = $rate;
         break;
      }
}
     
if ( empty( $all_free_rates )) {
        return $rates;
} else {
        return $all_free_rates;
}
 
}

Shipping Rates Not Working After Implementing this PHP?

You probably need to:

a) empty the Cart and start testing again

b) clear customer sessions:

Clear Customer Sessions – WooCommerce System Status Tools

Free Shipping Threshold @ Cart Page