Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Free Shipping if over $X, not with a coupon

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #11  
Old 10-05-2003, 07:04 PM
 
oasiswc oasiswc is offline
 

Newbie
  
Join Date: Jul 2003
Posts: 8
 

Default

Quote:
Originally Posted by cloud9
By the way, has anyone ever implemented 'Free Shipping if over a certain total' thru the code? I did see a thread here where someone was able to use shan's method to get this thru the admin panel, but they had a flat shipping rate otherwise, and I don't think that is too common.


Free Shipping Boosts Net Shopping...
http://www.wired.com/news/ebiz/0,1272,57098,00.html


Please X-Cart this would be so nice for 3.3.4!

http://forum.x-cart.com/viewtopic.php?p=27185#27185
Reply With Quote
  #12  
Old 01-22-2004, 02:13 PM
 
spingary spingary is offline
 

Advanced Member
  
Join Date: Apr 2003
Posts: 51
 

Default TINY mod to do Free Shipping for orders over $X w/real time

I also needed to do a "Free Shipping for orders over $X" while keeping the other real-time methods working, and without using flat rates. I've come up with a method that only requires adding ONE line to X_cart's php files. If anyone's seen any of my other posts, I really hate hacking at the x_cart code due to upgrade issues, so I made this as painless as possible.

The method is to add our own real-time shipping method.

First, let's add our new shipping method into the database table xcart_shipping. I call it "Free Shipping - Orders Over $200". The code I use is "FREEOVERX", subcode "201" - an arbitrary number I pick that is far enough away from the predefined X_Cart shipping methods. I don't set a weight limit, but you might want to do that just in case:

Code:
INSERT INTO xcart_shipping VALUES (103, 'Free Shipping - Orders Over $200', '', 'L', 'FREEOVERX', '201', 5, 'Y', '', '0.00', 0);

Now, here is the only hack needed -- in shipping/myshipper.php:

Code:
After this line: include "../shipping/mod_DHL.php"; Add this line: include "../shipping/mod_CUSTOM.php";

"mod_CUSTOM.php" is where I put my custom shipping methods. Right now, I only have one, the "Free Shipping Over $X". Here's the code for mod_CUSTOM.php:

Code:
<? // Edit the amount valid for free shipping here: $freeOverAmount=200; if ( !defined('XCART_SESSION_START') ) { header("Location: ../"); die("Access denied"); } global $product; // Make sure this shipping method is available foreach ($allowed_shipping_methods as $key=>$value) if ($value["code"] == "FREEOVERX") $FREEOVERX_FOUND = true; if ($FREEOVERX_FOUND) { $row = func_query_first("SELECT shippingid, subcode FROM $sql_tbl[shipping] WHERE code='FREEOVERX' AND active='Y'"); if ($row && ($product["subtotal"] >= $freeOverAmount)) { $rate = 0; $intershipper_rates[] = array("methodid" => $row['subcode'], "rate" => $rate); } } ?>

As you can see, you can pretty much do anything you want in this code to calculate shipping rates.

Let me know if you have trouble getting it to work. Have fun!

Oh, I forgot to mention, I am using version 3.5.2.
Reply With Quote
  #13  
Old 01-22-2004, 03:32 PM
  leon's Avatar 
leon leon is offline
 

X-Wizard
  
Join Date: Mar 2003
Location: Costa Rica
Posts: 1,213
 

Default

Very Nice for the Custom Mods section.
__________________
It doesn\'t matter what is done... it is how it is done.
=============================
XCart Version: 3.5.3 -> Dmcigars.com
XCart Version: 4.1.3....
Reply With Quote
  #14  
Old 01-22-2004, 06:34 PM
 
jordan0 jordan0 is offline
 

Advanced Member
  
Join Date: Oct 2003
Location: San Francisco, CA
Posts: 77
 

Default thanks

SpinGary,

Your solution to the free shipping problem seems to be exactly what I have been looking for, but I am having trouble getting it to work. I made the modification to myshipper.php, added the row to the xcart_shipping table, and created mod_CUSTOM.php but "Free Shipping Б─⌠ Orders over $99" does not appear as a choice during checkout. I made sure that the "Free Shipping..." method is activated in the "Shipping Methods" Admin area, and still no luck. Is something different because I use 3.4.8?

Thanks for your help,
Jordan
__________________
Jordan Sitkin
http://www.kitkraft.biz
X-Cart 4.0.18 [unix]
Reply With Quote
  #15  
Old 01-23-2004, 08:19 AM
 
spingary spingary is offline
 

Advanced Member
  
Join Date: Apr 2003
Posts: 51
 

Default

Jordan,

I haven't tried the code with 3.4.x yet. I took a quick look, and you can try this as a debugging step. Backup up your mod_CUSTOM.php file, and replace it with just this one line:

