sromain Posted July 15, 2013 Share Posted July 15, 2013 Hi, I would like to create a function that changes the price text on product page. All my products are rented by week but I have 20 products that are rented by day, that's why I want to create this function. Actually the price on my product page is display by this line of code : <span id="our_price_display" itemprop="price">{$productPrice|regex_replace:"/[\\{$currencySign}]/":""}€/week</span> I have created a category "day" and I would like that products which are on "day" category display this line of code : <span id="our_price_display" itemprop="price">{$productPrice|regex_replace:"/[\\{$currencySign}]/":""}€/day</span> I don’t know how to integrate this function in the code and if it is possible. If you could help me it would be nice Kind Regards, Romain Link to comment Share on other sites More sharing options...
sadlyblue Posted July 15, 2013 Share Posted July 15, 2013 (edited) Hi, Is the category_default for those product different than all the rest. If so you can use that to do what you want. Something like: {if $product->id_category_default != "id_of_category_day"}week{else}day{/if} then replace week with this. If the default is the same, then something else must be different (reference,...). Edited July 15, 2013 by sadlyblue (see edit history) Link to comment Share on other sites More sharing options...
sromain Posted July 15, 2013 Author Share Posted July 15, 2013 (edited) Yes I can put a different category_default for those products, I think I will use "day" category. If I add the line of code, I have an error. There are already 2 {if} in the code, do I have to replace it? Current code: {if $priceDisplay >= 0 && $priceDisplay <= 2} {if $currencyFormat == 1 || $currencyFormat == 3} <meta itemprop="priceCurrency" content="{$currency->iso_code}"/ ><span class="currency_price">{$currencySign}</span><span id="our_price_display" itemprop="price">{$productPrice|regex_replace:"/[\\{$currencySign}]/":""}</span> {else} <span id="our_price_display" itemprop="price">{$productPrice|regex_replace:"/[\\{$currencySign}]/":""}€/week</span> {/if} Edited July 15, 2013 by sromain (see edit history) Link to comment Share on other sites More sharing options...
sadlyblue Posted July 15, 2013 Share Posted July 15, 2013 just replace this line: <span id="our_price_display" itemprop="price">{$productPrice|regex_replace:"/[\\{$currencySign}]/":""}€/week</span> With this: <span id="our_price_display" itemprop="price">{$productPrice|regex_replace:"/[\\{$currencySign}]/":""}€/{if $product->id_category_default != "id_of_category_day"}week{else}day{/if}</span> And don't forget to replace id_of_category_day with the id of your category day. It should work, i just tested on my test site... Link to comment Share on other sites More sharing options...
sromain Posted July 15, 2013 Author Share Posted July 15, 2013 Yessssss!!! It works great Thank you so much sadlyblue. Kind regards, Romain Link to comment Share on other sites More sharing options...
vekia Posted July 15, 2013 Share Posted July 15, 2013 thanks for information that it works and for nice solution above works like a charm i marked this thread as [solved] regards Link to comment Share on other sites More sharing options...
sromain Posted July 15, 2013 Author Share Posted July 15, 2013 (edited) Hi SadlyBlue, I have tried the code on product-list page but it's not working. {if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}à partir de<br /><span class="price" style="display: inline;">{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}/{if $product->id_category_default != "49"}semaine{else}jour{/if}</span> {if isset($product.reduction) && $product.reduction} Do you think we can use this method for the product list-page? Regards, Romain Edited July 18, 2013 by sromain (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now