Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I would like to know if it is possible to enable free shipping with Woo Commerce only if certain items (or items of certain categories / shipping classes) are included in the cart.

The Free Shipping option only activates on the basis of cart value or via a coupon code so I investigated Flat Rate shipping and discovered that it prioritises the most expensive shipping class over the cheaper ones. This means the free shipping class I created never overrides the default charge.

I understand the logic behind this but it's the opposite of what I need as the idea is to incentivise purchases of higher profit margin products by eliminating delivery charges when they're included in an order.

I don't know if what I am trying to achieve is simply not possible within Woo Commerce. A coupon that only applies to certain products / categories seems to be the closest I can get but I'd rather not force users to enter a code at checkout.

Does anybody know if there any simpler ways to give users who purchase certain products free shipping?

share|improve this question

closed as off-topic by toscho Jul 4 at 11:19

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

6 Answers 6

up vote 1 down vote accepted

Perhaps this doesn't fully answer your question, but the table rate shipping plugin does give you the option to set a priority for a particular rate. Furthermore, this discussion gives a lot of hints as to where you could look for solutions

share|improve this answer
    
Thanks. Looking at the documentation for Table Rate Shipping it appears that it will do what I need it to. If my employer goes for the licence I'll update on whether it's of use. –  James O'Neill Mar 15 '13 at 11:00
    
Please don't post links to outside resources. Rather summon them here and use the link on top of it. If the link goes, the answer is useless and we're having a hard fight preventing link rot. -1 –  kaiser Sep 6 '13 at 20:48

Does anybody know if there any simpler ways to give users who purchase certain products free shipping?

Actually, when creating a product you can just mark it as a Virtual product right within the product editor and that will exclude shipping completely for that item.

share|improve this answer
1  
This works for simple products, but not for other types of products -- variable, for example. Nice try though. This will probably work for some people. –  Alexander Lee Williams Sep 6 '13 at 20:45
    
Why doesn't this work for variable products? You can mark each variation as virtual. –  BFTrick Sep 17 '13 at 19:37
    
I agree @BFTrick –  Nathan Sep 18 '13 at 18:09

Here's a snippet colleted from some Gists out of a GitHub issue discussion linked by @Ewout in another answer. I added a var_dump(), so you can uncomment and check what exactly you want to remove.

$available_methods is an array of:

$available_methods as $method_id => $method

Compare against $method_id if you need more specific checks.

// Hide standard shipping option when free shipping is available
add_filter( 'woocommerce_available_shipping_methods', 'wpse90835_hide_standard_shipping_when_free_is_available' );
/**
 *  Hide Standard Shipping option when free shipping is available
 * 
 * @param array $available_methods
 */
function wpse90835_hide_standard_shipping_when_free_is_available( $available_methods )
{
    // Developers!: Dump this to see what you can unset
    # var_dump( $available_methods );

    // remove standard shipping option
    if ( 
        isset( $available_methods['free_shipping'] ) 
        AND isset( $available_methods['flat_rate'] )
    )
        unset( $available_methods['flat_rate'] );


    return $available_methods;
}
share|improve this answer

Based on kaiser's code (above) I have created the following code:

    /**
 *  Hide free shipping option when Standard Shipping is available
 * 
 * @param array $available_methods
 */
function mwe_hide_free_shipping_when_standard_shipping_is_available($available_methods) {

    // remove standard shipping option
    if (isset($available_methods['free_shipping']) AND isset( $available_methods['flat_rate'])) {
        unset($available_methods['free_shipping']);
    }

    return $available_methods;
}
add_filter('woocommerce_available_shipping_methods', 'mwe_hide_free_shipping_when_standard_shipping_is_available');

And in turns of setting up WooCommerce, I have Free Shipping and Flat Rate both enabled in the Woo Shipping Options. Then I just set up a Shipping Class, specify it's cost (e.g., £7.95) in the Flat Rate options page, and then just add that shipping class to the products I want to charge £7.95 p&p for.

share|improve this answer

I've created a WooCommerce plugin which allows users to configure advanced settings for free shipping. In the plugin it is possible to select certain products for free shipping.

You can find the plugin free on wordpress.org called WooCommerce Advanced Free Shipping

Hope this helps.

share|improve this answer

The "virtual" option will remove all shipping costs, but it also deletes the option to ship to a different address than the customer's billing address. This isn't an issue if the customer buys other, non virtual products as well, but is if it's the only thing they buy.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.