Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

If statement checking for items in cart

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 03-28-2006, 09:29 PM
 
mmoskva mmoskva is offline
 

eXpert
  
Join Date: Aug 2005
Location: Pennsylvania
Posts: 306
 

Default 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?
__________________
x-cart 4.0.16v
linux server
Reply With Quote
  #2  
Old 03-28-2006, 11:15 PM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,200
 

Default

You can use:

Code:
{if $minicart_total_items > 0}There are items in the cart
Reply With Quote
  #3  
Old 03-28-2006, 11:38 PM
 
DanUK DanUK is offline
 

X-Adept
  
Join Date: Dec 2003
Location: UK
Posts: 800
 

Default

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

Dan
__________________
4.4.2

and

4.6.1
Reply With Quote
  #4  
Old 03-28-2006, 11:45 PM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,200
 

Default

^ No, I believe that would need to be done in the PHP code anywhere except cart.php
Reply With Quote
  #5  
Old 03-29-2006, 06:12 AM
 
mmoskva mmoskva is offline
 

eXpert
  
Join Date: Aug 2005
Location: Pennsylvania
Posts: 306
 

Default

thanks
__________________
x-cart 4.0.16v
linux server
Reply With Quote
  #6  
Old 10-04-2006, 09:36 AM
 
anthony anthony is offline
 

Newbie
  
Join Date: Aug 2005
Posts: 3
 

Default 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.
__________________
anthony
www.pointbweb.com
4.1.3
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 08:14 AM.

   

 
X-Cart forums © 2001-2020