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
  #61  
Old 11-22-2005, 12:12 PM
  HWT's Avatar 
HWT HWT is offline
 

eXpert
  
Join Date: Jan 2005
Location: Massachusetts, USA
Posts: 392
 

Default

Thanks bugaminute!

I've finally had time to get down to work on this, and whenever I upload myshipper.php, I get:

// Edit the file shipping/myshipper.php and under this line // include $xcart_dir."/shipping/mod_ARB.php"; (NPL used myshipper.php instead) // ADD THIS LINE to include this file: // include $xcart_dir."/shipping/mod_CUSTOM.php" // // You can also include other custom shipping files here so that myshipper.php is left alone. // // Edit the amount valid for free shipping below. $freeOverAmount=99; // That's all! 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); if (($userinfo["s_country"] == $config["General"]["default_country"]) && (($userinfo["s_state"] <> "AK") && ($userinfo["s_state"] <> "HI"))) $dest = "L"; else $dest = "I"; $row = func_query_first("SELECT shippingid, subcode FROM $sql_tbl[shipping] WHERE code='FREEOVERX' AND active='Y' and destination = '$dest'"); if ($row && ($tempcart["subtotal"] >= $freeOverAmount)) { $rate = 0; $intershipper_rates[] = array("methodid" => $row['subcode'], "rate" => $rate); } } ?>

displayed at the top of my cart page! Proof positive that I don't know what the @#*($&^ I'm doing. Anybody have the solution for getting it to do, and not display mod_CUSTOM.php?
__________________
x-cart 4.0.13 and 4.1.7 and 4.1.10
Reply With Quote
  #62  
Old 12-01-2005, 07:09 PM
 
bugaminute bugaminute is offline
 

Senior Member
  
Join Date: Oct 2004
Posts: 126
 

Default

Sorry HWT, I was away for a while...what that means is that you have a bug in your "myshipper/php" somewhere

here is my "myshipper.php' if it helps

Code:
\*****************************************************************************/ # # $Id: myshipper.php,v 1.24.2.6 2005/05/16 06:35:07 mclap Exp $ # if ( !defined('XCART_SESSION_START') ) { header("Location: ../"); die("Access denied"); } # # This function calculates shipping rates from my own shipper module # function func_shipper ($weight, $userinfo, $debug="N", $cart=false) { global $allowed_shipping_methods,$intershipper_rates; global $shipping_calc_service, $intershipper_error; global $sql_tbl; global $config; global $active_modules; global $xcart_dir; global $current_carrier; if (empty($userinfo) && ($config["General"]["apply_default_country"]=="Y" || $debug=="Y")) { $userinfo["s_country"] = $config["General"]["default_country"]; $userinfo["s_state"] = $config["General"]["default_state"]; $userinfo["s_zipcode"] = $config["General"]["default_zipcode"]; $userinfo["s_city"] = $config["General"]["default_city"]; } elseif (empty($userinfo)) return array(); $allowed_shipping_methods = func_query ("SELECT * FROM $sql_tbl[shipping] WHERE active='Y'"); $intershipper_rates = array (); if (!empty($active_modules["UPS_OnLine_Tools"]) and $current_carrier == "UPS") $ups_rates_only = true; else $ups_rates_only = false; if (!$ups_rates_only) { include $xcart_dir."/shipping/mod_FEDEX.php"; # Next file is new, created by NPL for Free Shipping over X include $xcart_dir."/shipping/mod_custom.php"; } # # Shipping modules depend on XML parser (EXPAT extension) # if( test_expat() != "" ) { if ($ups_rates_only) include $xcart_dir."/shipping/mod_UPS.php"; else { include $xcart_dir."/shipping/mod_USPS.php"; include $xcart_dir."/shipping/mod_CPC.php"; include $xcart_dir."/shipping/mod_ARB.php"; } } if($debug=="Y") { print("<H1>Shipping Rates</H1>"); foreach($intershipper_rates as $rate) { $method=func_query_first("select shipping from $sql_tbl[shipping] where subcode='$rate[methodid]'"); print(" ".str_replace("##SM##","<sup>SM</sup>",str_replace("##R##","®",$method["shipping"]))." (\$$rate[rate])"); } } return $intershipper_rates; } ?>
__________________
Xcart Version Gold 4.7.12
Prod Sys- Debian 9 Stretch
Prod Sys - Apache/2.4.25 (Debian)
CDSEO Pro- 2.2
Mysql Community Edition 5.7.32
PHP 7.3
Reply With Quote
  #63  
