X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   If statement checking for items in cart (https://forum.x-cart.com/showthread.php?t=20795)

mmoskva 03-28-2006 09:29 PM

If statement checking for items in cart
 
I would like to display a shipping message only after an item is added is the the cart; So the message will not appear is their are no items in the cart.

Does someone know the the IF statement that checks the cart to see if their are items in the cart?

Jon 03-28-2006 11:15 PM

You can use:

Code:

{if $minicart_total_items > 0}There are items in the cart

DanUK 03-28-2006 11:38 PM

Is there also a statement along the same lines to check for a particular item in the cart?

Dan

Jon 03-28-2006 11:45 PM

^ No, I believe that would need to be done in the PHP code anywhere except cart.php

mmoskva 03-29-2006 06:12 AM

thanks

anthony 10-04-2006 09:36 AM

Re: If statement checking for items in cart
 
Quote:

Originally Posted by DanUK
Is there also a statement along the same lines to check for a particular item in the cart?



I looked all over for this recently and then ended up just coding it myself in products.tpl. Should be a similar process for any other page. For the curious:

4.1.3

products.php

before

Code:

$smarty->assign("products",$products);

add
Code:

x_load('cart');
require $xcart_dir."/include/cart_process.php";
x_session_register("cart");
$cartprods = func_products_in_cart($cart, $membershipid);

foreach($cartprods as $product){
        $prodids[$product['productid']] = 'Y';
}
$smarty->assign("cartprods",$prodids);


then in products.tpl

Code:

{assign var="pid" value=$products[product].productid}
{if $cartprods[$pid] eq "Y"}
...
{else}
...
{/if}



hope that helps.


All times are GMT -8. The time now is 07:18 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.