Digitanie Posted September 26, 2018 Share Posted September 26, 2018 (edited) Hi, As is the case on the product template, I want display the selected the texture/color of attribute for each product in the basket (not only they names). After several days looking for a solution, I dare to ask if anyone would be able to help me... The only ones properties that which gives something in cart-detailed-product-line.tpl are: - $product.attributes" : only attribute names given (not even ID: wtf?)! - $product.url : complete URL with URI containing the selected attribute, but without possibility to recover only attribute's ID from Smarty. And I did not find any API doc, with the variables available. So I am here... Thanks for help. Edited September 26, 2018 by fujitsuDev (see edit history) Link to comment Share on other sites More sharing options...
Rolige Posted October 4, 2018 Share Posted October 4, 2018 Try dumping only $product, you will see that there is a id_product_attribute Link to comment Share on other sites More sharing options...
Digitanie Posted October 5, 2018 Author Share Posted October 5, 2018 (edited) Thanks, but nothing more with $product, I had already checked. It's not really elegant, but that work: {foreach from=$product.attributes key="attribute" item="value"} <div class="product-line-info variants"> {$clear1 = "{$product.url|regex_replace:'/[^\d*]+$/':''}"} {$clear2 = "{$clear1|regex_replace:'/^(.*[\/])/':''}"} {$img_id = "{$clear2}"} <div class="texture" style="background-image: url({$urls.img_ps_url}co/{$img_id}.jpg)"></div> </div> {/foreach} I didn't succeed in uniting the two RegEx conditions, so I cut in two steps. Edited October 5, 2018 by fujitsuDev (see edit history) Link to comment Share on other sites More sharing options...
zenerry Posted June 4, 2020 Share Posted June 4, 2020 (edited) Hello @fujitsuDev I'm pretty new to programming , finally I understood what you did. I've copy pasted you code inside my cart-detailed-product-line.tpl file without success. I've just needed to truncate in order to cut off the ID of the variant. <div class="variants"> {$clear1 = "{$product.url|regex_replace:'/[^\d*]+$/':''}"} {$clear2 = "{$clear1|regex_replace:'/^(.*[\/])/':''}"} {$img_id = "{$clear2|truncate:3:""}"} <div class="texture" style="background-image: url({$urls.img_ps_url}co/{$img_id}.jpg); width:50px; height:50px"></div> </div> Do you know how to cut until the "-" (dash) intead of truncating the first 3 chars? Thanks. Edited June 4, 2020 by zenerry found a solution (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