Support » Plugin: WooCommerce » Free shipping dependency on item and price problem

  • Resolved TristanAZ

    (@tristanaz)


    Hello everybody,

    I’m looking for days for a solution to the following problem:

    If I have a very specific product in the shopping cart, the normal shipping costs should be displayed. If I put other products in the cart and these are worth at least 30 €, all these products, as well as the specific product should be shipped free of charge.

    I have tried it with different dependencies and shipping classes, but I do not get the combination of the specific product and the goods value solved.

    Although I find solutions that when I reach a value of 30 €, this shipping is free. But if a certain item is in the shopping cart and in addition to the product price still has to be purchased for another 30 €, I find neither a plugin nor a helpful solution that makes this possible.

    Has someone an idea for me?

    Greetings,
    Tristan

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hey there,

    you need to set up two shipping calles, and one has to be free shipping. Assign the shipping classes to teach prodcut
    WC-_>Shipping classes
    than define flat rates per classes
    go to WC–>settings–>shipping–>flatrates

    then finaly add this to your theme functions.php

    add_filter( 'woocommerce_cart_shipping_packages', 'bulky_woocommerce_cart_shipping_packages' );
    
    function bulky_woocommerce_cart_shipping_packages( $packages ) {
        // Reset the packages
        $packages = array();
      
        // Bulky items
        $bulky_items   = array();
        $regular_items = array();
        
        // Sort bulky from regular
        foreach ( WC()->cart->get_cart() as $item ) {
            if ( $item['data']->needs_shipping() ) {
                if ( $item['data']->get_shipping_class() == 'free' ) {
                    $bulky_items[] = $item;
                } else {
                    $regular_items[] = $item;
                }
            }
        }
        
        // Put inside packages
        if ( $bulky_items ) {
            $packages[] = array(
                'ship_via'        => array( 'flat_rate' ),
                'contents'        => $bulky_items,
                'contents_cost'   => array_sum( wp_list_pluck( $bulky_items, 'line_total' ) ),
                'applied_coupons' => WC()->cart->applied_coupons,
                'destination'     => array(
                    'country'   => WC()->customer->get_shipping_country(),
                    'state'     => WC()->customer->get_shipping_state(),
                    'postcode'  => WC()->customer->get_shipping_postcode(),
                    'city'      => WC()->customer->get_shipping_city(),
                    'address'   => WC()->customer->get_shipping_address(),
                    'address_2' => WC()->customer->get_shipping_address_2()
                )
            );
        }
        if ( $regular_items ) {
            $packages[] = array(
                'contents'        => $regular_items,
                'contents_cost'   => array_sum( wp_list_pluck( $regular_items, 'line_total' ) ),
                'applied_coupons' => WC()->cart->applied_coupons,
                'destination'     => array(
                    'country'   => WC()->customer->get_shipping_country(),
                    'state'     => WC()->customer->get_shipping_state(),
                    'postcode'  => WC()->customer->get_shipping_postcode(),
                    'city'      => WC()->customer->get_shipping_city(),
                    'address'   => WC()->customer->get_shipping_address(),
                    'address_2' => WC()->customer->get_shipping_address_2()
                )
            );
        }    
        
        return $packages;
    }
    • This reply was modified 8 months, 4 weeks ago by braehler.
    Plugin Support Con Schneider

    (@conschneider)

    Automattic Happiness Engineer

    Hi @tristanaz,

    Did the reply above work for you?

    Kind regards,

    Sorry, but that does not work for me.

    I try to explain it differently.

    Customers can buy free from a value of $ 30.

    The exception is the special product for $ 15. Here the buyer must buy at least 4 pieces, so that these are free shipping.

    But there is a special feature: If the customer buys from the special product only 1 piece and additionally for another $ 30 other products, so a total of $ 45, then the order is also free shipping.

    There would have to be a possibility to check if the special product is in the shopping cart, the quantity is 1, and other products in the shopping cart totaling $ 30 ($ 45 together with the special product).

    Plugin Support Hari Shanker R

    (@harishanker)

    Automattic Happiness Engineer

    Hi @tristanaz

    The exception is the special product for $ 15. Here the buyer must buy at least 4 pieces, so that these are free shipping.
    But there is a special feature: If the customer buys from the special product only 1 piece and additionally for another $ 30 other products, so a total of $ 45, then the order is also free shipping.
    There would have to be a possibility to check if the special product is in the shopping cart, the quantity is 1, and other products in the shopping cart totaling $ 30 ($ 45 together with the special product).

    That’s a great question!

    I can tell you that it would be difficult to achieve this feature by default. With that said, I can recommend our official Table Rate Shipping extension, which will help you achieve this requirement off-the-shelf.

    It allows you to set such complex shipping costs, looking for conditions whether the cart total is <30 or whether the product is in cart.

    You can learn more about this over here: http://docs.woocommerce.com/document/table-rate-shipping/

    Feel free to ask us any pre-sales questions by following this link: https://woocommerce.com/my-account/create-a-ticket/

    Plugin Support Jesse Pearson

    (@jessepearson)

    Automattic Happiness Engineer

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

    I have a question for you. I want to accomplish the same thing except different logic.

    @myiah Is the question for me? 🙂

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Free shipping dependency on item and price problem’ is closed to new replies.