简体   繁体   中英

How to check virtuemart cart empty or not

i have one question that check the virtue-mart cart, if cart is empty then page redirected to the my link such as contact page,article.

for example customer click the "order now" button but cart is empty then redirect to contact page

please help me

Try this,

$cart = VirtueMartCart::getCart();
if(sizeof($cart->products) > 0){
 echo 'Cart have products';
}
else{
 echo 'Your cart is empty';
}

for redirections you can use follows

$mainframe = JFactory::getApplication();
$mainframe->redirect('url','message','message type');//message type is message,warning,error etc

Hope its helps..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM