Forums / Built-in Shipping and Payment Modules / Shopping Cart: loop through products to turn off Flat Rate shipping for certain prods

Shopping Cart: loop through products to turn off Flat Rate shipping for certain prods

Views: 1,392

Results 1 to 3 of 3
22 Aug 2011, 2:24 AM
#1
bobcnj avatar

bobcnj

New Zenner

Join Date:
Nov 2009
Posts:
10
Plugin Contributions:
0

Shopping Cart: loop through products to turn off Flat Rate shipping for certain prods

Using ZenCart for selling tickets to events. I am creating a mod that will turn off the flat rate shipping module if an event is within 7 days of current date (I have a new column in products_description that holds the event date).

I am having a problem writing the loop in my function. Where are the shopping cart product ids kept? Or put another way how do I access the items in the shopping cart - $cart is a global var but I cannot fund docs on it.

Any help getting the products_id out of the shopping cart from within a loop would be great.

30 Aug 2011, 3:28 AM
#2
bobcnj avatar

bobcnj

New Zenner

Join Date:
Nov 2009
Posts:
10
Plugin Contributions:
0

Re: Shopping Cart: loop through products to turn off Flat Rate shipping for certain prods

I may not have been clear in my previous post but I am stuck on this. Here is the code I am trying to get going.

function flat_option_valid() {
    global $order, $db;
    // for admin always true if installed
    if (strstr($PHP_SELF, FILENAME_MODULES)) {
      return true;
    }
   $products = $_SESSION['cart']->get_products();
   $check_flag = true;
    for ($i=0, $n=sizeof($products); $i<$n; $i++) {
	if ($products[$i]['STS_WillCallOnly'] == 1) {
		$check_flag = false;
		break;
	}
    }   
    return $check_flag;
  }

I have a new column called STS_WillCallOnly in product_description. I added that column to the get_products() function but cannot get the value in the loop.

This function simply returns false if product in the cart has this flag set to true.

I have tried getting $products[$i]['id'] but that does not bring back anything. The loop works - I go through once for each item in the shopping cart so I beleive I am on the right track.

30 Aug 2011, 1:38 PM
#3
ajeh avatar

ajeh

Oba-san

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

Re: Shopping Cart: loop through products to turn off Flat Rate shipping for certain prods

Where did you add your information in the shopping_cart class?

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!