FREE SHIPPING mod based on order total.
Here's a quick and easy mod to let you give free shipping based on an order subtotal. First you'll need to add a variable to the xcart_config table of your xcart database. Using something like PHPMyadmin, take one of the existing Shipping config fields and just duplicate it. Change the values to be:
name: free_shipping_threshold comment: FREE SHIPPING THRESHOLD Give free shipping on orders with subtotal greater than this value. Set to 0 to disable value: 0 category: Shipping orderby: 4 type: text defvalue: 0 Save the new row to your database. That will give you a nice config option in your shipping admin menu, so you can easily change the order subtotal required to get free shipping discounts. Now open your include/func.php file and modify your func_caluculate_single() function. Search for the code that handle the free shipping coupon... Code:
if (!empty($coupon_type) and $coupon_type == "free_ship") { and add this bit of code directly below that code Code:
//added by brett to offer free shipping if the free shipping threshold has been met Now to use this mod, just log in as an admin and open your general settings page and select "shipping options" from the pulldown menu. Then find the new value you set up for the free_shipping_threshold and enter a value greater than 0 to activate the module. This will give free shipping for orders that have subtotals greater than the threshold you set. It also sets the customer's discount equal to whatever your shipping cost would have been and displays it the same way a free shipping coupon would be displayed. This has the added benefit that it should save the discount value in your store's order stats, just like all the other discounts (although no coupon code will ever be set). This code is only tested on v3.5.7, but should work with most of the 3.5.x branch. I have no idea what the 4.0 branch looks like, so I can't help anyone with that version yet. Also, i just realized that this code will interfere if a user tries to use a discount coupon. A fix for that would probably be to just change the above code from Code:
//disregard this part of the code, just comment out these lines Code:
//disregard this part of the post...just comment out the $coupon_discount line Since coupons have theoretically been applied already, this will just add the shipping charge to whatever the existing discount value is. ENJOY! UPDATE: I have modified the code above by commenting out the $coupon_discount lines because it interfered with the normal coupon discount display in order receipts. Otherwise, the code is fine. |
An even better version
Okay, if you want this free shipping to work only with the shipping method you specify, here's what to do. Follow the previous post instructions for editing your database. Then add another new field to the database the same way, but this time call it "free_shipping_allowed_method" and enter in the same values, but give it an appropriate description. Then use the following code in your func_caluculate_single() function instead of adding the code snippet in my last post:
Code:
//added by brett to offer free shipping if the free shipping threshold has been met UPDATE: I have modified the code above by commenting out the $coupon_discount lines because it interfered with the normal coupon discount display in order receipts. Otherwise, the code is fine. |
another fix
I'm adding some more fixes as I get a better idea of how the coupon code works. It seems that after you make the above modifications, you cannot enter a coupon code once the free shipping discount has kicked in. To remedy that, I had to modify the skindir/customer/main/cart.tpl file. The very last part of the template file is the only part we need to change. So change this:
Code:
{if $cart.coupon_discount Code:
{*if $cart.coupon_discount I just commented out the IF statement that encloses the coupon entry form. That keep the coupon entry form from being hidden once there is already a discount being used (which happens when the free shipping discount is automatically applied). I'm not sure why the templates were designed to hide the coupon form in the first place. If you enter multiple discount coupons, it only figures in the last one entered, so there doesn't seem to be any danger of customers entering the same code multiple times and getting additional discounts. The only problem I see remaining is that if you use an actual "free shipping" coupon type, it will kill the automatic free shipping discount and hides the discount display in your cart total, but I guess that's by design. It would be nicer if free shipping coupons displayed the free shipping as a discount the same way the other coupons do. Maybe I'll fix that in a later post. |
Final fix for this mod...
After some testing, I've determined that it's not a good idea to add the free shipping cost to the discounts because it screws up the order receipts and makes it look like the customer is being overcharged because it shows up as a discount in the receipt, but the order total doesn't reflect the discount because we're simply not charging shipping, so nothing needs to be subtracted when it isn't added in the first place. That sounds confusing, so I've modified my post above and commented out the addition of the shipping charges to the discounts, so free shipping will no longer show as a discount. Aside from that it seems to work great for me.
|
Great mod. For what version please?
|
Version info
This mod is working on X-Cart Pro 3.5.7, but would probably work for most of the 3.5.x branch. Not sure about earlier versions though.
|
Does anyone know if this "free shipping mod based on order total" mod will work with X-Cart version 4.0.3?
|
I don't think it will work exactly as posted, but if you can find the right functions in the new version, you could probably apply this mod pretty easily with minor tweaking. Since I haven't looked at the 4.x code yet, I couldn't tell you where to look.
|
you are a genious
Thank you... Thank you... Thank you... Thank you... Thank you... Thank you... Thank you... Thank you... Thank you... Thank you... Thank you... Thank you... Thank you... Thank you... Thank you... Thank you... Thank you... Thank you...
|
Seems to have problem working in 3.4.14. Anyone with success for this mod under 3.4.xx ?
Seems to be conflicting with real-time UPS rates. Philippe |
All times are GMT -8. The time now is 09:59 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.