dimanche 22 février 2015

Echo different text if specific product is in cart or not

I have a problem with my checkout cart. I need to check out, if a particular product (with the ID 1) is already in the cart. If it is inside, I want to show Text 1. If it is NOT inside, I want to show Text 2.


Here is my code, I came so far until now:



<?php
$items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
$found = false;
foreach ($items as $item) {
if ($item->getProductId() == 1){
$found = true;
echo "Text 1";
break;
}
}
?>


Sorry for my bad english, I´m from Germany. Maybe anyone can help? Thank you


Aucun commentaire:

Enregistrer un commentaire