Forums / Built-in Shipping and Payment Modules / "Per item" for some products, table rate for the rest?

"Per item" for some products, table rate for the rest?

Locked

Started by kazie on 28 May 2009, 11:05 AM · Views: 3,072

Results 1 to 16 of 16
This thread is locked. New replies are disabled.
28 May 2009, 11:05 AM
#1
kazie avatar

kazie

New Zenner

Join Date:
Feb 2006
Posts:
26
Plugin Contributions:
0

"Per item" for some products, table rate for the rest?

Is it possible to set up my shipping according to;

Product Category A, B and C
1 item: €12
2-3: €15
<4: €29

(I've worked this out with table rate)

Product Category D
Allways €12 per item

2 Jun 2009, 5:18 PM
#2
ajeh avatar

ajeh

Oba-san

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

Re: "Per item" for some products, table rate for the rest?

You would have to customize the count to reduce the count for the Products in Category D used in the table calculation then add in the cost for the those Products in Category D at their own rate to add to the cost ...

If you look in the table.php module you will see the function quote where this can be customized ...

In the shopping_cart.php class you can use this function:

/**

  • Method to calculate the number of items in a cart based on an abitrary property
  • $check_what is the fieldname example: 'products_is_free'
  • $check_value is the value being tested for - default is 1
  • Syntax: $_SESSION['cart']->in_cart_check('product_is_free','1');
  • @param string product field to check
  • @param mixed value to check for
  • @return integer number of items matching restraint
    */
    function in_cart_check($check_what, $check_value='1') {

to determine how many Products from master_categories_id match the Category D categories_id ...

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!

4 Jun 2009, 12:29 PM
#3
kazie avatar

kazie

New Zenner

Join Date:
Feb 2006
Posts:
26
Plugin Contributions:
0

Re: "Per item" for some products, table rate for the rest?

Hi! Thanks for the reply. I should probably clarify, They're all the same product type "Products - General". The Category I want a per item shipping rate (€12/item) for, and ignore the table rate, is called LL/C and has the id 21. Can you please spell it out for me, I'm kinda new at this ;)

4 Jun 2009, 3:13 PM
#4
ajeh avatar

ajeh

Oba-san

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

Re: "Per item" for some products, table rate for the rest?

And on a mixed cart of the categories you want to use the table rates you have set up but change it when something is in categories_id 21 to add on to this at 12 per 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!

5 Jun 2009, 9:56 AM
#5
kazie avatar

kazie

New Zenner

Join Date:
Feb 2006
Posts:
26
Plugin Contributions:
0

Re: "Per item" for some products, table rate for the rest?

Exactly, "per item" shipping for category id #21 (and its sub categories #22 and #23) and "table rate" for my remaining categories (and their respective sub categories), #1, #14, #26 and #27.

5 Jun 2009, 5:28 PM
#6
ajeh avatar

ajeh

Oba-san

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

Re: "Per item" for some products, table rate for the rest?

So all products use the table rates as defined except for categories_id 22 and 23, correct?

Are categories_id 22 and 23 the master_categories_id for these products?

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!

8 Jun 2009, 10:52 AM
#7
kazie avatar

kazie

New Zenner

Join Date:
Feb 2006
Posts:
26
Plugin Contributions:
0

Re: "Per item" for some products, table rate for the rest?

ID 22 and 23 do use the table rate (by default). I havn't figured out how to exclude these two categories from the table rate. And all products in id 22 and 23 have 22 and 23 as their master id, I havn't messed around with master id at all.

8 Jun 2009, 2:54 PM
#8
ajeh avatar

ajeh

Oba-san

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

Re: "Per item" for some products, table rate for the rest?

This will count how many products are in master_categories_id 22 ...

$chk_excluded = $_SESSION['cart']->in_cart_check('master_categories_id','22');

You need to determine how many are in the two master_categories_id 22 and 23 and subtract those from the calculation when item count is used and then add it in the the total at the new rate ...

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!

9 Jun 2009, 9:55 AM
#9
kazie avatar

kazie

New Zenner

Join Date:
Feb 2006
Posts:
26
Plugin Contributions:
0

Re: "Per item" for some products, table rate for the rest?

Where to i place it, the shopping cart module file?

9 Jun 2009, 2:47 PM
#10
ajeh avatar

ajeh

Oba-san

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

Re: "Per item" for some products, table rate for the rest?

You are trying to customize your shipping module for Table Rate table ...

You need to customize the file:
/includes/modules/shipping/table.php

to count how many items are in the cart for categories_id 22 and 23 and subtract that from the count that is used in the table rate ... then add in that table rate total + (count for cat 22 and 23 * 12) for those products ...

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!

10 Jun 2009, 11:32 AM
#11
kazie avatar

kazie

New Zenner

Join Date:
Feb 2006
Posts:
26
Plugin Contributions:
0

Re: "Per item" for some products, table rate for the rest?

Where in table.php? Hehe I know I'm a pain in the ###### here =) I either get a blank page at "index.php?main_page=checkout_shipping" or it doesn't recognize that
$chk_excluded = $_SESSION['cart']->in_cart_check('master_categories_id','22');
... I was supposed to insert to table.php.

Can you please post the entire table.php-file with the changes I have to make. And is it possible to make it so that all subcategories in ID 21 (that would be 22 and 23) are set up so that the table rate exclude them (if you were o add more subcategories to ID 21 in the future)

10 Jun 2009, 1:35 PM
#12
ajeh avatar

ajeh

Oba-san

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

Re: "Per item" for some products, table rate for the rest?

I would have to work out all of the coding for this to work ...

I will try to get some time later to write up the code, if no one has come up with it before then ... :smile:

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!

11 Jun 2009, 10:23 AM
#13
kazie avatar

kazie

New Zenner

Join Date:
Feb 2006
Posts:
26
Plugin Contributions:
0

Re: "Per item" for some products, table rate for the rest?

Thanks ;) That would rule.

