Forums / Built-in Shipping and Payment Modules / 2 different shipping amounts and a maximum per order for shipping

2 different shipping amounts and a maximum per order for shipping

Started by scid on 28 May 2011, 2:11 PM · Views: 1,288

Results 1 to 11 of 11
28 May 2011, 2:11 PM
#1
scid avatar

scid

New Zenner

Join Date:
May 2011
Location:
US
Posts:
7
Plugin Contributions:
0

2 different shipping amounts and a maximum per order for shipping

I hope someone can point me in the right direction. I've been searching and searching and cannot find this exact problem. I'm only slightly versed in coding, but cannot write my own code. (I can copy and paste though). :smile:

I have several small items in my shop. Most can ship for $2.00 and I've been using a flat rate shipping of $2.00 per order. If someone orders a 2nd or 3rd item, the shipping rate only changes a few pennies and I'd rather make it simple. Well now I've complicated things because I'm adding 2 items which should only have $1.00 shipping fee if purchased inidivudally, original items should charge $2.00 if shipping individually, but I don't want to charge more than $2.00 total shipping even if they order a larger quantity or a mix of items. Can anyone help me figure out how to do this?

Thanks in advance!

28 May 2011, 4:02 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: 2 different shipping amounts and a maximum per order for shipping

You could customize the Flat Rate flat shipping module ...

    function quote($method = '') {
      global $order;

// bof: custom Flat rates
global $cart;
// check how many cart contains of products_id 6
$chk_item1 = 0;
$chk_item1 += $_SESSION['cart']->in_cart_check('products_id','6');

// check how many cart contains of products_id 18
$chk_item2 = 0;
$chk_item2 += $_SESSION['cart']->in_cart_check('products_id','18');

// check total count
$chk_cart_count = $_SESSION['cart']->count_contents();

// set rate based on total items in cart vs products_id 6, products_id 18 vs all products
switch (true) {
  case ($chk_item1 == $chk_cart_count):
  // only Item1 is in the cart
    $flat_charge = 1.00;
    break;
  case ($chk_item2 == $chk_cart_count):
  // only Item2 is in the cart
    $flat_charge = 1.00;
    break;
  default:
  // mixed cart
    $flat_charge = MODULE_SHIPPING_FLAT_COST;
    break;
}

      $this->quotes = array('id' => $this->code,
                            'module' => MODULE_SHIPPING_FLAT_TEXT_TITLE,
                            'methods' => array(array('id' => $this->code,
                                                     'title' => MODULE_SHIPPING_FLAT_TEXT_WAY,
                                                     'cost' => $flat_charge)));
// eof: custom Flat rates

      if ($this->tax_class > 0) {
        $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
      }

NOTE: Set the Flat Rate Fee to 2.00 on the module ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

28 May 2011, 5:51 PM
#3
scid avatar

scid

New Zenner

Join Date:
May 2011
Location:
US
Posts:
7
Plugin Contributions:
0

Re: 2 different shipping amounts and a maximum per order for shipping

The only thing I don't think this will let me do is have some items be $1 if purchased individually and some items be $2 if purchased individually or am I missing something? It's pretty close though if it's the best I can do.

28 May 2011, 5:53 PM
#4
scid avatar

scid

New Zenner

Join Date:
May 2011
Location:
US
Posts:
7
Plugin Contributions:
0

Re: 2 different shipping amounts and a maximum per order for shipping

Oh wait, I think I understand, there are 2 product ID's shown. So, I can just add the product ID of each type of item and separate by commas?

28 May 2011, 5:56 PM
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: 2 different shipping amounts and a maximum per order for shipping

No ... I set this up to test for individual products_id ...

You would need to follow the pattern of the two examples if you want to add more that are $1.00 shipping products when purchased alone ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

28 May 2011, 5:57 PM
#6
scid avatar

scid

New Zenner

Join Date:
May 2011
Location:
US
Posts:
7
Plugin Contributions:
0

Re: 2 different shipping amounts and a maximum per order for shipping

Hmmmm, in order to not need to add a product id each time I add a new product (frequently as each product is a one of a kind item, handmade) could I do this by catagory? All items in one catagory gets charged $1 shipping, all items in the 2nd catagory gets $2 shipping with a max shipping rate of $2??

28 May 2011, 6:03 PM
#7
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: 2 different shipping amounts and a maximum per order for shipping

All Products get a $2.00 Flate Rate Charge unless you build a test for them to see how many items are in the cart and if all of them are that item ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

28 May 2011, 6:11 PM
#8
scid avatar

scid

New Zenner

Join Date:
May 2011
Location:
US
Posts:
7
Plugin Contributions:
0

Re: 2 different shipping amounts and a maximum per order for shipping

OK, I'm going to test it. I see where the lines:

// class methods
function quote($method = '') {
global $order;

Are in the flat.php file.

Do I insert this code and leave what's there or replace what's below that section?

28 May 2011, 6:15 PM
#9
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: 2 different shipping amounts and a maximum per order for shipping

I marked the new code in red ... the code in black is to stay where it is and the code in red goes between the code in black ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

28 May 2011, 6:36 PM
#10
scid avatar

scid

New Zenner

Join Date:
May 2011
Location:
US
Posts:
7
Plugin Contributions:
0

Re: 2 different shipping amounts and a maximum per order for shipping

Thank you! I appreciate your patience with me.

28 May 2011, 6:43 PM
#11
scid avatar

scid

New Zenner

Join Date:
May 2011
Location:
US
Posts:
7
Plugin Contributions:
0

Re: 2 different shipping amounts and a maximum per order for shipping

You are wonderful! It works perfectly!:clap::clap: