Prestashop – Show Product Combination / Attributes With Prices on product page

Recently i found that prestashop do not add product prices with combination on product page like magento do, Its a good idea, sometime magento custom options look weired, but sometime its necessary in certain instances.

There is a nice work around by a guy in prestashop forum, i am making it working and some better clear instruction to integrate prestashop attribute / combination with its price on product page.

 

First, you need to edit two files,

(1)/controllers/front/ProductController.php

Version 1.5.5.0 try to find line around 418 as

$groups[$row['id_attribute_group']]['attributes'][$row['id_attribute']] = $row['attribute_name'];

Add : [Do not REPLACE YOU NEED TO ADD]

$groups[$row['id_attribute_group']]['name_price'][$row['id_attribute']] = array('name' => $row['attribute_name'],'price' => $row['price']);

 

(2)/themes/YOUR_THEME/product.tpl

try to search RADIO and you will find something like

{elseif ($group.group_type == 'radio')}

after that line replace FOLLOWING Codes which start with

{foreach} to {/foreach}

please note they are opening and closing tags for smary php template. YOU NEED TO REPLACE WITH THIS CODE :

{foreach from=$group.name_price key=id_attribute item=group_attribute}
<ul>
<li>
<input type="radio" class="attribute_radio" name="{$groupName}" value="{$id_attribute}" {if ($group.default == $id_attribute)} checked="checked"{/if} onclick="findCombination();getProductAttribute();" > <span>{$group_attribute.name|escape:'htmlall':'UTF-8'}</span> <span">{$currencySign|html_entity_decode:2:"UTF-8"} {$group_attribute.price}</span>
</li>
</ul>
{/foreach}

And you will be able to show attrubutes / combination price. NOW, if you got your desired output than okay but i found one issue is with DECIMALS there may be unnecessary decimals. so you can get ride with this code in PRODUCTCONTROLLER.php Instead of this code [FROM ABOVE TUTORIAL YOU MIGHT HAVE ADDED SO REPLACE WITH NEW BELOW CODE]:

$groups[$row['id_attribute_group']]['name_price'][$row['id_attribute']] = array('name' => $row['attribute_name'],'price' => $row['price']);

ADD THIS NEW CODE

$groups[$row['id_attribute_group']]['name_price'][$row['id_attribute']] = array('name' => $row['attribute_name'],'price' => number_format($row['price'],2));

READ ABOVE CODE at the end there is DECIMALS SETTINGS,

number_format($row['price'],2));

where 2 shows 2 decimals so those found problem with DECIMALS CAN easily edit it.