If this is your first visit, check our documentation. To post, register or login.
Forums / Built-in Shipping and Payment Modules / Different shipping methods for different categories

Different shipping methods for different categories

Started by tylerd213 on 13 Mar 2008, 2:16 AM · Views: 107,884

Results 341 to 360 of 554
5 Apr 2011, 2:51 PM
#341
paul69 avatar

paul69

Zen Follower

Join Date:
Jan 2010
Posts:
124
Plugin Contributions:
0

Different shipping methods for different categories

Ok I've searched through the forum for 2 hours now and mostly this thread. What I'm trying to do is add an aditional amount to the shipping quote for international which isn't a problem however, I need to do it for only 2 categories or for those with a product id > 3000 as that is the cut off. Can anyone help? I've tried many options and keep getting stuck with the syntax to use to look for a product id greater than 3000 or include a different quote only if the one or both of the 2 categories are in the cart and NO others. I've been trying to modify the following to do it..

          if ($order->delivery['country_id'] != STORE_COUNTRY) {
            $extra_handling_int = 13.00;
        global $cart;
        $chk_categories += $_SESSION['cart']->in_cart_check('master_categories_id','17');
        if ($chk_categories > 0) {
          $extra_handling_int = 0.00;
``` Not sure how to do this and I can't seem to put together anything that will work. Maybe I need to clone the USPS module or something?
7 Apr 2011, 4:31 PM
#342
bigal007 avatar

bigal007

New Zenner

Join Date:
Apr 2011
Posts:
4
Plugin Contributions:
0

Re: Different shipping methods for different categories

I am new to zen cart and was wondering if what I was thinking would work after reading this thread.
I have a shop where it is Illegal to mail order many of the products, these are spread over a large number of categories. What I need to do is set things up so that if any of the prohibited items are in the cart then store pickup only is the sole delivery option. For items that can be shipped I then sI would like to be able to offer either a flat rate charge or store pickup as the delivery options.
It would however be useful if some items could be set up for free delivery (to match off line offers). In the situation where a free delivery item is mixed with one of the other products then the other delivery methods come back into force. So for example

Product R = Resticted item MUST BE Store Pickup only

Product S = Standard flat rate or Store Pickup

Product F = Free Shipping or Store Pickup.

So a cart with:

R, R+S, R+F or R+S+F = Store Pickup Only.

S or S+F = Flat Rate (default) or Store Pickup.

F = Free Shipping (default) or Store Pickup.

It is unlikely that items which can be shipped will be picked up but as we have to offer that service on the restricted items anyway it makes sense to offer it accross the board.

I thought that easiest way to do this would be using the shipping weight to trigger the options, I thought that I could set the shipping weight to zero for the free shipping, 1 for flat rate and 2 for store pickup only. I am unsure where and how you would then check to see which shipping method should be used..

Thanks

Alan

11 Apr 2011, 12:13 PM
#343
bigal007 avatar

bigal007

New Zenner

Join Date:
Apr 2011
Posts:
4
Plugin Contributions:
0

Re: Different shipping methods for different categories

OK so I have managed to get the free shipping to work, just by using the free shipping module, using the always free shipping radio button in the product admin.
I have set up all products that can be shipped so that the have a product weight of 0. For the restricted products I have set the product weight to 2. I have played around with the fat module and have added the following code:

      // disable only when entire cart is free shipping
      if (zen_get_shipping_enabled($this->code)) {
        $this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false);
      }
	  
	  // disable based on cart weight
	  if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('weight') > 0)) {
	  $this->enabled = false;
	  }

Which I hoped would turn the module off if the total weight in the cart was greater than zero. Trouble is though the flat mod still shows even with a restricted item (weight greater then zero) in the cart.
If anyone could help me find an answer to this problem.

BTW I am using version 1.3.9h.

Thanks

Alan

Alan

11 Apr 2011, 1:56 PM
#344
ajeh avatar

ajeh

Oba-san

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

Re: Different shipping methods for different categories

Inside your IF statement add:

global $cart;

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 Apr 2011, 10:42 PM
#345
bigal007 avatar

bigal007

New Zenner

Join Date:
Apr 2011
Posts:
4
Plugin Contributions:
0

Re: Different shipping methods for different categories

Thanks for the help.
OK so I have tried adding the global $cart; to the file. I could not work out where it needs to go though. What I have now is:

  class flat {
    var $code, $title, $description, $icon, $enabled;

// class constructor
    function flat() {
      global $order, $db;

      $this->code = 'flat';
      $this->title = MODULE_SHIPPING_FLAT_TEXT_TITLE;
      $this->description = MODULE_SHIPPING_FLAT_TEXT_DESCRIPTION;
      $this->sort_order = MODULE_SHIPPING_FLAT_SORT_ORDER;
      $this->icon = '';
      $this->tax_class = MODULE_SHIPPING_FLAT_TAX_CLASS;
      $this->tax_basis = MODULE_SHIPPING_FLAT_TAX_BASIS;

      // disable only when entire cart is free shipping
      if (zen_get_shipping_enabled($this->code)) {
        $this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false);
      }
	  
	  // disable based on cart weight
	  global $cart;
	  if ((IS_ADMIN_FLAG == false) && ($_SESSION['cart']->in_cart_check('weight') > 0)) {
	  $this->enabled = false;
	  }

I also tried it with adding the $cart variable to the top global's statement, and also as a new line within the {} of the if statement.

With all of these I get the same error message:

1054 Unknown column 'weight' in 'field list'
in:
[select weight as check_it from products where products_id='93' limit 1]

The products_id number is correct for the first item in the cart.

I think that I had a problem with the braces in the if statement, in that originally there were two opening and closing braces at each end, I closed off the first brace before the && and opened the second half afterwards.

Unfortunately I have no PHP experience, I've only ever used C/C++ and some Java before, and that was back in the 90's.

Thanks

Alan

12 Apr 2011, 12:57 AM
#346
ajeh avatar

ajeh

Oba-san

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

Re: Different shipping methods for different categories

You cannot make up field names ... :eek:

This function:
$_SESSION['cart']->in_cart_check('something_here')

requires a valid field from the products table ...

If you want to use Product Weight. then use:
products_weight

as that is the name of the field that you are trying to check in the cart ... :cool:

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!

12 Apr 2011, 12:58 AM
#347
ajeh avatar

ajeh

Oba-san

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

Re: Different shipping methods for different categories

Also, are you looking for a specific weight in the cart or the total weight of the cart?

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!

12 Apr 2011, 1:08 AM
#348
ajeh avatar

ajeh

Oba-san

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

Re: Different shipping methods for different categories

If you mean Total weight you could use:

if (!IS_ADMIN_FLAG) {
  global $cart;
//  $chk_weight = $_SESSION['cart']->show_weight() - $_SESSION['cart']->free_shipping_weight();
  $chk_weight = $_SESSION['cart']->show_weight();
  if ($chk_weight > 0) {
    $this->enabled = false;
  }
}

the commented one is if you need to remove the Free Shipping Weight where you are using weight in the Product Weight on Products marked as Free Shipping ...

experiment a bit ...

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!

13 Apr 2011, 1:22 PM
#349
bigal007 avatar

bigal007

New Zenner

Join Date:
Apr 2011
Posts:
4
Plugin Contributions:
0

Re: Different shipping methods for different categories

Linda thank you very much for your help, it works perfectly now, and without the need to uncomment the extra line you put in:). I have it set up that any items which can be shipped have zero weight and the restricted items have a positive weight. So if the cart has any weight in it then the only delivery choice is store pickup. For the few items with free shipping then I just use the free shipping radio button on the product page and the freeshipper module. I hope by being clear in what I have done with your help that it may be of assistance to others.
I had a look in the database tables in the mySQL control panel as well as looking for the cart .php files to try and find the correct field name to look up which was where I got the weight field name from. I guess that I really need to find some mySQL/PHP training courses, as I am obviously not going to be able to muddle my way through this!
Anyway again many thanks for the help.

Alan

13 Apr 2011, 1:45 PM
#350
ajeh avatar

ajeh

Oba-san

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

Re: Different shipping methods for different categories

You are most welcome ... thanks for the update that this is now working for you ... :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!

22 Apr 2011, 2:18 AM
#351
lenpilot avatar

lenpilot

New Zenner

Join Date:
Apr 2011
Location:
Colonial Beach Virginia
Posts:
10
Plugin Contributions:
0

Re: Different shipping methods for different categories

I am trying to configure the USPS options so that Media Mail will only be given as an option when the products are books, CD or DVD but not on other products. If this is posted elsewhere I cant find it.

I can put these into a single "Media" master category if needed.

This is a new install
No add ons
And I am very green here

If this is already covered somewhere else I would appreciate if someone can point me there.

22 Apr 2011, 1:54 PM
#352
ajeh avatar

ajeh

Oba-san

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

Re: Different shipping methods for different categories

Let's say all Products that allow the Media are in Categories 10, 12 and 15 ...

You can customize the shipping module:
/includes/modules/shipping/usps.php

You could do a test and see when Media should show, something like:

[B]          $cost = preg_replace('/[^0-9.]/', '',  $cost);
[/B]$chk_media = 0;
$chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','10');
$chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','12');
$chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','15');

if ($chk_media == $_SESSION['cart']->count_contents()) {
  // all media content
  $chk_media_only = true;
} else {
  $chk_media_only = false;
}
if ($type != 'MEDIA' || ($type == 'MEDIA' && $chk_media_only)) {
//  echo 'YES USPS ' . $type . ' count: ' . $chk_media . ' vs ' . $_SESSION['cart']->count_contents() . '<br>';
[B]          $methods[] = array('id' => $type,
                             'title' => $title,
                             'cost' => ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_USPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_USPS_HANDLING) );
[/B]} else {
//  echo 'NO USPS ' . $type . ' count: ' . $chk_media . ' vs ' . $_SESSION['cart']->count_contents() . '<br>';
  // do not show
}
[B]        }

        $this->quotes['methods'] = $methods;
[/B]

Now, MEDIA will only show if the total contents of the cart comes from master_categories_id 10, 12 and 15 ...

NOTE: be sure you are using the current USPS January 2, 2011 C version of usps.php from post #26:
http://www.zen-cart.com/forum/showthread.php?t=171314&highlight=USPS+January+2011

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!

22 Apr 2011, 11:48 PM
#353
srfrantz avatar

srfrantz

New Zenner

Join Date:
Jan 2005
Posts:
3
Plugin Contributions:
0

Re: Different shipping methods for different categories

Hi all.
sorry I can't bring myself to read thru all 33 pages of this thread to see if my needs are answered somewhere.

client site is here: https://www.allaboutthewish.com/store in demo/test mode.

the bottles all ship by UPS. fine good. works great.
the bottles come with a start up set of papers and stuff that are included in the box. weight is adjusted for that. still all good.

owner wants to have just the custom engraved brass plates that are ordered separate from bottles, ship at flat rate of $2.50 (via USPS) as she has to send out to have those done separately, then she just drops in the mail when they come back to her.

I could use the code from the very first solution in the thread for the accessories category, but there are the chocolates (which is another whole issue..get to that in a sec.) obviously I could create a category just for the nameplates...but she's picky about all the accessories be in accessories...

here's what I figured out so far. I enabled the Free Shipping module and just assigned it to the brass plates. and assigned a handling charge of $2.50 in the edit box for Free Shipping in the admin. this does the job, but its odd to see Free Shipping $2.50 on the checkout screen. so I could find the lang file def. (if that's where it is) and change it to something else.
or I could just add $2.50 to the price and put 0 in as the shipping/handling fee.

but the issue is, what if the client or someone else with no clue how to use the admin, needs to add another product, that ships at a different flat rate?

is there a module or an add on or something that lets you put in the individual items' unique shipping charges, or select a shipping method for that product only, on the product details page?
could this be something that is built into future versions?????

I shudder to think how long it would take me to find all the proper files to edit the code to make it happen, and how many things I could break in the process, being a completely self taught trial and error PHP duffer...

any other ideas are welcome...

oh the chocolates, she wants an option for them to request an ice pack in warm weather which would add a cost and weight and up shipping charge accordingly. only thing I can think of is to add the ice pack as a product. then try to figure a way to ask customer on checkout if they'd like to add one to their cart (only if they order the chocolates) before final checkout?

thanks.
Stan

23 Apr 2011, 11:40 PM
#354
lenpilot avatar

lenpilot

New Zenner

Join Date:
Apr 2011
Location:
Colonial Beach Virginia
Posts:
10
Plugin Contributions:
0

Re: Different shipping methods for different categories

Ajeh:

Let's say all Products that allow the Media are in Categories 10, 12 and 15 ...

You can customize the shipping module:
/includes/modules/shipping/usps.php

You could do a test and see when Media should show, something like:

Now, MEDIA will only show if the total contents of the cart comes from master_categories_id 10, 12 and 15 ...

NOTE: be sure you are using the current USPS January 2, 2011 C version of usps.php from post #26:
http://www.zen-cart.com/forum/showthread.php?t=171314&highlight=USPS+January+2011

Thank You! That Works Great!!! I Do have to add each subcategory as well. It will not allow off category items. Even with free shipping. But that is something I can live with. People love cheap shipping and this should greatly enhance book and media sales I am almost there! http://www.lenandmarcys.com/cart/

27 Apr 2011, 6:07 PM
#355
oqcq avatar

oqcq

New Zenner

Join Date:
Apr 2011
Posts:
3
Plugin Contributions:
0

Re: Different shipping methods for different categories

I've read the entire thread, believe it or not. It seems true that is impossible for Zencart to cater for everybody's specific shipping needs as standard.

My UK-based store has four product types in four categories.

As I ship internationally, I need to have a separate pricing for each of the 'zones' : UK, Europe and Row and currently use the Zone Rates shipping.

Currently, I have assigned each product with a weight according to its category.

Problem: The total shipping cost is given according to the weight: price as defined rather than calculating the shipping cost of products from category A's shipping PLUS products from category B's shipping.

To overcome this, I ran a script that generates all the possible combination of products from the different categories up to a quantity of 10 and inserted the generated rules in to the Zone Rates Shipping Table. Crude, yes I know and its limitations are obvious but it does work.

However, I have never been happy with this clumsy solution and have been wondering if there is a better alternative:

Maybe cloning a shipping module for each of the UK,European and RoW destinations and changing the code to detect which country the order is being shipped to and then be disabled/enable appropriately?

I came across this code to allow for the total shipping cost to be the sum of each of the cart's products' categories:

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

// i ignore free shipping items.. all items are priced not matter what.
//$total_count = $total_count - $_SESSION['cart']->free_shipping_items();

// each array item is another array consisting of the product name, it's base shipping cost,
// the price of each extra unit shipped, and the IDs of each product in that price category.
$product_chart = array(
'smallmatted' => array(
'base' => 6,
'extra' => 1,
'ids' => array(1106, 1108, 1110, 1131, 1133, 1127, 1129)
),
'largematted' => array(
'base' => 7,
'extra' => 1,
'ids' => array(1107, 1109, 1111, 1128, 1132, 1134, 1130)
),
'canvasrolled' => array(
'base' => 8,
'extra' => 1,
'ids' => array(1135, 1137, 1140, 1142, 1143, 1146, 1148, 1150, 1152)
),
'smallframed' => array(
'base' => 24,
'extra' => 4,
'ids' => array(191, 192, 193, 194, 195, 196, 197, 198, 188, 189, 190, 1151, 1147)
),
'mediumframed' => array(
'base' => 45,
'extra' => 5,
'ids' => array(1136, 1141, 1147)
),
'largeframed' => array(
'base' => 75,
'extra' => 10,
'ids' => array(1138, 1139, 1144, 1145, 1149)
);

$cost = 0;

// calculate the cost based on quantity
foreach ($order->products as $product) {
$product_id = explode(':', $product['id']);
$product_id = $product_id[0];

foreach ($product_chart as $product_type => $product_details) {
if (in_array($product['id'], $product_details['ids'])) {
$qty = $product['qty'];
$cost += $product_details['base'] + $product_details['extra'] * ($qty - 1);
}
}
}

$this->quotes = array(
'id' => $this->code,
'module' => 'Shipping',
'methods' => array(
array(
'id' => $this->code,
'title' => MODULE_SHIPPING_MINE_TEXT_WAY,
'cost' => $cost
)
)
); 

This accommodates a lot of my needs, but does not offer the ability to have different prices according to the final destination.

Which variables or constants do I need to reference to detect the destination country and compare to a list of countries?

Each category needs a base shipping price and a price for additional products. (e.g. 1 item from category A costs £2.50 to ship, each additional item a further 0.50p) and these costs need to differ according to the destination.

Am I over-complicating this? Any advice/solutions would be much appreciated.

1 May 2011, 2:05 PM
#356
oqcq avatar

oqcq

New Zenner

Join Date:
Apr 2011
Posts:
3
Plugin Contributions:
0

Re: Different shipping methods for different categories

I came up with a solution -

I had to strip out the cloned shipping module and create a new code that:

Defined base and additional prices for each category depending upon shipping destination.

Found the product in cart with highest base price.

Upon that base price, added only the 'additional * qty' prices for every other item in the cart.

It is behaving how I wanted, the only draw-back being that the shipping module config in zencart admin has no effect as the new shipping module has been effectively hard coded.

Thanks

4 May 2011, 2:49 AM
#357
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Re: Different shipping methods for different categories

I was able to solve one of my problems so I'm sharing the code I came up with here in case someone is having the same problem I'm having.

I'm using the USPS module and the Insurance Optional module. In one of my stores I offer free shipping over $65 up to $200 (at $200 the insurance optional kicks in as that's where minimum wholesale orders start). The problem is for whatever reason ot_insurance.php calculates and charges shipping regardless of the my selection of not charging insurance on free shipping and Amount Exempt From Fee. Quite annoying if you ask, having to explain my clients why am I charging insurance if I'm offering free shipping, makes no sense. Since I wasn't able to figure out how to solve the insurance optional mode I edited instead the USPS module. So my solution was to add an if statement to add insurance up to $200 directly on the usps.php module so any shipping charges will reflect the insurance cost already calculated based on the shopping cart subtotal.

locate

          $cost = preg_replace('/[^0-9.]/', '',  $cost);
          $methods[] = array('id' => $type,
                             'title' => $title,
                             'cost' => ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_USPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_USPS_HANDLING) );

        }

and change for

          $cost = preg_replace('/[^0-9.]/', '',  $cost);
//MANUELA added to charge insurance up to 200 due to the problem with insurance optional module
            if ($order->info['subtotal'] <= 50) {
            $insurance_charge = 1.80; 
            } elseif (50.01 - 100) {
            $insurance_charge = 0.50;
            } elseif (100.01 - 200) {
            $insurance_charge = 0.55;
            }
          $methods[] = array('id' => $type,
                             'title' => $title,
                             'cost' => ($cost * $shipping_num_boxes) + $insurance_charge + (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_USPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_USPS_HANDLING) );

        }

I don't know much of PHP, but it works for what I need.

This change charges $1.80 insurance fee for orders subtotaling $50 or less, $0.50 for orders subtotaling 50.01 - 100, which makes the current $2.30 mark for insurance and $0.55 more for orders subtotaling 100.01 - 200, for the $2.85 mark up to $200. After $200 the insurance optional module kicks in and does the rest.

For now it works, until I find a better solution for my predicament.

If anyone can improve the code, please do so and post the changes so we can all benefit.

Hope this helps someone else! :smile:

M.Valenti
Contemporary Artist - Entrepreneur
http://www.manuelavalenti.com - http://www.byvalenti.com

18 May 2011, 4:57 AM
#358
jilk avatar

jilk

New Zenner

Join Date:
May 2009
Posts:
7
Plugin Contributions:
0

Re: Different shipping methods for different categories

Hi,
I have been reading this lengthy thread for 2 days now but can't find what I need. Can someone help?

In my store I have:

1. Tickets that can be purchased to an event
There is a $5 booking fee for these regardless of how many tickets are added to the cart. Tickets are all in the category "Tickets" (cat #20) within sub categories: cat #21, 22, 23. The $5 is to be applied when any of the products from cat #21 and/or 22 and/or 23 are in the cart. (ie. a flat $5 per order, not $5 per ticket).

2. DVD's
These must be posted and postage cost is $7 per DVD. DVD's are all in the category "DVDs" (cat #30) within sub categories (#31, 32, & 33).

3. Downloads
These are downloadable so do not incur a shipping fee. Downloads are all in the category "Downloads" (cat #40) within sub categories (cat #41,42)

So, for example, if a customer adds to their cart:

  • 2 x tickets (1 from cat #21 and 1 from cat #22)
  • 1 x DVD (from cat #32)
  • 2 x downloads (1 from cat #41 and 1 from cat #42)
    Then the total "shipping" cost will be $5 (ticket booking fee) and $7 (DVD postage) = $12.

Or - if a customer adds to their cart:

  • 1 x DVD (from cat #32)
  • 2 x downloads (1 from cat #41 and 1 from cat #42)
    Then the "shipping" cost will be $7 (DVD postage) only.

I have enabled the "Flat Rate" module for the booking fee but need to know how to limit this to apply ONLY when tickets are added to the cart.

I'm assuming that I can use the "Per Item" module for the DVD's and Downloads but need to know how to apply this only when products from those categories are in the cart.

Any help VERY MUCH APPRCIATED!!!!

18 May 2011, 1:11 PM
#359
ajeh avatar

ajeh

Oba-san

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

Re: Different shipping methods for different categories

If you only have DVDs and Tickets to calculate the charge on, you could customize the code in Flat Rate flat with:

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

global $cart;
$chk_dvd = 0;
$chk_dvd += $_SESSION['cart']->in_cart_check('master_categories_id','31');
$chk_dvd += $_SESSION['cart']->in_cart_check('master_categories_id','32');
$chk_dvd += $_SESSION['cart']->in_cart_check('master_categories_id','33');
$chk_dvd = $chk_dvd * 7.00;

$chk_tickets = 0;
$chk_tickets += $_SESSION['cart']->in_cart_check('master_categories_id','21');
$chk_tickets += $_SESSION['cart']->in_cart_check('master_categories_id','22');
$chk_tickets += $_SESSION['cart']->in_cart_check('master_categories_id','23');
$chk_tickets = ($chk_tickets > 0 ? 5.00 : 0.00);


$cost = $chk_dvd + $chk_tickets;
      $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' => MODULE_SHIPPING_FLAT_COST)));

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!

19 May 2011, 10:20 PM
#360
jilk avatar

jilk

New Zenner

Join Date:
May 2009
Posts:
7
Plugin Contributions:
0

Re: Different shipping methods for different categories

Thanks Linda, your help is appreciated.

My only problem is that, with your suggested code, if I ever enter another product into the DVD category, or if my DVD's have different postage costs (ie: boxed sets) then I would have to hardcode each postage value and category into flat.php, although I thank you for the suggestion - this won't work for me.

I guess what I'm after is a means of saying:

  1. If any tickets are present in the cart then add a flat $5.00 booking fee.
  2. If anything else is present in the cart then apply the postage cost for the individual product

I'm assuming that I can use the "flat" shipping module to cover the tickets and the "per item" shipping module to cover everything else. Just need to know how to apply one or both depending on what's present in the cart. I'll keep working on it!

Thanks