mhmdshv Posted April 17, 2015 Share Posted April 17, 2015 Hi I'm trying to get total price of products in ajax block cart without any currencies, for example if the total price is 100$, i just want to get 100 Also i want to get the price of every product in the cart without currencies. I tried using this : {convertPrice price=$productPrice} but it doesn't work here. I changed it to: {convertPrice price=$product.price} but it still shows $ at the end of the price. Any ideas how to do this? Thanks are in orders. Link to comment Share on other sites More sharing options...
NemoPS Posted April 18, 2015 Share Posted April 18, 2015 I think you can either use the raw variable (product.price) or use a str_replace to get rid of the sign Link to comment Share on other sites More sharing options...
mhmdshv Posted April 19, 2015 Author Share Posted April 19, 2015 thanks nemo. product.price will return the price without any divisions, like 18000000, not 18,000,000. although its a solution, but is there any other way just to remove the $ sign? Link to comment Share on other sites More sharing options...
NemoPS Posted April 20, 2015 Share Posted April 20, 2015 Yes, as I mentioned, use "replace"http://www.smarty.net/docsv2/en/language.modifier.replace.tpl Link to comment Share on other sites More sharing options...
mhmdshv Posted April 20, 2015 Author Share Posted April 20, 2015 Yes, i used 'replace' to remove the $ sign from total price, here is what i did: {$total|replace:'$':''} But the product price has another syntax, which is unfamiliar to me, and there is a little about replace syntax in the guide. here is the syntax for individual products: {displayWtPrice p="`$product.total`"} can you give me any clues how to use replace in this please? i would be thankful. Link to comment Share on other sites More sharing options...
NemoPS Posted April 22, 2015 Share Posted April 22, 2015 try with {assign var=totalprice value={displayWtPrice p="`$product.total`"[spam-filter] then use the replace on totalprice Link to comment Share on other sites More sharing options...
conqueror Posted April 23, 2015 Share Posted April 23, 2015 Hi, I want to make product price without currency. But I didnt. Smarty replace not working. Example: Product price : 500,00 TL Varible: {convertPrice price=$productPrice|replace:' TL':''} But not change anything. How l can do? Link to comment Share on other sites More sharing options...
NemoPS Posted April 24, 2015 Share Posted April 24, 2015 You cannot use it like that, you need to apply it to the result variable as I stated in my last topic Link to comment Share on other sites More sharing options...
mhmdshv Posted April 27, 2015 Author Share Posted April 27, 2015 thank you nemo. as always, solved my problem. But now when i add a product to my cart, it will use ajax-cart.js to update the cart and then, the $ sign is back until i refresh the page. i checked the js file, and here is the command that puts the price into the cart: (parseFloat(this.price_float) > 0 ? this.priceByLine : freeProductTranslation) i wonder if u could give me a tip to make this return the price without the sign. thanks! Link to comment Share on other sites More sharing options...
mhmdshv Posted April 28, 2015 Author Share Posted April 28, 2015 thank you nemo. as always, solved my problem. But now when i add a product to my cart, it will use ajax-cart.js to update the cart and then, the $ sign is back until i refresh the page. i checked the js file, and here is the command that puts the price into the cart: (parseFloat(this.price_float) > 0 ? this.priceByLine : freeProductTranslation) i wonder if u could give me a tip to make this return the price without the sign. thanks! P.S: Never mind, i figured it out. i just needed to to replace "this.priceByLine" with "this.priceByLine.replace(/$/gi, "")". easy enough Link to comment Share on other sites More sharing options...
bedandw Posted June 29, 2016 Share Posted June 29, 2016 Using the latest product.tpl solves this problem Link to comment Share on other sites More sharing options...
Recommended Posts