Okay
  Public Ticket #4537806
display HT price for btob customer for minimum amount rules
Open

Comments

  •  1
    christophe WATTEAU started the conversation

    Hello,

    Could you help us for display HT price for minimum amount rules (see attached files)

    thanks in advance for your reply.

    Regards 

    Christophe

    Attached files:  display minimum amount HT.jpg

  •  2,641
    WebWizards replied

    Hi Christophe,

    Thank you for purchasing our plugin!

    To solve this, please add the following to your theme's functions.php file or any code snippets plugin:

    add_filter('b2bking_minmax_order_total_calculation_basis', function($val){
    return WC()->cart->cart_contents_total;
    }, 10, 1);

    This should make the minimum amount rules use the HT (excluding tax) price instead.

     

    Let me know if that worked!

    Kind regards,
    Stefan

  •  1
    christophe WATTEAU replied

    Hi stefan,

    Sorry for my late reply, perfect for US for your code php

    We have another request for the dynamic rule below that we have implemented on our website

    Discount (Percentage) of 10% for B2B customers (logged-in) on Total cart > 1000 euros HT

    it's possible to display the following text in the shopping cart: (cf screenshot)

    "10% additional discount on orders over 1000 euros excluding tax, more than xxx euros to get an additional 10%"

    Thanks in advance for your help
    Regards
    Christophe

    Attached files:  Capture cart.JPG

  •  2,641
    WebWizards replied

    Hi Christophe,

    Great to hear that worked,

     

    B2BKing itself doesn't have that feature but it's fairly simple enough to achieve with a code snippet:

    add_action( 'woocommerce_before_cart_table', 'custom_cart_discount_message' );
    add_action( 'woocommerce_before_checkout_form', 'custom_cart_discount_message' );
    
    function custom_cart_discount_message() {
        $threshold = 1000; // € HT
        $cart_total_ex_tax = WC()->cart->get_subtotal(); // subtotal excluding tax
    
        if ( $cart_total_ex_tax >= $threshold ) {
            $message = '🎉 Félicitations ! Vous bénéficiez d\'une <strong>remise supplémentaire de 10&nbsp;%</strong> sur votre commande&nbsp;!';
            echo '<div class="woocommerce-info">' . $message . '</div>';
        } else {
            $remaining = $threshold - $cart_total_ex_tax;
            $remaining_formatted = number_format( $remaining, 2, ',', '&nbsp;' );
            $message = sprintf(
                '💡 <strong>-10&nbsp;%% supplémentaires</strong> dès 1&nbsp;000&nbsp;€ HT — plus que <strong>%s&nbsp;€</strong> pour en profiter&nbsp;!',
                $remaining_formatted
            );
            echo '<div class="woocommerce-info">' . $message . '</div>';
        }
    }

    This PHP snippet can be added to functions.php, or by following our guide here: https://woocommerce-b2b-plugin.com/docs/how-to-add-a-snippet-php-or-js/

     

    Let me know if you need any adjustments to how that works or looks etc, and I can make the changes for you,

     

    Kind regards,

    Stefan

  •  1
    christophe WATTEAU replied

    Hi stefan,

    ok thanks a lot it's perfect !

    best regards

    Christophe

  •  1
    christophe WATTEAU replied

    Hi Stefan,

    just little things, The message appears in the B2C and B2B shopping carts. I would like it to appear only in the B2B shopping cart.

    Thanks in advance for your help.

    Regards

    Christophe

  •  2,641
    WebWizards replied

    Hi Christophe,

    Good to hear that worked :)

    I have now modified the code snippet to ensure the message only appears for B2B users, as requested.

    Please find the updated code here: https://pastecode.io/s/frkobtcj

    You can simply replace the previous snippet with this new version.

    Let me know if you need anything,

    Kind regards,
    Stefan

  •  1
    christophe WATTEAU replied

    Hi Stefan,

    Very good, it's perfect now.

    Thanks for much

    Christophe

  •  2,641
    WebWizards replied

    Hi Christophe,

    My pleasure! If you run into any other issues or anything else we can help with, please let us know.

    Also, if you have a moment, I would really appreciate it if you considered leaving a quick rating for the plugin - it takes just a few seconds and is a big help to us! (We're also on G2 and Capterra)

    Kind regards,
    Stefan