Tamade Posted June 26, 2021 Share Posted June 26, 2021 (edited) Hello v1.7.1.1. classic If I want it to show something if a product is in the cart, the following code works: {$in_cart = 0} {foreach from=$cart['products'] item='cart_product'} {if $cart_product['id_product'] == $product.id} {$in_cart = 1} {/if} {/foreach} {if $in_cart}....{/if} When I want to check the attributes, the following code does not work for me: {$in_cart = 0} {foreach from=$cart['products'] item='cart_product'} {if $cart_product['????'] == $id_attribute} {$in_cart = 1} {/if} {/foreach} {if $in_cart}....{/if} How do I write to find the product attribute id for me? Thanks Edited June 28, 2021 by Tamade (see edit history) Link to comment Share on other sites More sharing options...
YoJoe Posted December 16, 2021 Share Posted December 16, 2021 I faced identical problem but haven't found any out of box solution. Oh well, a man needs sometimes to roll up his own sleeves 😎 A bit of debugging to check what sort of data we can get from product object, and voilla. Simple as it's possible. We just need to check if product id matches the one in cart along with its attribute, thus: {if $cart_product['id_product'] == $product.id && $cart_product['id_product_attribute'] == $product.id_product_attribute} 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