0

I want to add a 'free shipping' image to product pages (where products qualify for free shipping). What is the best way to go about this?

I have a good understanding of theming Magento but am still coming to terms with developing extensions for it. I had hoped that I'd be able to get a products raw price and have a basic if statement like below:

if($product_price > 75.00)
    echo "<img src="free-shipping.png" />";

But the product price calculations are all hidden away inside their own classes/module and I was hoping to be able to do this purely from my theme template files.

  1. Can it be done this way (if so, how)?
  2. How would I go about creating a module to do this - I understand how to create a basic module (file structure and registering it in the Magento system) but I think I'm going to get completely lost when I try and interact with the database - I'm reading through Alan Storm's very comprehensive Magento development tutorials, but it's taking some time. :-)

Thanks.

P.s - I'm running the latest version of Magento CE.

Anonymous
  • 6,181
  • 7
  • 45
  • 72
  • Under which circumstances do you offer free shipping? Does it depend on total cart value or on a specific product price (like above)? Is free shipping only available for this very product or for the wohle shipment? Do you use a shopping cart price rule or do you use the shipping method "free shipping"? – Matthias Zeis Dec 30 '11 at 10:56
  • Good point. We offer free shipping for orders over £75, so just as an extra selling point on every product page where the item value is over £75 I'm putting a free shipping graphic next to my add-to-cart button. Of course customers will still receive free shipping if they buy 3 x £40 items for example, but I think just displaying it on the product page of all those products with at least the free-shipping threshold value definitely can't hurt. – Anonymous Dec 30 '11 at 11:22

1 Answers1

2

I think you could achieve your goal, by only customizing product page template.

For a good introduction to Magento code, see this answer : How does Magento code work?.

I think the minimal file you can edit is :

app/design/frontend/{package}/{theme}/template/catalog/product/view.phtml

At the top, we can see the product is retrieved with $_product = $this->getProduct();, so all along that file, you may access the product price ($_product->getPrice();). There are also other child content blocks displayed on the page, choose the one you want.

Community
  • 1
  • 1
  • Thanks Vince, that was a lot easier than I thought it would be. I have a working solution now. Before, I was dealing with $this->getTierPriceHtml() as that's the part of the template that output my pricing html. Where is the getProduct class defined, so I can see what other models I can make use of are? – Anonymous Dec 30 '11 at 11:00
  • `getPrice()` is a method, you can access all attributes by calling `get` where `Attribute_code` has the first character upper case. –  Dec 30 '11 at 11:23