• Resolved babiskalogirou

    (@babiskalogirou)


    Hello dear friends! I would like to know if there is a way to hide a specific class when cart subtotal is above a certain amount. More specifically, i would like to hide the class “inactive-shipping” that is include in the shipping methods. Thank you in advance.

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

Viewing 6 replies - 1 through 6 (of 6 total)
  • Saif

    (@babylon1999)

    Hello @babiskalogirou,

    Hello dear friends! I would like to know if there is a way to hide a specific class when cart subtotal is above a certain amount. More specifically, i would like to hide the class “inactive-shipping” that is include in the shipping methods. Thank you in advance.

    I understand you want to hide a CSS class, I’ve included the syntax below but I didn’t find that class in the cart.

    
    .inactive-shipping{
      display: none !important;
    }

    Can you please instead attach a highlighted screenshot of the place you want to hide?

    You can use a service like Snipboard.

    Look forward to hearing from you.

    Thread Starter babiskalogirou

    (@babiskalogirou)

    Hello dear @babylon1999
    Thank you very much for your kind response.
    I’m looking for a way to hide this class,
    only when the cart subtotal is over a certain amount.

    https://snipboard.io/aHdDG3.jpg

    Saif

    (@babylon1999)

    Hello @babiskalogirou,

    I’m looking for a way to hide this class,
    only when the cart subtotal is over a certain amount.

    Please note that hiding the CSS class won’t stop customers from choosing that shipping option.

    Nonetheless here’s the snippet for it, you can it using you can add it to your functions.php file or use a plugin like Code snippet.

    /* --- Remove CSS class if total is 150$   --- */
    add_action( 'wp_print_scripts', 'Remove_CSS_Class_Conditionally' );
    
    function Remove_CSS_Class_Conditionally() {
    
    	global $woocommerce;
    
            $subtotal = WC()->cart->cart_contents_total;
    
    	if( $subtotal > 150 ) { 
    	
    	?> 
      <style>
           .inactive-shipping{
      display: none !important;
    }
    	 
    	</style> <?php
    }}

    I’ve made the limit 150$, but you can change it to any value. ??

    If you want an option to completely remove the shipping option based on the cart total, then I strongly recommend going with the Table Rate Shipping extension.

    Hope this helps!

    Thread Starter babiskalogirou

    (@babiskalogirou)

    I can’t thank you enough for your assistance!
    It works fine, however it does not take effect when updating the cart (it does by refreshing the cart page, though). I am already grateful, but i would very much appreciate it if you suggested me a way to overcome this last obstacle.

    anastas10s

    (@anastas10s)

    Howdy @babiskalogirou ??

    I can’t thank you enough for your assistance!
    It works fine, however it does not take effect when updating the cart (it does by refreshing the cart page, though). I am already grateful, but i would very much appreciate it if you suggested me a way to overcome this last obstacle.

    Thank you for the kind words. For further flexibility with said customizations, feel free to check out an extension, like Table Rate Shipping (directly linked here) my colleague suggested.

    Kindly keep in mind we are not developers and only offer support for existing functionality.

    Please see our Support Policy: https://www.woocommerce.com/support-policy/

    For assistance with customization or development with your site, we recommend that you seek help from:

    * A local web developer
    * Codeable.io
    * WooExperts
    * Stackexchange

    I hope that helps you to figure it out.

    Feel free to get back to us if you have further questions.

    Thread Starter babiskalogirou

    (@babiskalogirou)

    Hello dear @anastas10s

    I do undestand. Thank very much, once more.
    You see, i’m a beginner ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Hide a specific class when cart subtotal is above a certain amount’ is closed to new replies.