Code:
$intershipper_rates[] = array("methodid" => 201, "rate" => 10);

Replace "201" with whatever subcode you used.

This should give you a shipping option while in your cart for the shipping method you added at $10. Let me know what happens.

Some other quick notes:
Make sure that your insert SQL statement went into the table correctly.
Make sure your products have weights (just in case).
Make sure you are shipping domestically, since the SQL set the method for national only - if not, change it.

Gary
Reply With Quote
  #16  
Old 01-24-2004, 06:53 AM
 
joelrhome joelrhome is offline
 

Advanced Member
  
Join Date: Dec 2003
Posts: 89
 

Default Having trouble. Can someone help me??

I am trying to use this mod, but I am having trouble with the mysql table part. I am not sure exactly what needs to go into the following:

1. "Field"
2. "Type"
3. "Length/Values*"
4. "Attributes"
5. "Null"
6. "Default**"
7. "Extra"

If anyone could let me know, thanks...

Also, there was something about.... "The method is to add our own real-time shipping method".... - If I am using UPS real time calculation, will this work or not. please excuse my ignorance...

Thanks
Reply With Quote
  #17  
Old 01-24-2004, 08:36 AM
 
spingary spingary is offline
 

Advanced Member
  
Join Date: Apr 2003
Posts: 51
 

Default

Joelrhome,

No no-- the MySQL part is not to add a field to the xcart_shipping table. All we are doing is adding a row to that table. You can go to the "Patch/Upgrade" area, under the Apply SQL Patch, type in this in the query(ies) box:

Code:
INSERT INTO xcart_shipping VALUES (103, 'Free Shipping - Orders Over $200', '', 'L', 'FREEOVERX', '201', 5, 'Y', '', '0.00', 0);

As for your question regarding real-time shipping, yes the other real-time shipping methods will continue to work fine. This method is to add another real-time shipping method to be available to your customers in their cart if their order amount is over $X.

Hope this helps,
Gary
Reply With Quote
  #18  
Old 01-24-2004, 12:27 PM
 
joelrhome joelrhome is offline
 

Advanced Member
  
Join Date: Dec 2003
Posts: 89
 

Default still learning the x cart

Thanks, That did it.
Reply With Quote
  #19  
Old 01-26-2004, 07:48 PM
 
joelrhome joelrhome is offline
 

Advanced Member
  
Join Date: Dec 2003
Posts: 89
 

Default well, maybe not

Ok. I have tried the mod. I guess I must be misunderstanding how this is supposed to work. I have set my own shipping methods based on weight ( like the way UPS does it - in fact, I am using the info from their website to decide how much to charge ). The desired result that I am looking for, is that when The customer checks out and the order is under $300, I dont want them to see anything but the "paid methods that i have defined... When their order total is $300 or over, The "free shipping" method either appears as a choice, (either in place of ground or in addition to) or no shipping methods at all... and the shipping is $0.00 . I hope this isnt confusing to anyone who wishes to read this. I am a newbie... I have been working on this for the past 4 hours. i have tried every variable that i know. I have followed every step mentioned and each time
if the order is under $300, the "free" method is visible. this isnt good. what have done wrong. please help... thanks.
Reply With Quote
  #20  
Old 01-28-2004, 03:26 PM
 
spingary spingary is offline
 

Advanced Member
  
Join Date: Apr 2003
Posts: 51
 

Default

Update! Turns out that the global product var that I used to get the cart subtotal is not calculated first if the user updates the quantity. This script is not accurate if the user changes quantity and hits "update". The user will have to refresh the cart one more time to get it to work properly.

So, I adjusted the code to recalculate on its own. Here's the new code:

Code:
<? // Custom shipping methods // // Edit the amount valid for free shipping below. $freeOverAmount=200; if ( !defined('XCART_SESSION_START') ) { header("Location: ../"); die("Access denied"); } global $products, $cart, $userinfo, $current_area, $login; // Make sure this shipping method is available foreach ($allowed_shipping_methods as $key=>$value) if ($value["code"] == "FREEOVERX") $FREEOVERX_FOUND = true; if ($FREEOVERX_FOUND) { $tempcart = func_calculate($cart, $products, $login, $current_area); $row = func_query_first("SELECT shippingid, subcode FROM $sql_tbl[shipping] WHERE code='FREEOVERX' AND active='Y'"); if ($row && ($tempcart["subtotal"]>= $freeOverAmount)) { $rate = 0; $intershipper_rates[] = array("methodid" => $row['subcode'], "rate" => $rate); } } // Use if national shipping is not working right: // if ($userinfo["s_country"]=="US" && is_numeric($zp3)) // ... ?>

Have fun!
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 03:03 PM.

   

 
X-Cart forums © 2001-2020