Misa Amane Posted June 7, 2016 Share Posted June 7, 2016 Hello all, I set a specific price for a category of product. How can i display this date in the categories pages ( in file product-list.tpl) ? I tried to get the date from 1 product with {$product->specificPrice['to']} but it didn't work. Link to comment Share on other sites More sharing options...
erouvier29 Posted June 7, 2016 Share Posted June 7, 2016 (edited) smarty syntax: $product->specificPrice.to Edited June 7, 2016 by erouvier29 (see edit history) Link to comment Share on other sites More sharing options...
Misa Amane Posted June 7, 2016 Author Share Posted June 7, 2016 I tried it too but it didn't work, in the file product-list.tpt the object product hasn't specificPrice Link to comment Share on other sites More sharing options...
erouvier29 Posted June 8, 2016 Share Posted June 8, 2016 Sorry, that was for product.tpl. In product-list.tpl, use $product.specific_prices.to, e.g. <span>{$product.specific_prices.to|date_format:"%d/%m/%Y"}</span> 1 Link to comment Share on other sites More sharing options...
Misa Amane Posted June 8, 2016 Author Share Posted June 8, 2016 (edited) It works, thank you. Is there any way to convert this date in duration. For example : 4 days left rather that 12/06/2016 edit : It's okey, i succeed with JQuery Edited June 8, 2016 by guillaume hammouti (see edit history) Link to comment Share on other sites More sharing options...
erouvier29 Posted June 8, 2016 Share Posted June 8, 2016 (edited) In that case, I would rather compute the number of days left within the CategoryController. E.g. from line 240 in PS 1.6.1.5: // ADD THIS... $now = time(); foreach ($this->cat_products as &$product) { if (isset($product['id_product_attribute']) && $product['id_product_attribute'] && isset($product['product_attribute_minimal_quantity'])) { $product['minimal_quantity'] = $product['product_attribute_minimal_quantity']; } // ... AND THAT if (isset($product['specific_prices'])) { $product['specific_prices']['days_left'] = ceil((strtotime($product['specific_prices']['to']) - $now)/86400); } } Then use {$product.specific_prices.days_left} in product-list.tpl [EDIT] Oops, sorry again, I didn't see your edit... Edited June 8, 2016 by erouvier29 (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