Okay
  Public Ticket #3190889
Shipping cost by weight
Closed

Comments

  •  1
    Fernando started the conversation

    Hello,

    I tried to add shipping fees by weight. I already added free shipping per customer group B2B or B2C using the following guide:

    https://woocommerce-b2b-plugin.com/docs/set-up-different-shipping-costs-for-b2b-b2c-order-value-dynamic-shipping-costs/

    When I used Wholesale Suite (WS) and Flexible Shipping (FS) plugins, I enabled on WS that shipping methods used for wholesale customers are not displayed for retail customers and worked very well. And shipping methods were setup by weight as method to compute cost using FS. Now I dont know how to configure shipping cost using weight as base. The shipping cost is the same. And how to set priority in order that free shipping is displayed when customer group reach certain minimum amount of the order or is it automatically that if free shipping is available no other shipping methods are displayed?

    Fernando

  •  2,218
    WebWizards replied

    Hello Fernando,


    1) "or is it automatically that if free shipping is available no other shipping methods are displayed?"

    By default in WooCommerce, if free shipping is available, other methods are displayed as well.

    If you want to automatically hide other methods when free shipping is available, you can use this WooCommerce code snippet:

    function hide_shipping_when_free_is_available( $rates, $package ) {
        $new_rates = array();
        foreach ( $rates as $rate_id => $rate ) {
            // Only modify rates if free_shipping is present.
            if ( 'free_shipping' === $rate->method_id ) {
                $new_rates[ $rate_id ] = $rate;
                break;
            }
        }
        if ( ! empty( $new_rates ) ) {
            //Save local pickup if it's present.
            foreach ( $rates as $rate_id => $rate ) {
                if ('local_pickup' === $rate->method_id ) {
                    $new_rates[ $rate_id ] = $rate;
                    break;
                }
            }
            return $new_rates;
        }
        return $rates;
    }
    add_filter( 'woocommerce_package_rates', 'hide_shipping_when_free_is_available', 10, 2 );
    

    This can be added to functions.php or to any snippets plugin


    2) "how to set priority in order that free shipping is displayed when customer group reach certain minimum amount of the order"

    This can be done by following our guide here https://woocommerce-b2b-plugin.com/docs/how-to-set-up-free-shipping-for-bulk-orders-dynamic-rules/

    Basically, you must first go to WooCommerce -> Settings -> Shipping and create a Free shipping method with a very high minimum such as image-15-1024x406.png

    Secondly, you would go to B2BKing -> Dynamic Rules and create a free shipping rule:

    image-16-1024x404.png


    The above rule will automatically activate free shipping when the order total is > $1500


    3) "I enabled on WS that shipping methods used for wholesale customers are not displayed for retail customers and worked very well"

    In B2BKing, you can go to B2BKing -> Groups, and for each group/b2c/logged out users, you can choose which shipping or payment methods are enabled or disabled.  For example

    image-1-1024x559.png


    4) B2BKing itself does not have features to configure shipping by weight - that's probably outside the scope of our plugin.

    If you do not use the FS plugin, then there is also a WooCommerce mechanism of setting up shipping by weight through the use of shipping classes: https://woocommerce.com/document/product-shipping-classes/

    Not sure if that's as flexible as the FS plugin though.


    Kind regards,

    Stefan