A A A
Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 4 characters - maximum search word length is 84 characters

No permission to create posts
sp_Feed Topic RSS sp_TopicIcon
Shipping Charge Based on Order Total Amount
October 6, 2010
11:29 am
Avatar
Admin
Forum Posts: 5862
Member Since:
March 16, 2008
sp_UserOfflineSmall Offline

There have been a few requests forthe ability to offer different flat rate shipping options, based on order amount.

Let's say that you wanted to offer 2 flat rate shipping charges based on the order total.

For example:

Order total $0.00 to $100.00 = $6.50 shipping
Order total $100.01 to and up = $9.50 shipping

This functionality can be added to the Market Theme system without a whole lot of trouble.  

Here's how...

Open up your "cart.php" file for editing.  (This file is located in the "ajCart/" folder of the Market Theme files area.)

On or around line #100, you will find this line of code:

                    $checkout .='<input type="hidden" name="shipping_'.$i.'" value="'.$Shipping.'" />';

Disable the line by changing it to this:

                    // $checkout .='<input type="hidden" name="shipping_'.$i.'" value="'.$Shipping.'" />';

Next, on or around line #104 you will find this line of code:

            $GrandTotal = $GrandTotal + ($crtAmount[$item] * $crtQuantity[$item]);

For this support post example, we will use the shipping rates as outlined above.  So, immediately AFTER this line, enter the following lines:

if ($GrandTotal > 0) { $ShippingTotal = 6.50; }
if ($GrandTotal > 100.00) { $ShippingTotal = 9.50; }
$checkout .='<input type="hidden" name="shipping_1" value="'.$ShippingTotal.'" />';

Save the file, and that's it.

To take this a step further..  Let's say you actually wanted 4 shipping ranges like this instead of 2:

Order total $0.00 to $100.00 = $6.50 shipping
Order total $100.01 to $200.00 = $9.50 shipping
Order total $200.01 to $300.00 = $12.50 shipping
Order total $300.01 and up = $15.50 shipping

For a scenario like this, you would simply add two more lines of code in similar fashion as you just did, only changing the range of the Grand Total.  

So, for this new example you would instead enter these lines:

if ($GrandTotal > 0) { $ShippingTotal = 6.50; }
if ($GrandTotal > 100.00) { $ShippingTotal = 9.50; }
if ($GrandTotal > 200.00) { $ShippingTotal = 12.50; }
if ($GrandTotal > 300.00) { $ShippingTotal = 15.50; }
$checkout .='<input type="hidden" name="shipping_1" value="'.$ShippingTotal.'" />';

Save the file, and that would do it.

October 6, 2010
2:29 pm
Avatar
Utah
Member
Members
Forum Posts: 68
Member Since:
October 6, 2010
sp_UserOfflineSmall Offline

You're so good to us Laugh 

What if after $200 or $300 (whatever amount) you'd like to offer free shipping?  How would we end the code?  Would it be something like;l

if ($GrandTotal>250.00) {$ShippingTotal=0.00;}  ???

Did I get it right?  Embarassed

October 6, 2010
3:31 pm
Avatar
Admin
Forum Posts: 5862
Member Since:
March 16, 2008
sp_UserOfflineSmall Offline

Yes, that's right.

December 6, 2010
6:26 pm
Avatar
tderichsweiler
Member
Members
Forum Posts: 16
Member Since:
October 27, 2010
sp_UserOfflineSmall Offline

