Some useful shippets for including customer account and a basic basket/cart product count in the header of Magento. This should be added to header.html in your template folder, athough the code will work anywhere in the Magento template system
Login and log out links
<ul> <?php if ($this->helper('customer')->isLoggedIn() ) { ?> <li><a href="/customer/account/logout/">Log out</a></li> <!-- <li><a href="/customer/account/create/">Register</a></li> --> <?php } else { ?> <li><a href="/customer/account/login/">Sign in</a></li> <li><a href="/customer/account/create/">Register</a></li> <?php } // logged in ?> </ul>
Simple code to dispay cart count
<ul> <?php $count = $this->helper('checkout/cart')->getSummaryCount(); //get total items in cart $total = $this->helper('checkout/cart')->getQuote()->getGrandTotal(); //get total price if($count>1) { echo $this->__('<li><a href="/checkout/cart"><strong>Basket (%s Items)</strong></a></li>',$count); } else if ($count==1) { echo $this->__('<li><a href="/checkout/cart"><strong>Basket (1 Item)</a></li></strong>',$count); } else { echo $this->__('<li><a href="/checkout/cart"><strong>Basket (0 Items)</strong></a></li>',$count); } ?> </ul>
My Magento Expertise
If you are planning a new e‑commerce store, considering a platform upgrade or looking for ongoing Magento support, I can provide the expertise you need. Based in Northern Ireland and working with clients locally and internationally, I deliver solutions that help businesses grow.
More Magento posts
—
Magento database structure
The database structure of Magento is designed to store and manage various aspects of an e-commerce website, including products, orders, customers, and more. Understanding the Magento database structure is crucial…
—
Accessibility in ecommerce websites
In the digital age, where online shopping has become an integral part of our lives, ecommerce websites hold the key to business success. Amidst the rush to create visually appealing…
—
Using Magento to get small businesses online
For small businesses aiming to establish a formidable online presence and drive sales, Magento emerges as a powerful e-commerce platform offering a suite of features tailored to their needs. Scalability…
Continue reading "Using Magento to get small businesses online"
—
How can I speed-up my Magento website?
Speed optimisation is crucial for a Magento website as it directly impacts user experience, conversions, and search engine rankings. You should prepare your server so it is set-up to use…