Rollaen Posted February 9, 2018 Share Posted February 9, 2018 (edited) Good day, I would like to display text "Free delivery" in a product-slider.tpl for products that already have Free delivery as a product tag. However I do not want to display all product tags. I tried this {if (isset($product->tags) && $product->tags)} {if in_array('Free delivery', $product->tags.1)} <p>Free delivery</p> {/if} {/if} nevertheless the code only works in product.tpl. I do not know how to display "Free delivery" in the product-slider.tpl file. Any advices are hearty welcome Edited February 9, 2018 by Rollaen (see edit history) Link to comment Share on other sites More sharing options...
joseantgv Posted February 12, 2018 Share Posted February 12, 2018 (edited) On 9/2/2018 at 12:39 PM, Rollaen said: Good day, I would like to display text "Free delivery" in a product-slider.tpl for products that already have Free delivery as a product tag. However I do not want to display all product tags. I tried this {if (isset($product->tags) && $product->tags)} {if in_array('Free delivery', $product->tags.1)} <p>Free delivery</p> {/if} {/if} nevertheless the code only works in product.tpl. I do not know how to display "Free delivery" in the product-slider.tpl file. Any advices are hearty welcome Override function getProductProperties from Product class: public static function getProductProperties($id_lang, $row, Context $context = null) { if (!$row['id_product']) { return false; } $row['tags'] = Tag::getProductTags((int)$row['id_product']); return parent::getProductProperties($id_lang, $row, $context); } Edited February 19, 2018 by joseantgv (see edit history) Link to comment Share on other sites More sharing options...
Rollaen Posted February 13, 2018 Author Share Posted February 13, 2018 Good day I tried to override Product.php in override/classes according to your function however it always shuts down entire website. My code in Product.php: <?php class Product extends ProductCore { public static function getProductProperties($id_lang, $row, Context $context = null) { if (!$row['id_product']) { return false; } $row['tags'] = Tag::getProductTags((int)$row['id_product']); return parent::getProductProperties($id_lang, $row, $context) } } Thanks in advance for your help Rob Link to comment Share on other sites More sharing options...
joseantgv Posted February 15, 2018 Share Posted February 15, 2018 On 13/2/2018 at 7:28 PM, Rollaen said: Good day I tried to override Product.php in override/classes according to your function however it always shuts down entire website. My code in Product.php: <?php class Product extends ProductCore { public static function getProductProperties($id_lang, $row, Context $context = null) { if (!$row['id_product']) { return false; } $row['tags'] = Tag::getProductTags((int)$row['id_product']); return parent::getProductProperties($id_lang, $row, $context) } } Thanks in advance for your help Rob Hi Rob, apologies for the delay, this buggy forum doesn't alert me with your new answer. When you say that it "shuts down entire website" I suppose that you mean a blank page. Please enable errors https://www.prestashop.com/forums/topic/575132-how-to-enable-debug-mode-on-prestashop-17-and-older-versions-turn-on-error-reporting-blank-page/ 1 Link to comment Share on other sites More sharing options...
Rollaen Posted February 18, 2018 Author Share Posted February 18, 2018 Hello I am sorry for that I answer this late. Here is the problem according to debug mode for the code above. Parse error: syntax error, unexpected '}' in /data/www/dpkk.cz/www.dpkk.cz/override/classes/Product.php on line 16 Thanks answer Rob Link to comment Share on other sites More sharing options...
joseantgv Posted February 19, 2018 Share Posted February 19, 2018 18 hours ago, Rollaen said: Hello I am sorry for that I answer this late. Here is the problem according to debug mode for the code above. Parse error: syntax error, unexpected '}' in /data/www/dpkk.cz/www.dpkk.cz/override/classes/Product.php on line 16 Thanks answer Rob Sorry, I forgot a semicolon: <?php class Product extends ProductCore { public static function getProductProperties($id_lang, $row, Context $context = null) { if (!$row['id_product']) { return false; } $row['tags'] = Tag::getProductTags((int)$row['id_product']); return parent::getProductProperties($id_lang, $row, $context); } } Link to comment Share on other sites More sharing options...
Rollaen Posted February 19, 2018 Author Share Posted February 19, 2018 Unfortunately this solution does not work. The condition does not display anything. Thanks for answer Rob Link to comment Share on other sites More sharing options...
joseantgv Posted February 22, 2018 Share Posted February 22, 2018 On 19/2/2018 at 1:21 PM, Rollaen said: Unfortunately this solution does not work. The condition does not display anything. Thanks for answer Rob Hi Rob, something's wrong/different in your store. I tested code before posting it. See attachments. Please ensure that overrided code is executed, adding a die() or similar. Have you removed /cache/class_index.php? 1 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