| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
FREE SHIPPING mod based on order total. | ||||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||||
|
|||||||||
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:
and add this bit of code directly below that code Code:
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:
Code:
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.
__________________
www.brettbrewer.com Getting back into x-cart dev after a long hiatus. Modded lots of x-carts from version 3.1.x to 4.1.x. Developer of ImageScaler mod, Pre-login per user coupon mod, Wordpress feed mod, DigitalSubscriptions mod, Phonetic bulk download keys addon for DownloadExpander mod, Serial Number Generator for ESD products, Custom CMS/LMS integrations, external products mod, and more. |
|||||||||
#2
|
|||||||||
|
|||||||||
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:
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.
__________________
www.brettbrewer.com Getting back into x-cart dev after a long hiatus. Modded lots of x-carts from version 3.1.x to 4.1.x. Developer of ImageScaler mod, Pre-login per user coupon mod, Wordpress feed mod, DigitalSubscriptions mod, Phonetic bulk download keys addon for DownloadExpander mod, Serial Number Generator for ESD products, Custom CMS/LMS integrations, external products mod, and more. |
|||||||||
#3
|
|||||||||
|
|||||||||
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:
Code:
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.
__________________
www.brettbrewer.com Getting back into x-cart dev after a long hiatus. Modded lots of x-carts from version 3.1.x to 4.1.x. Developer of ImageScaler mod, Pre-login per user coupon mod, Wordpress feed mod, DigitalSubscriptions mod, Phonetic bulk download keys addon for DownloadExpander mod, Serial Number Generator for ESD products, Custom CMS/LMS integrations, external products mod, and more. |
|||||||||
#4
|
|||||||||
|
|||||||||
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.
__________________
www.brettbrewer.com Getting back into x-cart dev after a long hiatus. Modded lots of x-carts from version 3.1.x to 4.1.x. Developer of ImageScaler mod, Pre-login per user coupon mod, Wordpress feed mod, DigitalSubscriptions mod, Phonetic bulk download keys addon for DownloadExpander mod, Serial Number Generator for ESD products, Custom CMS/LMS integrations, external products mod, and more. |
|||||||||
#5
|
|||||||||
|
|||||||||
Great mod. For what version please?
|
|||||||||
#6
|
|||||||||
|
|||||||||
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.
__________________
www.brettbrewer.com Getting back into x-cart dev after a long hiatus. Modded lots of x-carts from version 3.1.x to 4.1.x. Developer of ImageScaler mod, Pre-login per user coupon mod, Wordpress feed mod, DigitalSubscriptions mod, Phonetic bulk download keys addon for DownloadExpander mod, Serial Number Generator for ESD products, Custom CMS/LMS integrations, external products mod, and more. |
|||||||||
#7
|
|||||||
|
|||||||
Does anyone know if this "free shipping mod based on order total" mod will work with X-Cart version 4.0.3?
|
|||||||
#8
|
|||||||||
|
|||||||||
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.
__________________
www.brettbrewer.com Getting back into x-cart dev after a long hiatus. Modded lots of x-carts from version 3.1.x to 4.1.x. Developer of ImageScaler mod, Pre-login per user coupon mod, Wordpress feed mod, DigitalSubscriptions mod, Phonetic bulk download keys addon for DownloadExpander mod, Serial Number Generator for ESD products, Custom CMS/LMS integrations, external products mod, and more. |
|||||||||
#9
|
|||||||
|
|||||||
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...
__________________
Long time fan, not running any sites at the moment... |
|||||||
#10
|
|||||||
|
|||||||
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
__________________
X-Cart 4.4.3 - Happily EWD Hosted - |
|||||||
|
|||
X-Cart forums © 2001-2020
|