Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Disable Flat Rate shipping after 4 items in cart


djkubus

Recommended Posts

Hello I found a mod in the contribs that disables shipping modules after a certain amount of money is spent in the cart but what I wanted was code that will disable the Flat Rate shipping after the customer adds 5 or more items in the shopping cart. I have edited the code a bit from the original mod and it still does not work I have checked the original code and that does not work can anyone help me please... :-)

 

Thanx

 

Original contrib

This came about after I wanted to have the following 4 shipping options on my store. 

1) Table rate for standard postage based on a per quantity basis ie 1 unit = €5.00 2 units=€9.00 etc
2) A second table rate giving an option of registered courier post again per quantity 1 unit = €8.00 2=€13.00 etc
3) Free shipping by standard post if order over €50 - only to appear as an option if order value over €50
4) Free shipping by courier if over €100 – only to appear if order value over €100


The first 2 I had found using a contribution from doodersrage search for Table Rate With Quantity Option but the last 2 I needed to find a solution for. 

I modified a suggestion in a help thread by wheeloftime in relation to disabling a shipping option based on weight and here it is.

In the particular shipping module you wish to apply this to ( catalog/includes/modules/shipping/FILE.php ) insert the following at line 80:


if ( ($this->enabled == true) && ($order_total <100) ) {
   $this->enabled = false;
   return;
   }

just after

if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title); 

and before 

     return $this->quotes;
   }

modify the figure 100 to whatever figure you wish to trigger the display of the module. 

Note: this merely hides the module if the total is less than €100. I use this to provide a free shipping option ( I have a table rate shipping module set to €0.00 ) but you could use it for any purpose – maybe a reduced shipping rate if you spend a certain amount etc.

 

This is what I edited the code to and it does not work...

 

if ( ($this->enabled == true) && ($quantity <4) ) {
   $this->enabled = false;
   return;
   }

 

Im using the latest version of OSC

Link to comment
Share on other sites

Why do you think $quantity would work? Have you set this to something?

 

if ($cart->count_contents() >= 5) $this->enabled = false;

 

Burt, i'm not much of a coder so I thought this would work as I have found this call tag in another script to thats what I thought the cart uses for quantity. By any chance would you know where to insert this code into the flat.php module I tried in the same place as the one above and I get a php error. I looked for $cart anywhere in the coding and that line does not pop up... Thank you in advance for your help :-)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...