image - Magento product weight - custom picture -
i want have code in magento, following:
- gets product weight
- depending on weight displays custom png
for example: if weight under 3 kg, displays shipping_1.png if weight between 3-5 kg, displays shipping_2.png, etc..
i think got use $product->getweight(); instance, since i'm not programmer, not know how go on it.
can me snippet, start?
thank you!
i not know how want show weight images, doing show weight image on product page under price.
it little hard no programming knowledge, need configure yourself, such image file path.
firstly go folder:
app/design/frontend/{package}/{theme}/template/catalog/product
then find line :
<?php echo $this->gettierpricehtml() ?>
this code print out product price, should around line 60insert following code below price code line:
<?php /*add weight image on product page*/ $_weight = (float) $this->htmlescape( $_product->getweight() ); $weightimgpath = mage::getbaseurl(mage_core_model_store::url_type_media) . 'yourfoldername/'; $weightimg = 'shipping_'; if ( $_weight < 3 ) { $weightimg.'1'; } else if( $_weight >= 3 && $_weight <= 5 ) { $weightimg.'2'; } else { $weightimg.'3'; } echo '<span>shippment : <img src="' . $weightimgpath . $weightimg . '.png" /></span>'; ?>
here picture of code insert in clean magento view.phtml file:
few things remind:
you should find web developer maintain or develop website, @ least save time.
you should make weight images in 1 size, otherwise website weird.
you might configure put weight images, other condition show weight image , text of 'shippment :'
good luck!
Comments
Post a Comment