Magento – Sales Tax Rates and Defaults

This is a tiny little post because I was a bit confused about why my Magento store would be showing sales tax to my visitor before it knew the shipping destination!

To set rates and locations and all that good stuff, there’s a good page in the Magento forum here.

There’s also a little sneaky configuration thing I missed which is in the System Configuration. There, under the Sales section, is a module called Tax. Under Tax we find “Default Tax Origin Calculation,” which is a bit of a misnomer, I think. Unless someone can explain it better to me, this is actually a Default Tax Destination Calculation.

When this is filled in, your customers see this tax rate in the basket. The actual tax isn’t applied until we know where we’re shipping. In our case, we really didn’t want to see any tax until we knew for sure where the order was being shipped.

Hope this helps. If no one else, future me will likely be helped by having noted this!

Magento – disable sidebar cart, tags and newsletter

Magento is a really wonderful commerce package and I look forward to its continued improvement. 

The site I’m building does not wish to display the “Newsletter,” “Tags,” or the “My Cart” sidebar. Just as I was getting ready to delve into my templates, I thought better of it and Google’d and sure enough: it’s a lot easier than that.

From your admin panel, simply go to System->Advanced. There you’ll find a wealth of advanced features you can enable or disable. In my case, I disabled:

  • Mage_Newsletter: this shows the newsletter subscription box. I disabled it because we’re not ready to do anything with it yet.
  • Mage_Tag: the tagging feature is slick, but until we have a strategy to make it useful, I’d just as soon disable it for the time being.

Now, to not display the shopping card sidebar, I had to go somewhere else. From System->Advanced, select Checkout (it’s under the Sales heading). Shopping Cart Sidebar is a Yes/ No drop Down.

The way my brain works, I would have expected the side cart display feature to be in the same place as the Newsletter and Tag features. As I wrote this, I’d (successfully) disabled the cart and went on a hunt to find the newsletter and tag features. By then I’d completely forgotten where the darn switch was for the My Cart sidebar!

And thus we blog.

Magento – display SKU on product listing page

In list.phtml, I want to be able to see the SKU in the product listing. list.phtml is a simple if a tad large “if-else” construct, the first part of the if being list view, the else part being the grid view. So, if you want it in both places, you’ll have to hit 2 spots. list.phtml is found in app/design/frontend/pathToYourTheme/template/catalog/product.

On this particular project, SKU is very important. We mail out several catalogs to various verticals, and some people don’t know anything but the SKU when they’re ordering.

My theme is based on default. Your actual line numbers may vary, but here’s the context for list view, the “if” of our template:


55 <?php // Product description ?>
56 <div class="product-shop">
57 <h5><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->htmlEscape($_product->getName())?></a></h5>
58 <?php echo $this->htmlEscape($_product->getSku()); ?>
59 <?php if($_product->getRatingSummary()): ?>
60 <?php echo $this->getReviewsSummaryHtml($_product) ?>
61 <?php endif; ?>

Grid view is the “else” of this section, it’s down a little further in list.phtml:


102 <h5><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><? php echo $this->htmlEscape($_product->getName()) ?></a></h5>
103 <?php echo $this->htmlEscape($_product->getSku()); ?>
104 <?php if($_product->getRatingSummary()): ?>
105 <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
106 <?php endif; ?>

And that’s it! You’ll have a nice display of your SKU.

Magento – display SKU on product page

Magento’s default theme doesn’t display the SKU on the product page (at least as of v1.1.6). As per this discussion thread, it’s fairly easy to add by editing the template:

In whichever theme you’re using, in the file template/catalog/product/view.phtml, add the line:

<?php echo $this->htmlEscape($_product->getSku()) ?>

Here’s a few lines of my view.phtml to give you some context:

40
41
42
43
44
45
46
47
48
49
50
51
<div class="product-essential">
<form action="<?php echo $this->getAddToCartUrl($_product) ?>" method="post" id="product_addtocart_form">
 
     <div class="product-img-box">
         <?php echo $this->getChildHtml('media') ?>
     </div>
 
     <div class="product-shop">
         <h3 class="product-name"><?php echo $this->htmlEscape($_product->getName()) ?></h3>
         <?php echo $this->htmlEscape($_product->getSku()) ?>
 
         <?php if ($this->canEmailToFriend()): ?>

We are also reminded in the Magento thread that we should not use the default theme in place, as it’s subject to changes from release to release. Instead, you should create a copy of the default theme (if that’s what you want to start with), and work with that. See also: http://www.magentocommerce.com/design_guide/articles/working-with-magento-themes#head-how-to-create-a-theme