Zen Cart Logo
Forums / General Questions / Conditional message on shopping cart page

Conditional message on shopping cart page

Locked

Views: 1,064

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
13 Nov 2010, 12:31 PM
#1
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Conditional message on shopping cart page

In one of my stores I have several products which can only be supplied if some conditions are being met.

It was necessary that a manufacturer specific message is being displayed on the shopping cart page if the cart contains a product from a given manufacturer.

I have only one manufacturer who requires one condition to be filled. That was easily solved by adding this to the tpl_shopping_cart_default.php page:

<!--bof prescriptive advice required alert --> <div> <?php global $cart; if ($_SESSION['cart']->in_cart_check('manufacturers_id','1')) { echo TEXT_PRESCRIPTIVE_ADVICE_REQUIRED; } //above returns true for prescriptive advice required ?> </div> <!--eof prescriptive advice required alert -->

If a customer adds a product made by the manufacturer with id=1 then the message (call it message A) shows just fine.

Then there are several other manufacturers who's requirements are different from manufacturer 1 but they are all of a common nature.

I managed to display a message different to the one applicable to manufacturer 1 if (per say) a product made by manufacturer 2 is added to the cart by modifying the code above with another id and another define.

But - and here is my problem - what if the cart contains a product from manufacturers 2, 3 and 4 (all with the same conditional message to be displayed - let's call it message B)?

Is it possible to put 2,3 and 4 into an array covering manufacturers 2,3 and 4 regardless of which product from these manufacturers is in the cart?

To top it off, if the cart contains something from manufacturer 1 and also something from manufacturer 2, 3 or 4 then only message A needs to be shown - message B would be obsolete.

I have been stuffing around with this idea for most of the day with varying results, but none of my attempts were satisfactory.

Any ideas or pointers please?

TIA

Frank

13 Nov 2010, 2:58 PM
#2
ajeh avatar

ajeh

Oba-san

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

Re: Conditional message on shopping cart page

Each has to be tested separately ...

So you could use something like:

<!--bof prescriptive advice two required alert -->
<div>
<?php
global $cart;
$chk_multi_manufacturers += $_SESSION['cart']->in_cart_check('manufacturers_id','2');
$chk_multi_manufacturers += $_SESSION['cart']->in_cart_check('manufacturers_id','3');
$chk_multi_manufacturers += $_SESSION['cart']->in_cart_check('manufacturers_id','4');
if ($chk_multi_manufacturers) {
echo TEXT_PRESCRIPTIVE_ADVICE_REQUIRED_TWO;
} //above returns true for prescriptive advice two required
?>
</div>
<!--eof prescriptive advice two required alert -->
13 Nov 2010, 5:19 PM
#3
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Conditional message on shopping cart page

To expand this to your other condition (message 2 not required if message 1 shown), you could do this```php

<!--bof prescriptive advice required alert --> <div> <?php global $cart; $chk_single_manufacturer = $_SESSION['cart']->in_cart_check('manufacturers_id','1'); $chk_multi_manufacturers += $_SESSION['cart']->in_cart_check('manufacturers_id','2'); $chk_multi_manufacturers += $_SESSION['cart']->in_cart_check('manufacturers_id','3'); $chk_multi_manufacturers += $_SESSION['cart']->in_cart_check('manufacturers_id','4'); if ($chk_single_manufacturer) { echo TEXT_PRESCRIPTIVE_ADVICE_REQUIRED_ONE; } elseif ($chk_multi_manufacturers) { echo TEXT_PRESCRIPTIVE_ADVICE_REQUIRED_TWO; } //above returns true for prescriptive advice two required ?> </div> <!--eof prescriptive advice required alert --> ```
13 Nov 2010, 9:57 PM
#4
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Conditional message on shopping cart page

Thanks to both of you.

I will have a crack at this later in the day and let you know how it panned out.

14 Nov 2010, 3:59 AM
#5
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Conditional message on shopping cart page

All configured and uploaded - works a treat :smile:

Thanks again Linda and Glenn