• Resolved clunky

    (@clunky)


    Hi Jeroen
    Been using this plugin for a couple of years now and am very impressed.
    My client has recently added a bunch of virtual products to his store and we have come across an issue.
    When the virtual product is added to the cart along with a physical product, the cart totals include the virtual product cost, and goes towards the free shipping value.

    Therefore the customer gets his physical product free shipping.

    Is there a condition where the category of the virtual products or each virtual product can be deducted from the cart subtotal, to prevent free shipping target being met?
    i.e. if the virtual product is in the cart, remove its value from the subtotal and therefore the order will not be free shipping?
    If I add a condition like “category”-> “not equal to”-> “catX” will the value be removed or the whole condition be ignored irrespective of the cart totals so the free shipping will never fire?

    Cheers in advance ??

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

Viewing 13 replies - 1 through 13 (of 13 total)
  • Thread Starter clunky

    (@clunky)

    Hi Jeroen
    Does this link that I found in an older support post do what I’m really after?

    Plugin Author Jeroen Sormani

    (@sormano)

    Hi,

    The snippet does change things to exclude virtual products., but its quite old – not sure if it still works without giving any PHP notices (won’t give errors as far as I can see).

    Also, the snippet is also meant for the Advanced Shipping plugin, not this one, so if you want to give a whirl it would have to be modified first.

    I’d recommend creating a custom condition though – this is a bit cleaner as it adds a new condition vs changing the matching method of an existing one (which may cause confusion at some point as its not longer the actual ‘Subtotal’ its matching against).

    Thread Starter clunky

    (@clunky)

    Hi Jeroen
    You say “I’d recommend creating a custom condition though”…
    I have currently 5 free shipping rates set up for different user roles, this custom condition would need to relate to each one of these.
    Creating a new one which encompasses these would seem to be rather a lot of work.
    As it doesn’t seem possible that the virtual product cost can be deducted from the subtotal to allow free shipping with mixed products in the cart….
    Would adding a condition say “Category”-“not equal to”-“virtual category”, actually prevent the customer buying the virtual product along with a physical one, therefore not benefiting from the free shipping?
    i.e. will it just ignore the virtual product?
    Rather confused now ??
    Cheers

    Plugin Author Jeroen Sormani

    (@sormano)

    Hi,

    Shouldn’t be a lot of work to change 5 shipping rate conditions from ‘Subtotal’ to a new custom condition, would it?

    Adding such category condition would prevent the free shipping rate from showing up when a virtual product is present in the cart. It will not just ignore the virtual product. Whether it’ll prevent the customer from purchasing depends if you have other shipping options available for them to choose from.

    Cheers,
    Jeroen

    Thread Starter clunky

    (@clunky)

    Hi Jeroen
    Much appreciate you taking the time to go through this with me.
    I have played about with one of my free shipping rates to see what this would do.
    I can confirm that by adding a condition “category”-“not equal to”-“cat x” allows the user to add the virtual products along with physical products to the cart, but the subtotals don’t ever trigger the free shipping at all.

    It would be really great if your plugin had a tickbox to “ignore virtual products”.

    Be really cool if there was a snippet which did this, but after trawling the web it doesn’t appear to look good.
    In fact I have only found one other discussion; Exclude WooCommerce virtual product from counting towards free delivery, but it didn’t have a solution for me as its plugin specific. https://stackoverflow.com/questions/47781984/exclude-woocommerce-virtual-product-from-counting-towards-free-delivery

    Cheers

    Plugin Author Jeroen Sormani

    (@sormano)

    Hi,

    Thats because the ‘Category’ condition doesn’t allow for other products (from other categories) to be present in the cart.

    The plugin won’t have such checkbox – I’d be able to easily add 50 checkboxes if I features were implemented that only the .1% uses ?? I need to be careful about features added to prevent clutter and keep it a clean&stable plugin.

    The customizations that the plugin and WordPress itself allow through hooks/filters are what are perfect for those exact cases ?? (as per the custom “Subtotal minus virtual” condition suggestion)

    If you need help creating such custom condition I may be able to create it for you – just reach out through my site if wanted.

    Cheers,
    Jeroen

    Thread Starter clunky

    (@clunky)

    Hi Jeroen
    I will speak to my client about this.
    Just wanted to know, if the default woo setup, without your plugin, would add virtual costs to the cart?
    Cheers

    Plugin Author Jeroen Sormani

    (@sormano)

    Yes, as far I know its always based on the cart subtotal, also with Woo Core.

    Thread Starter clunky

    (@clunky)

    Hi Jeroen
    I have another test woocommerce setup running, I have added a virtual product and a physical product to the cart.
    There is a flat rate and free shipping level and can confirm that this too adds the virtual product cost to the shipping. (when you add more virtuals to the cart to attain the free shipping level, it kicks in)
    Just curious…
    How is it that it doesn’t exclude the virtual cost?
    It seems that the virtual product is being ignored, is this a woo issue that no one has noticed?
    I have searched the web but can’t find an answer.
    Cheers

    Thread Starter clunky

    (@clunky)

    Hi Jeroen
    How would I adjust this to work with your plugin so that it could be used with all my AFS options?

    add_filter('woocommerce_package_rates', 'custom_free_shipping_option', 10, 2 );
    function custom_free_shipping_option($rates, $package){
    
        // HERE set the "minimum order amount" for free shipping
        $limit = 500;
    
        $free_total = 0;
    
        // Get the cart content total excluding virtual products
        foreach( WC()->cart->get_cart() as $cart_item )
            if( ! $cart_item['data']->is_virtual( ) )
                $free_total += $cart_item['line_total'];
    
        // Disabling free shipping method based on specific cart content total
        if( $free_total < $limit )
            foreach ( $rates as $rate_key => $rate )
                if( 'free_shipping' == $rate->method_id )
                    unset( $rates[ $rate_key ] );
    
        return $rates;
    }

    Cheers

    Plugin Author Jeroen Sormani

    (@sormano)

    Hi,

    I don’t believe this is an bug or anything – the virtual products are ‘ignored’ in a sense that they don’t show for the shipping package.
    The ‘Minimum spend amount’ is simply based on the cart (sub)total in my plugin and Woo – which does include all (including virtual) products.

    I’m afraid I won’t be able to assist with custom customizations like that within what I offer for support. I’d recommend to have your webdeveloper assist with that.

    Cheers,
    Jeroen

    Thread Starter clunky

    (@clunky)

    Hi Jeroen
    I think this is the bit that I am confused with…
    Woo seems to be adding the total cart cost and using it to calculate shipping.
    I thought that it would ignore the virtual and therefore not count towards the shipping costs, but it doesn’t.
    I understand the minimum spend bit but the shipping bit is causing me a problem.
    If I create a virtual product (which is set in woo to not include any shipping), why does it add shipping in the cart if there is another physical product in there?
    A customer did just this recently and ended up with free shipping for a physical item that should have cost him an extra £10?? (because the virtual item took him over the free shipping threshold).
    Confused to say the least.

    Cheers

    Plugin Author Jeroen Sormani

    (@sormano)

    Hi,

    It simply takes the cart amount, which includes virtual products. Nothing more, nothing less.

    As long as there’s a shippable product in the cart, Woo requires a shipping method, and shipping methods calculate based on cart amount.

    Cheers,
    Jeroen

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Virtual products’ is closed to new replies.