Expresso Store - Add free shipping when an order's subtotal is over an certain amount?

14

5

Is it possible to disable the shipping price if the order total is over a certain amount? I was thinking maybe a conditional in the checkout template but I havent gotten it to work. Does anyone have any ideas or could point me in the right direction? Thanks!

ee_dogg

Posted 2012-11-21T18:15:52.897

Reputation: 102

Answers

10

You didn't mention in the question you were trying to do this in addition to USPS.

The answer @MediaGirl gave would be correct if you were using the Default Shipping Plugin, as you can simply create extra rules to apply free shipping to orders over $50 (or whatever).

If you want to do this in combination with USPS rates, you will need to make a simple PHP shipping plugin which extends the USPS plugin and adds your custom rule.

For example, create a new file third_party/store/libraries/store_shipping/store_shipping_usps_with_max.php, with the following contents:

require_once dirname(__FILE__).'/store_shipping_usps.php';
class Store_shipping_usps_with_max extends Store_shipping_usps
{
    public function calculate_shipping($order)
    {
        // free shipping for orders over $50
        if ($order['order_shipping_subtotal_val'] >= 50)
        {
            return 0;
        }

        return parent::calculate_shipping($order);
    }
}

You should then be able to install and configure this new Store_shipping_usps_with_max plugin the same way you did the regular USPS plugin, but it will have the extra feature of free shipping on orders over $50


Another option if you don't want to go the PHP route, would be to simply add some conditionals to your checkout template, to automatically submit hidden fields for the free shipping method:

{if order_total_val > 50}
    <input type="hidden" name="shipping_method" value="id_of_free_shipping_method" />
{if:else}
    <input type="hidden" name="shipping_method" value="id_of_usps_shipping_method" />
{/if}

Adrian Macneil

Posted 2012-11-21T18:15:52.897

Reputation: 12 083

I'm trying to combine that into UPS and FedEx shipping methods, but how I can get IDs of both of those? – JackTheKnife – 2014-03-07T17:39:55.923

That depends. In Store v2 the UPS and FedEx methods generate multiple shipping options, so they have multiple 'IDs'. You would need to output the {field:shipping_method} dropdown to see what the IDs are. – Adrian Macneil – 2014-03-08T08:53:28.330

First - there is a problem with Store v2 and UPS method (reported separately) to get IDs at the beginning of the checkout. Second - as you mentioned UPS method generates multiple shipping options and in that case I don't know which ID was chosen. Also IDs look like Store_ups_ext:XX so I'm not sure if I need to post whole part as a value. Personally I prefer to go with PHP version, but presented above is not working with current UPS add-on. – JackTheKnife – 2014-03-12T13:50:17.973

This answer was written quite a while ago for Store 1.x so probably best to start fresh. See http://expressionengine.stackexchange.com/a/20202/150 for a way to achieve this in Store 2.

– Adrian Macneil – 2014-03-12T21:53:49.207

10

You don't need a conditional...

Set up a shipping method called Free Shipping using the Default Shipping Plugin.

Then set up the rules for this new shipping method... you'll want to set Minimum Order Total and Maximum Order Total specific to your use case. Then set your Base Rate charge to 0. Should do the trick.

Info on Shipping Methods is here in the docs: https://exp-resso.com/docs/store/settings/shipping_methods.html

Anna_MediaGirl

Posted 2012-11-21T18:15:52.897

Reputation: 12 118

Its still giving me two options for shipping: Free Shipping free and usps. – ee_dogg – 2012-11-22T00:35:39.003

Are you able to set order total minimum and maximum for the USPS method? – Anna_MediaGirl – 2012-11-22T16:31:14.083

No, I'm not able to set a total minimum and maximum for the USPS method. This is bizzare. Before I posted this I was using 1.6.0 and I Just updated to store 1.6.1 still the same problem. It will show the USPS Shipping and Free Shipping options when under $100.00 – ee_dogg – 2012-11-23T18:50:56.247

Adrian provided two options for you in his answer. – Anna_MediaGirl – 2012-11-23T20:46:26.493

2That worked! Adrian is a beast! – ee_dogg – 2012-11-23T22:33:22.260