Thanks for this.  I did insert the required code but when I put an item into my shopping cart I'm getting an error message that says, "syntax error, unexpected '{' in [location of cart.php] on line 104. 

Clearly I must have done something wrong, but I can't for the life of me see my error.

I'm new to this, so please let me know if there's more info I need to send in order to allow someone to provide me w/ some guidance.

 

Thanks!

February 22, 2011
11:59 am
Avatar
Admin
Forum Posts: 5862
Member Since:
March 16, 2008
sp_UserOfflineSmall Offline

For those wanting to do pricing based on the number of items, instead of adding the code:

if ($GrandTotal > 0) { $ShippingTotal = 6.50; }
if ($GrandTotal > 100.00) { $ShippingTotal = 9.50; }
if ($GrandTotal > 200.00) { $ShippingTotal = 12.50; }
if ($GrandTotal > 300.00) { $ShippingTotal = 15.50; }
$checkout .='<input type="hidden" name="shipping_1" value="'.$ShippingTotal.'" />';

 

you could do something like this, based on the quantity of items.

For example:  

    For 1-6 items = $6.50

    For 7-30= $9.50

    For 31 - 72= $12.50

    For 73 and above = $15.50

 

// Set shipping rate based on total order quantity            
$totalquan=$totalquan+$crtQuantity[$item];    
if ($totalquan > 0) { $ShippingTotal = 6.50; }
if ($totalquan > 6) { $ShippingTotal = 9.50; }
if ($totalquan > 30) { $ShippingTotal = 12.50; }
if ($totalquan > 72) { $ShippingTotal = 15.50; }
$checkout .='<input type="hidden" name="shipping_1" value="'.$ShippingTotal.'" />';
April 17, 2011
8:43 am
Avatar
Member
Members
Forum Posts: 8
Member Since:
June 10, 2010
sp_UserOfflineSmall Offline
I set my code as follows: 

if ($i > 0) { $ShippingTotal = 6.50; }
if ($i > 4) { $ShippingTotal = 9.50; }
if ($i > 10) { $ShippingTotal = 12.50; }
if ($i > 20) { $ShippingTotal = 16.50; }
$checkout .='<input type="hidden" name="shipping_1" value="'.$ShippingTotal.'" />';

When I increase the quanties in the shopping cart above 4, the shipping price does not increase to $9.50.   
what else do I need to do to make this work?  

There was no mention in this tutorial about what to do with the normal fields on the individul product post page.  

Any ideas of what I need to do?  thanks... 
April 18, 2011
12:02 pm
Avatar
Admin
Forum Posts: 5862
Member Since:
March 16, 2008
sp_UserOfflineSmall Offline

By your code listed, it appears correct that if a user has a quantity of 5 (ie. greater than 4), then the shipping total should be $9.50.

 

However, I did notice something else on your site.  Your images and shopping cart aren't showing up correctly.

 

Go into your Market Theme settings area and change your image path settings from "absolute" to "relative" and save.

Make sure that your images are now showing up.  Also check your shopping cart contents page, to make sure it shows correctly.

If it doesn't, then would I be correct in guessing that your hosting account is through Hostgator? 

If so, let me know and I can direct you to a help page for that.

After that's working, then let's proceed on this shipping total question.

May 20, 2011
12:26 am
Avatar
Member
Members
Forum Posts: 66
Member Since:
September 26, 2010
sp_UserOfflineSmall Offline

I think these instructions are obsolete for the current version, or at least the one I am using currently. 4.2

$checkout .='<input type="hidden" name="shipping_'.$i.'" value="'.$Shipping.'" />'; does not exist in current code. 

I don't know which code to comment out.

I see:

$checkout = '';Frown
 $prods = '';
 $i = 1;
 $ShippingTotal = 0;
 $GrandTotal = 0;

and

$checkout .='<input type="hidden" name="handling_'.$i.'" value="'.$Handling.'"

and

$checkout .='<input type="hidden" name="item_name_'.$i.'" value="'.$crtName[$item].'" />

and

$checkout .='<input type="hidden" name="item_description_'.$i.'" value="'.$crtOptions[$item].'" />

dcw
May 20, 2011
11:05 am
Avatar
Admin
Forum Posts: 5862
Member Since:
March 16, 2008
sp_UserOfflineSmall Offline

Yes, I guess with the release of version 4.2 -- these instructions above are out of date.

I'll try to get together the code changes necessary and post back here.

May 20, 2011
5:17 pm
Avatar
Admin
Forum Posts: 5862
Member Since:
March 16, 2008
sp_UserOfflineSmall Offline

Ok...

 

So here are the code changes for the current version of 4.23:

 

1.  Open up your "cart.php" file for editing.  It's located within the "ajCart/" folder, however you can also edit it through the Appearance Theme editor tool.

 

2.  Locate the line around #189 that says:

// Create value for inventory control 

 

3.  Immediately BEFORE this line, enter this extra code:

if ($GrandTotal > 0) { $ShippingTotal = 1.00; }
if ($GrandTotal > 100.00) { $ShippingTotal = 2.00; }
if ($GrandTotal > 200.00) { $ShippingTotal = 3.00; }
if ($GrandTotal > 300.00) { $ShippingTotal = 4.00; }

if ($i<count($crtAmount)){
        $item_shipping_pk = 0;
    } else {
        $item_shipping_pk = $ShippingTotal;
    }

 

4.  Save the file.

 

Keep in mind, you'll want to alter this code in three ways.

 

1. The code above is for 4 price brackets.  You can have more or less.  To add more, you'll add an extra line like this:

if ($GrandTotal > 400.00) { $ShippingTotal = 5.00; }

-or- to have one or two price brackets less, you'll remove a line or two --

if ($GrandTotal > 200.00) { $ShippingTotal = 3.00; }
if ($GrandTotal > 300.00) { $ShippingTotal = 4.00; }
if ($GrandTotal > 0) { $ShippingTotal = 4.95; }
if ($GrandTotal > 49.99) { $ShippingTotal = 6.95; }
if ($GrandTotal > 99.99) { $ShippingTotal = 0.00; }

if ($i<count($crtAmount)){
        $item_shipping_pk = 0;
    } else {
        $item_shipping_pk = $ShippingTotal;
    }
August 8, 2011
11:46 pm
Avatar
Admin
Forum Posts: 5862
Member Since:
March 16, 2008
sp_UserOfflineSmall Offline

Post #39 in this thread my also help.

http://www.markettheme.com/for.....-the-first

January 14, 2012
8:57 pm
Avatar
gina
Member
Members
Forum Posts: 10
Member Since:
January 12, 2012
sp_UserOfflineSmall Offline

I need help. Was trying to follow the above directions to get shipping calculated by items quantity but just made a mess out of my coding. I too use hostgator and have the latest version of market theme. My checkout bot is now showing error on box#199. But I think it's all wrong. In the end of the code I changed $item for#item.
And have both portions of code on: the one after GrandTotal and the one before create value as above.
How do I clean up this mess?

January 18, 2012
12:36 am
Avatar
Admin
Forum Posts: 5862
Member Since:
March 16, 2008
sp_UserOfflineSmall Offline

So, did you change "#item" back to "$item" then?

January 18, 2012
12:38 am
Avatar
Admin
Forum Posts: 5862
Member Since:
March 16, 2008
sp_UserOfflineSmall Offline

If it helps, you can always just open up the standard default version of "cart.php" (located in the "ajCart/" folder of the Market Theme files) -- and just re-paste it over your changes to get back to the base version.

 

Then, you can try again -- only doing steps in #10 above.

January 18, 2012
12:42 am
Avatar
Admin
Forum Posts: 5862
Member Since:
March 16, 2008
sp_UserOfflineSmall Offline

You also may need to make sure the "register_globals" variable is turned "off" in your "php.ini" hosting configuration file.

Here are more details on that process.

http://www.markettheme.com/for.....pty/page-4

(post #67)

January 18, 2012
12:44 am
Avatar
gina
Member
Members
Forum Posts: 10
Member Since:
January 12, 2012
sp_UserOfflineSmall Offline

I did fix it back to the standart version but i still want for it to calculate by items quantity. how can i make it work?

The instructions above left me with error on line#196

January 18, 2012
12:44 am
Avatar
Admin
Forum Posts: 5862
Member Since:
March 16, 2008
sp_UserOfflineSmall Offline

Try the link on post #15 above.

January 18, 2012
12:50 am
Avatar
gina
Member
Members
Forum Posts: 10
Member Since:
January 12, 2012
sp_UserOfflineSmall Offline

I cant find the file you mentioned. Im need more detail directions. Sorry, Im new at this.

January 18, 2012
12:53 am
Avatar
Admin
Forum Posts: 5862
Member Since:
March 16, 2008
sp_UserOfflineSmall Offline
January 18, 2012
12:55 am
Avatar
gina
Member
Members
Forum Posts: 10
Member Since:
January 12, 2012
sp_UserOfflineSmall Offline

The link is not helpfull. Not what Im trying to do

No permission to create posts
Forum Timezone: UTC 0

Most Users Ever Online: 213

Currently Online:
4 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

icy1: 2636

wreed06: 175

laurie390: 169

boutiqueelliette: 156

StitchTek Services, LLC: 144

yiorgos: 127

Member Stats:

Guest Posters: 457

Members: 2471

Moderators: 1

Admins: 1

Forum Stats:

Groups: 1

Forums: 4

Topics: 4078

Posts: 18978

Newest Members: teddy1, raycrean, tseibt55, aceman, peteryoung320@gmail.com, JdsCentral

Moderators: Market Admin: 5862

Administrators: Market Admin: 5862

Market takes ecommerce to the next level with an easy to use, quick setup platform. Learn more or take the tour.