Zen_j1 Posted January 14, 2014 Share Posted January 14, 2014 (edited) I have added a code to product_list.tpl pasted below which I found on one of the post at prestashop forum which work perfect to display price before discount and discount percentage for default attribute. Now I have bought attribute module from prestashop store so customer can change attribute on product list page. Now my issue is the code display discount for first attribute (default) but does not change other attribute. I have seen on product page discount price changes per attribute. I would also like to bring to your attention price after discount is changed as per attribute it just price before discount is not changing I need your help to know what code should be added to code I have in product_list.tpl (given below) or copied from product.tpl since I know code in product.tpl is making it work. I have also attached a screen shot with the post to explain my situation more clearly. I kindly request you all to take a look at screen shot. I am using prestashop 1.5.4.1 Code:- {if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}<span class="price" style="display: inline;">{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</span><br />{/if} {if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}<span class="availability">{if ($product.allow_oosp || $product.quantity > 0)}{l s='Available'}{elseif (isset($product.quantity_all_versions) && $product.quantity_all_versions > 0)}{l s='Product available with different options'}{else}{l s='Sold Out'}{/if}</span>{/if} {if $product.price_without_reduction gt $product.price} {if $product.specific_prices}{assign var='pro_specific_prices' value=$product.specific_prices} {if $pro_specific_prices.reduction_type eq 'percentage' && ($pro_specific_prices.from eq $pro_specific_prices.to OR ($smarty.now|date_format:'%Y-%m-%d %H:%M:%S' <= $pro_specific_prices.to && $smarty.now|date_format:'%Y-%m-%d %H:%M:%S' >= $pro_specific_prices.from))} <span class="price-discount">{if !$priceDisplay}{displayWtPrice p=$product.price_without_reduction}{else}{displayWtPrice p=((($product.price_without_reduction) / (1 + ((($product.rate|intval) / 100)|floatval)))|floatval)}{/if}</span> <span class="price_list_reduction"> (-{$pro_specific_prices.reduction * 100|floatval}%) </span> {/if} {/if} {/if} Edited January 14, 2014 by kartik_jh1 (see edit history) Link to comment Share on other sites More sharing options...
PascalVG Posted January 14, 2014 Share Posted January 14, 2014 Hi Kartik, do you have an URL of your site? Then we can play with it a little.... Link to comment Share on other sites More sharing options...
Zen_j1 Posted January 14, 2014 Author Share Posted January 14, 2014 (edited) Hi , do you have an URL of your site? Then we can play with it a little.... Edited February 11, 2014 by Zen_j1 (see edit history) Link to comment Share on other sites More sharing options...
PascalVG Posted January 14, 2014 Share Posted January 14, 2014 Kartik, in the module you bought, the value of final price is modified (probably using ajax) We have to add the code to change the original price variable as well. To help you, maybe you can Email me the original module, so I can have a look at it where/what to edit. (I will throw it away when finished)? Email: [email protected] What PrestaShop version do you use?? Let me know if you like this. pascal Link to comment Share on other sites More sharing options...
Zen_j1 Posted January 14, 2014 Author Share Posted January 14, 2014 (edited) in the module you bought, the value of final price is modified (probably using ajax) We have to add the code to change the original price variable as well. To help you, maybe you can Email me the original module, so I can have a look at it where/what to edit. (I will throw it away when finished)? Email: [email protected] What PrestaShop version do you use?? Let me know if you like this. pascal Thanks for offering me help. Since this is a paid module which i think does not fall under Open source software I will NOT be able send it thru email. Please note its not that i do not trust you but i have to respect rights of original developer also. I am sure there should be a way to solve this by adding code to product_list.tpl I am not able to resolve this by myself as i am not a programmer. I am using prestashop 1.5.4.1 Edited February 11, 2014 by Zen_j1 (see edit history) Link to comment Share on other sites More sharing options...
Zen_j1 Posted January 18, 2014 Author Share Posted January 18, 2014 (edited) This module has two main file one is PHP and another is javascript . Since I cannot send module to anyone or paste entire code here. I am pasting only price section code of both file which I think pulls price as per attribute. Can anyone help me to resolve this issue with this information. PHP code:- foreach($attributes AS $k=>&$attribute){ $ipa=$attribute['id_product_attribute']; if(!isset($prices[$ipa])){ $prices[$ipa]=Tools::displayPrice(Product::getPriceStatic($id_product, Product::$_taxCalculationMethod==PS_TAX_INC, $ipa)); } $attribute['price']=$prices[$ipa]; $attribute['image']=""; if($this->settings['changeimgattr']['v'] && isset($images[$ipa])){ $attribute['image']=$link->getImageLink($product->link_rewrite[$cookie->id_lang], $product->id.'-'.$images[$ipa][0]['id_image'], $this->settings['pimgsize']['v']); } } JavaScript:- if(s){ $("[rel=ajax_id_product_"+idp+"]").parent().find('span.price').html(s.price); if(s.image!=''){ $("[rel=ajax_id_product_"+idp+"]").closest("li").find('.product_img_link img').attr('src', s.image); } Edited January 18, 2014 by kartik_jh1 (see edit history) Link to comment Share on other sites More sharing options...
ibndawood Posted January 18, 2014 Share Posted January 18, 2014 Hello Karthik, I can give you directions. Product Price Discount is calculated in product.js file Each product will be initialized to a javascript variable called productPriceWithoutReduction it is this variable that is being manipulated on selecting the attribute. The javascript function that does all the price calculation is updateDisplay function in product.js file. updateDisplay function has the functionality to update the discount price on changing the attribute. You can study the function and include the code in your file. Hope this helps. 1 Link to comment Share on other sites More sharing options...
Zen_j1 Posted January 18, 2014 Author Share Posted January 18, 2014 Hello Karthik, I can give you directions. Product Price Discount is calculated in product.js file Each product will be initialized to a javascript variable called productPriceWithoutReduction it is this variable that is being manipulated on selecting the attribute. The javascript function that does all the price calculation is updateDisplay function in product.js file. updateDisplay function has the functionality to update the discount price on changing the attribute. You can study the function and include the code in your file. Hope this helps. Thanks for helping me getting started. I will look into code of product.js and of module file try to make this work. Your information is important for me as i am not programmer but i can try editing the code. Link to comment Share on other sites More sharing options...
Recommended Posts