sportstolen Posted October 22, 2012 Posted October 22, 2012 Hi! I´m trying to make a nice cart in header... What i want is, When cart is empty, echo your cart is empty. When there are 1-3 items in cart it will echo like " 1x dvd movie" But, here comes the trickt part, when there is more than 3 items in cart it should output the 3 items and echo beneath "You got x more items in your cart, where x are the number of items that are in the cart but not showing Here is som code i have come up with.. This will be a nice addon if i only get som help :) <table width="100%"> <tr> <td> <div class="cart_header">Shopping cart </div> </td></tr> <tr> <td> <div class="cart_listing3"> <?php $number_of_unique_products = $cart->cart_size(); $products = $cart->get_products(); if ($cart->count_contents() > 0) { for ($i=0, $n=sizeof($products); $i<$n; $i++) { $j = count($products); if ($i == 3) { break;} ?> <?php if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) { echo '<div class="cart_listing_image">'.tep_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], 16, 16, false, 5).'</div><div class="newItemInCart">'.$products[$i]['quantity']. ' x '. substr($products[$i]['name'], 0, 35),'</div>'; } else { echo '<div class="cart_listing_image">'.tep_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], 16, 16, false, 5).'</div><div class="cartwrap">'.$products[$i]['quantity']. ' x '. substr($products[$i]['name'], 0, 35),'</div>'; } if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) { tep_session_unregister('new_products_id_in_cart'); } ?><?php } } else { echo 'your cart is empty'; } ?> </div> </td></tr> <tr> <td> <?php if ($cart->cart_size() > 3) {?> <div><?php echo 'you got x more items in your cart'?></div> <?php } ?> </td></tr> </table>
Recommended Posts
Archived
This topic is now archived and is closed to further replies.