11 Jun 2009, 1:26 PM
#14
ajeh avatar

ajeh

Oba-san

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

Re: "Per item" for some products, table rate for the rest?

You would have to customize the table.php and alter the following:

  function quote($method = '') {
    global $order, $shipping_weight, $shipping_num_boxes, $total_count;

    // shipping adjustment
    switch (MODULE_SHIPPING_TABLE_MODE) {
      case ('price'):
        $order_total = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;
        break;
      case ('weight'):
        $order_total = $shipping_weight;
        break;
      case ('item'):
        $order_total = $total_count - $_SESSION['cart']->free_shipping_items();

        $chk_excluded22 = $_SESSION['cart']->in_cart_check('master_categories_id','22');
        $chk_excluded23 = $_SESSION['cart']->in_cart_check('master_categories_id','23');

echo 'COUNT IS: total: ' . $order_total . ' cat 22: ' . $chk_excluded22 . ' cat 23: ' . $chk_excluded23 . ' = ' . ($order_total - ($chk_excluded22 + $chk_excluded23));

        $order_total = ($order_total - ($chk_excluded22 + $chk_excluded23));
        break;
    }

    $order_total_amount = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;

    $table_cost = split("[:,]" , MODULE_SHIPPING_TABLE_COST);
    $size = sizeof($table_cost);
    for ($i=0, $n=$size; $i<$n; $i+=2) {
      if (round($order_total,9) <= $table_cost[$i]) {
        if (strstr($table_cost[$i+1], '%')) {
          $shipping = ($table_cost[$i+1]/100) * $order_total_amount;
        } else {
          $shipping = $table_cost[$i+1];
        }
        break;
      }
    }

    $shipping = $shipping + (($chk_excluded22 + $chk_excluded23) * 12);

    if (MODULE_SHIPPING_TABLE_MODE == 'weight') {

The echo in there is just so you can see how this is working ... later comment it out ...

NOTE: if you have other shipping modules running at the same time you may need to customize this code further ...

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!

11 Jun 2009, 2:51 PM
#15
kazie avatar

kazie

New Zenner

Join Date:
Feb 2006
Posts:
26
Plugin Contributions:
0

Re: "Per item" for some products, table rate for the rest?

Awsome, can't thank you enough.

Just one final question. If you only have products from category 22 or 23 in the shopping cart it calculates the table rate total for one product plus 12 dollars.

Defined by ..
$shipping = $shipping + (($chk_excluded22 + $chk_excluded23) * 12);

if i change this to ...
$shipping = (($chk_excluded22 + $chk_excluded23) * 12);

The rest of the products becomes free.

Is it possible to skip the "$shipping" and only use "(($chk_excluded22 + $chk_excluded23) * 12);" if there's only products from category 22 and 23 in the shopping cart.

Thank's again

11 Jun 2009, 4:15 PM
#16
ajeh avatar

ajeh

Oba-san

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

Re: "Per item" for some products, table rate for the rest?

Set your first amount to:
0:0.00

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!