Old 12-01-2005, 07:33 PM
  shipmerchant's Avatar 
shipmerchant shipmerchant is offline
 

eXpert
  
Join Date: Mar 2005
Posts: 361
 

Default Can this enabled and disabled at will?

I like this mod, but can it be disabled and enabled at will? We would like to offer this savings to our customers on special occasions not year around.

Thanks for your help.
__________________
Mil Mascaras
Live Xcart Site #1-V- 4.1.8
Live Xcart site # 2-V 4.4.3
CDSEO Mod - Firetank MM30 - 7DANA- The bestTemplates!
Linux - EWD Host Servers awesome service!
AlteredCart One Page Checkout
Reply With Quote
  #64  
Old 12-02-2005, 04:42 AM
  HWT's Avatar 
HWT HWT is offline
 

eXpert
  
Join Date: Jan 2005
Location: Massachusetts, USA
Posts: 392
 

Default

You would not believe the idiodic nature of my issue . . . and it was so obvious. A php file should start with: <?php shouldn't it?!!!!! Now, for another cup of coffee.
__________________
x-cart 4.0.13 and 4.1.7 and 4.1.10
Reply With Quote
  #65  
Old 12-02-2005, 07:32 AM
 
bugaminute bugaminute is offline
 

Senior Member
  
Join Date: Oct 2004
Posts: 126
 

Default

Shipmerchant - Yes it can be enabled and disabled from the "shipping methods" in the management section of the Admin gui.

-----

HWT - <?php -- don't feel bad, I have done worse before coffee
__________________
Xcart Version Gold 4.7.12
Prod Sys- Debian 9 Stretch
Prod Sys - Apache/2.4.25 (Debian)
CDSEO Pro- 2.2
Mysql Community Edition 5.7.32
PHP 7.3
Reply With Quote
  #66  
Old 12-06-2005, 03:03 PM
 
khotos khotos is offline
 

Member
  
Join Date: Mar 2005
Location: Hollywood, FL
Posts: 29
 

Default Re: TINY mod to do Free Shipping for orders over $X w/real t

Quote:
Originally Posted by spingary
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.


Hi,
I'm trying to use this with X-Cart 4.0.17, but is not working.
Please can I have the correct code for this version ?
I'm using USPS and free shipping over $150 with FedEx Ground.

Thanks.
Miguel Karroum
__________________
Miguel Karroum
http://toosexyjeans.com
X-Cart 4.3.1
Reply With Quote
  #67  
Old 12-13-2005, 09:05 PM
 
eastman eastman is offline
 

Advanced Member
  
Join Date: Aug 2005
Location: Wyoming
Posts: 74
 

Default

This was a great mod, thanks to all for the hard work. Another poster asked about the possibility of adding the Free shipping option in the "Select a Carrier" menu instead of the "Delivery Options" menu. Has anyone figured this one out?

Thanks
__________________
X-Cart Pro v4.4.3
Reply With Quote
  #68  
Old 01-02-2006, 11:18 PM
 
misuse misuse is offline
 

Newbie
  
Join Date: Nov 2005
Posts: 6
 

Default

Quote:
Originally Posted by balinor
FYI, this WILL work with the new UPS module configuration, it just takes a little tweaking.

I am using the UPS module. What's the tweaking you are talking about?

I noticed that in order for someone to recieve the free shipping they have to use the dropdown to "other". Does the tweaking fix that?
__________________
X-Cart Gold v. 4.1.9 Apache
Reply With Quote
  #69  
Old 01-31-2006, 10:41 AM
 
billstevens billstevens is offline
 

Member
  
Join Date: Oct 2004
Posts: 26
 

Default Thanks for the mod! - Added a flat shipping option

Thanks for the mod it is working great with 4.0.17
I added a simple else statement to allow me to define a flat shipping rate if the conditions for free shipping are not met.

I'd like to eliminate the ability for our wholesale customers to qualify for free shipping - anyone done this already?

-Bill

Code:
<?php // Custom shipping methods // // Free shipping over $X mod // Add an entry to table xcart_shipping like this: // INSERT INTO xcart_shipping VALUES (150, 'Standard Shipping', '', 'L', 'FREEOVERX', '201', 5, 'Y', '', '0.00', 0); // I picked "201" subcode arbitrarily, but it seems like a good number to start as to not conflict with predefined shipping methods // The "5" is the orderby. "Y" is active or not. Replace "0.00" with a weight limit if you don't want this available for heavy orders. // This will show up as a Real-Time shipping method in "Shipping Options" // // Edit the file shipping/myshipper.php and under this line // include $xcart_dir."/shipping/mod_ARB.php"; // ADD THIS LINE to include this file: // include $xcart_dir."/shipping/mod_CUSTOM.php"; // // You can also include other custom shipping files here so that myshipper.php is left alone. // // Edit the amount valid for free shipping below. $freeOverAmount=125; // That's all! 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); if ($userinfo["s_country"] == $config["General"]["default_country"]) $dest = "L"; else $dest = "I"; $row = func_query_first("SELECT shippingid, subcode FROM $sql_tbl[shipping] WHERE code='FREEOVERX' AND active='Y' and destination = '$dest'"); if ($row && ($tempcart["subtotal"] >= $freeOverAmount)) { $rate = 0; $intershipper_rates[] = array("methodid" => $row['subcode'], "rate" => $rate); } // Begin add flat shipping amount if order does not qualify for free shipping else { $rate = 6.95; $intershipper_rates[] = array("methodid" => $row['subcode'], "rate" => $rate); } // End add flat shipping } ?>
__________________
Bill
X-Cart 4.1.9
Reply With Quote
  #70  
Old 02-01-2006, 03:06 PM
 
youngvet1 youngvet1 is offline
 

eXpert
  
Join Date: Aug 2005
Posts: 245
 

Default

Ok after reading this thread and the manual, i am having problems setting up free shipping for for orders over $x ( I also use flat rate shipping for store)which according to the first page of this thread -- what i want to accomplish shouldn't require any code changes.


I would like free shipping on USPS priority (national) orders >= $125.00

For US order < $125 I want USPS priority(national) to be $6.95.

Then I also have USPS express mail (national) to be $14.95 always.


I currently have the following setup ( which is not working):

I have

1)USPS priority (national)
destination zone set to USA ( which I dsefined as all united states)
the only fields i set are:

order total is set to $124.99 and flat is set to $6.95

----------------------------------------------------------
2)
USPS priority (national)
destination zone set to USA ( which I dsefined as all united states)
the only fields i set is:

flat is set to $0


-------------------------------------------------------
3)
USPS express mail (national)
destination zone set to USA ( which I dsefined as all united states)
the only fields i set is:

flat is set to $14.95


-----------------------------------------------------------
When i am signed in all i see in the drop down on the shopping cart page is (no matter what the order total is)
is
USPS priority $6.95
USPS express $14.95

-------------------------------------------------------------------------
I am not sure what the problem is because what i want to happen is when the order total is $125 or over it to say

USPS priority $0.00
USPS express $14.95


------------------------------------------------------------------------------


Also a second problem i am facing is when not signed in and I add something to the shopping cart (no matter what the total is)

there is no drop down by shipping method and it just says "$0.00"



--------------------------------------------------------------------



I would really really appreciate if some one could help me with these problems.
__________________
x-cart version 4.0.14
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



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 01:09 PM.

   

 
X-Cart forums © 2001-2020