Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / Customizing the Look of Your Shop / Templates, Stylesheets, Page Layout / How can I restrict shipping choices based on kinds of products in the cart?

How can I restrict shipping choices based on kinds of products in the cart?

Locked
This thread is locked. New replies are disabled.
13 Sep 2009, 5:53 PM
#1
bladerogers avatar

bladerogers

New Zenner

Join Date:
Sep 2009
Posts:
18
Plugin Contributions:
0

Post #1 by bladerogers

OK, not sure if this is in the right topic, but hope I get some help here. I am attempting to modify the logic of the shopping cart shipping information. On a per product basis I have modified the products table to include two new boolean fields, one for canada post and one for UPS. When the user checksout I wish to check all cart items to see if which methods of shipping pertain to each and present to the user true totals as some of their orders may be split shipping (case in point, Canada Post will not ship Ammunition, only UPS will...user has 3 ammunition products in cart and another item that can go either or...we need to give the user the option to split this up). Anyhow, I'll deal with that later...for now my issue is this. I find tracking down the functions and methods somewhat difficult in Zen. Right now I am trying to determine what array element names exist in the array $product (foreach ($productArray as $product) ) which is used in the tpl_shoppingcartdefault file. Attempting to output array elements by key position does nothing $product[6] for instance). I've determined through a count that their are 19 positions in the array, but I need to know how to acccess each without knowing their element reference names!! I need the productid for each item in the array, and of course productid, product_id and the obvious don't seem to exist. In what file is the Session variable 'cart' created?? I can't seem to find that in the obvious places. Also, does there exist a dev manual for zen cart? Is there a way to view all current session variables at any given time, like a session var page??

13 Sep 2009, 6:11 PM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Post #2 by kobra

Rather than reinvent the wheel...from your basic description there is a commercial module for "per item" shipping that has been reported to be highly versatile. You might open a dialog with them.
PM me for reference.
As to the rest, one of the Dev's will have to fill you in on the session programming.

Zen-Venom Get Bitten

13 Sep 2009, 6:23 PM
#3
bladerogers avatar

bladerogers

New Zenner

Join Date:
Sep 2009
Posts:
18
Plugin Contributions:
0

Post #3 by bladerogers

Absolutly! If this already exists, please point me in the direction of the mod! I looked high and low and couldn't find anything that fit the bill, but perhaps I missed this. thanks! :)

13 Sep 2009, 6:33 PM
#4
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Post #4 by kobra

PM me
Being commercial, forum guidlines prefer this privately

Zen-Venom Get Bitten

13 Sep 2009, 6:34 PM
#5
bladerogers avatar

bladerogers

New Zenner

Join Date:
Sep 2009
Posts:
18
Plugin Contributions:
0

Post #5 by bladerogers

Please understand, I am not looking for a modification to charge shipping on a per item basis, but to determine what shipping options are available for each item. Currently there are only two shipping options we use, CP and UPS. In each cart upon checkout we will check the cart and determine shipping using one method including all items that can be shipped using method A only and method A and B, and also determine cost of shipping for those items marked only B and A and B. We will still be using CP and UPS modules to determine actual shipping costs. The shipping on a per-item bases is cost per item, at least that is the only module I could find. THis is different...are you referring to another one that would work in this case?

Thanks!

13 Sep 2009, 8:36 PM
#6
bladerogers avatar

bladerogers

New Zenner

Join Date:
Sep 2009
Posts:
18
Plugin Contributions:
0

Post #6 by bladerogers

Kobra, thanks for the direction, but that particular module does not do what we require. I do think I'll have to move forward with a custom modification. I need to be able to view current session items, will look into that.

13 Sep 2009, 9:02 PM
#7
bladerogers avatar

bladerogers

New Zenner

Join Date:
Sep 2009
Posts:
18
Plugin Contributions:
0

Post #7 by bladerogers

found the API, got a good start

$CartProductIDs = $_SESSION['cart']->get_product_id_list(); returns comma sep product ids. I'll take it from there. Not sure how I didn't stumble on that API up until now.

Thanks all!

13 Sep 2009, 9:10 PM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #8 by drbyte

http://www.zen-cart.com/forum/showpost.php?p=527844&postcount=5
http://www.zen-cart.com/forum/showpost.php?p=527997&postcount=9
These 2 posts discuss something akin to the following code, which is inserted into the constructor method of each of the shipping modules you want restrictions to occur in.
Basically this example looks up the "products_model" field from the data in the products in the cart, to check for certain match combinations, and enables the module if those are found.
You could do similarly using something like the products_id field and disabling the module instead (with false instead of true):

	  if (IS_ADMIN_FLAG == false) {
           if ($_SESSION['cart']->in_cart_check('products_model','NAV') > 4) && $_SESSION['cart']->in_cart_check('products_model','MP') > 0) ) {
	    $this->enabled = true;
	  }

Other semi-related discussions:
http://www.zen-cart.com/forum/showthread.php?p=781104#post781104
http://www.zen-cart.com/forum/showthread.php?t=133190
http://www.zen-cart.com/forum/showthread.php?t=126162

(Or you could use the get_products() or get_product_id_list() methods and do your own looping instead.)

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

14 Sep 2009, 2:51 AM
#9
bladerogers avatar

bladerogers

New Zenner

Join Date:
Sep 2009
Posts:
18
Plugin Contributions:
0

Post #9 by bladerogers

Thanks DrByte, definitely that helps me!