This IF has no purpose, at this time:
global $cart; is needed in each function ... but just 1 time per function ...Code:// check total weight if (IS_ADMIN_FLAG == false) { $chk_weight = $_SESSION['cart']->in_cart_check('products_weight','0'); }
This IF has no purpose, at this time:
global $cart; is needed in each function ... but just 1 time per function ...Code:// check total weight if (IS_ADMIN_FLAG == false) { $chk_weight = $_SESSION['cart']->in_cart_check('products_weight','0'); }
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: v1.5.5]
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!
I sure hope I'm not driving you crazy.....
Ok, I took that out of usps.php AND flat.php, and for now I'm working on Flat.
I feel like I'm onto something, but may have the parentheses wrong, something is wrong, but I'm starting to understand this a bit!
I realized I had to give flat.php more instructions so it will really know when to use it and when to not:
PHP Code:
global $cart;
// check for manufacturer id alchemy
if (IS_ADMIN_FLAG == false) {
$chk_manufacturer = $_SESSION['cart']->in_cart_check('manufacturers_id','1');
}
// disable if no alchemy products in cart
if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('manufacturers_id','1') == 0)) {
// hide FLAT
$this->enabled = false;
}
// disable if there are weighted products
if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_weight') > 0)) {
// hide FLAT
$this->enabled = false;
}
// enable if total product weight is 0 AND there are alchemy products
if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_weight') == 0)) && (('manufacturers_id','1') > 0)) {
// show FLAT
$this->enabled = true;
}
This one isn't doing anything and I think there is a unbalanced use of the parens:
Code:// enable if total product weight is 0 AND there are alchemy products if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_weight') == 0)) && (('manufacturers_id','1') > 0)) { // show FLAT $this->enabled = true; }
But the better way is to clean up all that code and condense it:
Code:global $cart; // check for manufacturer id alchemy if (IS_ADMIN_FLAG == false) { $chk_manufacturer = $_SESSION['cart']->in_cart_check('manufacturers_id','1'); $chk_products_weight = $_SESSION['cart']->show_weight(); } // enable if total product weight is 0 AND there are alchemy products if (IS_ADMIN_FLAG == false && $chk_products_weight == 0 && $chk_manufacturer > 0) { // show FLAT $this->enabled = true; } else { $this->enabled = false; }
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: v1.5.5]
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!
I finally made this work and thought I'd update in case others were needing to do the same thing. With what I'd done up to this point it wasn't working correctly, and I finally just simplified it and had both the USPS and FLAT modules check the total cart weight, if it's zero it uses flat, if it's more than zero it uses USPS. If USPS is being used, it checks for Alchemy products, and if there are any it adds my flat rate to the USPS.
Linda, thank you so much for sticking with me on this and helping me so much! I learned a lot!
Here's the code in case it helps someone else, my added code is in green...
In flat.php...
In usps.php....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 only when entire cart is free shipping if (zen_get_shipping_enabled($this->code)) { $this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false); } global $cart; // check total cart weight if (IS_ADMIN_FLAG == false) { $chk_products_weight = $_SESSION['cart']->show_weight(); } // enable if total product weight is 0 if (IS_ADMIN_FLAG == false && $chk_products_weight == 0) { // show FLAT $this->enabled = true; } else { // hide FLAT $this->enabled = false; }
Code:// disable only when entire cart is free shipping if (zen_get_shipping_enabled($this->code)) { $this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false); } global $cart; // check cart weight if (IS_ADMIN_FLAG == false) { $chk_products_weight = $_SESSION['cart']->show_weight(); } // enable if total product weight is more than zero if (IS_ADMIN_FLAG == false && $chk_products_weight > 0) { // show USPS $this->enabled = true; } else { $this->enabled = false; } // BOF: UPS USPS $this->quotes = array('id' => $this->code, 'module' => $this->title . $show_box_weight); // EOF: UPS USPS global $cart; //check if manufacturer alchemy is in cart if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('manufacturers_id','1') > 0)); { $manufacturer_alchemy = $_SESSION['cart']->in_cart_check('manufacturers_id','1'); $drop_ship_extra_charge = $manufacturer_alchemy; } // charge dropship fee for alchemy if ($drop_ship_extra_charge > 0) { $cat_extra_charge = 10; echo 'An additional $10 shipping fee for Alchemy items has been applied.'; } else { $cat_extra_charge = 0; }
Hi
I haven't had any luck posting around elsewhere, so I thought I'd try here.
I'd like to do something similar to the OP and what's been discussed here...
I've been playing with the codes on this thread, as you can see below, but haven't had any success getting them to work for me.
I want to get the cart to only show the Flat Rate shipping option when products from the manufacturers Excalibur and Greenpower are in the cart - otherwise show the Per Item option.PHP Code:
global $cart;
//check if manufacturer is in cart
if ((IS_ADMIN_FLAG == false &&
$_SESSION['cart']->in_cart_check('manufacturers_id','1','2') > 0)); {
$manufacturer_excalibur, $manufacturer_greenpower =
$_SESSION['cart']->in_cart_check('manufacturers_id','1','2');
}
// enable if manufacturer is in cart
if (IS_ADMIN_FLAG == false && $chk_manufacturers_id == 0) {
// show FLAT
$this->enabled = true;
} else {
// hide FLAT
$this->enabled = false;
}
I really have little idea how the coding works, so any help would be much appreciated.
Thanks in advance,
Tija
What happens if I have 1 Product from Excalibur and 2 Products from Greenpower and then 2 Products from other manufacturers_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: v1.5.5]
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!
To control the Flat Rate flat shipping module so that it only shows if ALL products in the cart are from manufacturers_id 1 or 2 you can use:
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); } // check if manufacturer 1 or 2 is in cart if (IS_ADMIN_FLAG == false) { global $cart; $chk_manufacturers_id1 = $_SESSION['cart']->in_cart_check('manufacturers_id', '1'); $chk_manufacturers_id2 = $_SESSION['cart']->in_cart_check('manufacturers_id', '2'); $chk_manufacturers_id = $chk_manufacturers_id1 + $chk_manufacturers_id2; if ($chk_manufacturers_id > 0) { $this->enabled = true; } else { $this->enabled = false; }
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: v1.5.5]
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!
Ah, OK - thanks for the reply and for cleaning that up :)
Most of my items are drop-shipped and remain a flat rate no matter how many a customer buys, and I subsidise the shipping when a customer buys products combined with drop-shipped products. So the shipping remains $15.
OK, so I tried the code, Linda... now both the shipping estimator and the admin shipping modules page aren't working.
I know I'm doing something wrong - I just have no idea what.
Any suggestions?
- Tija
Yeps ... add the missing closing bracket that I left out:
Code:// check if manufacturer 1 or 2 is in cart if (IS_ADMIN_FLAG == false) { global $cart; $chk_manufacturers_id1 = $_SESSION['cart']->in_cart_check('manufacturers_id', '1'); $chk_manufacturers_id2 = $_SESSION['cart']->in_cart_check('manufacturers_id', '2'); $chk_manufacturers_id = $chk_manufacturers_id1 + $chk_manufacturers_id2; if ($chk_manufacturers_id > 0) { $this->enabled = true; } else { $this->enabled = false; } }
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: v1.5.5]
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!
Bookmarks