vasikgreif Posted June 26, 2010 Share Posted June 26, 2010 Hi, I have a product, there are 3 groups of attributes, in each group cca 10 attributes. Now when I select the combination that doesn't exist, Presta gives "this combination doesn't exist" message (something like that, I don't have the english language file). Is there a way to hide the combinations that don't exist? I mean when I select one attribute from first group, the attributes in other groups that don't exist with this one would be hidden? Thanks Link to comment Share on other sites More sharing options...
rocky Posted June 27, 2010 Share Posted June 27, 2010 No, it's not possible. It would require dynamically changing the options in the dropdowns, which would be difficult. Link to comment Share on other sites More sharing options...
vasikgreif Posted June 27, 2010 Author Share Posted June 27, 2010 Thanks for reply, is there another solution how to let the customer know which combinations are available? Now the customer has to guess what combinations could be available, wchich with raising number of options is really boring... Link to comment Share on other sites More sharing options...
rocky Posted June 27, 2010 Share Posted June 27, 2010 It already displays the number of items in stock when you select a quantity, so the customer can see if a combination is available before clicking "Add to cart". I think that is enough, but if you really need to display a list of unavailable combinations, you could use code like the following in product.tpl: {if isset($groups)}{strip} {l s='The following combinations are unavailable:'} {foreach from=$combinations key=idCombination item=combination} {if $combination.quantity == 0} {assign var=attributes value=','|explode:$combination.list} {foreach from=$groups key=id_attribute_group item=group} {foreach from=$group.attributes key=id_attribute item=group_attribute} {foreach from=$attributes item=attribute name=attribute} {if $id_attribute == $attribute|substr:1:-1} {$group_attribute}{if !$smarty.foreach.attribute.last}, {/if} {/if} {/foreach} {/foreach} {/foreach} {/if} {/foreach} {/strip}{/if} This code probably isn't very efficient, but it should work. Link to comment Share on other sites More sharing options...
vasikgreif Posted June 27, 2010 Author Share Posted June 27, 2010 Hi, thanks for your help, I think I didn't specify exactly enough what I need. The code you posted will show list of combinations out of stock, right? I would need to make a list of valid combinations, combinations that exist.My problem is I have an item that has 3 groups of attributes, 10 attributes in each group, but not all the combinations of them exist (let's say only 20 percent of all possible combinations exist). Now the customer has to guess the valid combinations. Link to comment Share on other sites More sharing options...
rocky Posted June 27, 2010 Share Posted June 27, 2010 In that case, use the following code: {if isset($groups)}{strip} {l s='The following combinations are available:'} {foreach from=$combinations key=idCombination item=combination} {if $combination.quantity > 0} {assign var=attributes value=','|explode:$combination.list} {foreach from=$groups key=id_attribute_group item=group} {foreach from=$group.attributes key=id_attribute item=group_attribute} {foreach from=$attributes item=attribute name=attribute} {if $id_attribute == $attribute|substr:1:-1} {$group_attribute}{if !$smarty.foreach.attribute.last}, {/if} {/if} {/foreach} {/foreach} {/foreach} {/if} {/foreach} {/strip}{/if} 1 Link to comment Share on other sites More sharing options...
vasikgreif Posted June 28, 2010 Author Share Posted June 28, 2010 Thanks, works like a charm! Link to comment Share on other sites More sharing options...
lightdown Posted July 29, 2010 Share Posted July 29, 2010 Hi everybody,I´m searching for something like this code, but now, i need to put an add a cart from this list.For example, in my shop , the code from rocky show this:140, 80, PDRD140, 80, W-23140, 80, w27210, 280, w-24Its Ok, those are combinations from my products, but, below i see the selects that i want to delete. I need the people buy the products from the list above.Each combination has a reference. Another option would be put a select with references and hidden the other selectsAnyone knows how to make this?Thanks for all Link to comment Share on other sites More sharing options...
rocky Posted July 29, 2010 Share Posted July 29, 2010 It sounds like I should incorporate this code into the next version of my "Product attributes as radio buttons and checkboxes" module. I was planning to add a "Combination view" as well as the "Attribute view" it currently has, then add the option to have "Add to cart" buttons next to each. I just have to find time to do it. 2 Link to comment Share on other sites More sharing options...
guest* Posted August 28, 2010 Share Posted August 28, 2010 In that case, use the following code: {if isset($groups)}{strip} {l s='The following combinations are available:'} {foreach from=$combinations key=idCombination item=combination} {if $combination.quantity > 0} {assign var=attributes value=','|explode:$combination.list} {foreach from=$groups key=id_attribute_group item=group} {foreach from=$group.attributes key=id_attribute item=group_attribute} {foreach from=$attributes item=attribute name=attribute} {if $id_attribute == $attribute|substr:1:-1} {$group_attribute}{if !$smarty.foreach.attribute.last}, {/if} {/if} {/foreach} {/foreach} {/foreach} {/if} {/foreach} {/strip}{/if} I need the same, is this code instead of one in product.tpl or just to ammend ? In wicht Postition ? after of before block " <!-- attributes --> " ? Link to comment Share on other sites More sharing options...
rocky Posted August 28, 2010 Share Posted August 28, 2010 You can add this code wherever you want it to appear. You shouldn't overwrite any other code. Link to comment Share on other sites More sharing options...
guest* Posted August 29, 2010 Share Posted August 29, 2010 ok. Thx, I try. Link to comment Share on other sites More sharing options...
Danny Sam Posted December 14, 2010 Share Posted December 14, 2010 In that case, use the following code: {if isset($groups)}{strip} {l s='The following combinations are available:'} {foreach from=$combinations key=idCombination item=combination} {if $combination.quantity > 0} {assign var=attributes value=','|explode:$combination.list} {foreach from=$groups key=id_attribute_group item=group} {foreach from=$group.attributes key=id_attribute item=group_attribute} {foreach from=$attributes item=attribute name=attribute} {if $id_attribute == $attribute|substr:1:-1} {$group_attribute}{if !$smarty.foreach.attribute.last}, {/if} {/if} {/foreach} {/foreach} {/foreach} {/if} {/foreach} {/strip}{/if} How do I also display the combination reference and price along with the available combination list? Link to comment Share on other sites More sharing options...
Danny Sam Posted December 15, 2010 Share Posted December 15, 2010 can any one help me on this? I want to show the available combinations along with the reference and the cost. pls help.. Link to comment Share on other sites More sharing options...
Dmcwebd Posted December 15, 2010 Share Posted December 15, 2010 is there any way to show the stock for each combination?that would be greatthx Link to comment Share on other sites More sharing options...
em.pe Posted January 20, 2011 Share Posted January 20, 2011 In that case, use the following code:{if isset($groups)}{strip} {l s='The following combinations are available:'} {foreach from=$combinations key=idCombination item=combination} {if $combination.quantity > 0} {assign var=attributes value=','|explode:$combination.list} {foreach from=$groups key=id_attribute_group item=group} {foreach from=$group.attributes key=id_attribute item=group_attribute} {foreach from=$attributes item=attribute name=attribute} {if $id_attribute == $attribute|substr:1:-1} {$group_attribute}{if !$smarty.foreach.attribute.last}, {/if} {/if} {/foreach} {/foreach} {/foreach} {/if} {/foreach} {/strip}{/if} Thank you very much for this code! But I have a problem...Now this code generate something like this:size_1, color_1, color_2, color_3 ...size_1, size_2, color_1, color_2 ...... But how to display attributes with names of groups inside? Group1: size_A Group2: color_A, color_B, color_C ...Group1: size_A, size_B Group2: color_A, color_B ...... Thanks in advance. Link to comment Share on other sites More sharing options...
Cosmi Posted February 1, 2011 Share Posted February 1, 2011 Dear PrestaShop developers,Is there any way to show available combinations in product-list.tpl ? I tried to modify the above code but the result is blank.Here is what I did: (I added "product." to some variables... ) {if isset($groups)}{strip} {l s='The following combinations are available:'} {foreach from=$product.combinations key=idCombination item=combination} {if $product.combination.quantity > 0} {assign var=attributes value=','|explode:$combination.list} {foreach from=$product.groups key=id_attribute_group item=group} {foreach from=$product.group.attributes key=id_attribute item=group_attribute} {foreach from=$product.attributes item=attribute name=attribute} {if $id_attribute == $attribute|substr:1:-1} {$group_attribute}{if !$smarty.foreach.attribute.last}, {/if} {/if} {/foreach} {/foreach} {/foreach} {/if} {/foreach} {/strip}{/if} Thanks to all! Link to comment Share on other sites More sharing options...
corint1 Posted February 1, 2011 Share Posted February 1, 2011 how to test the products contained in the category page(product-list.tpl) if there are combinations. I want to disable the "add to cart" only for products that are combinations 1 Link to comment Share on other sites More sharing options...
rocky Posted February 1, 2011 Share Posted February 1, 2011 In PrestaShop v1.4, you can simply go to the Preferences > Products tab and change 'Display "add to cart" button when product has attributes' to 'No', then click the save button. In PrestaShop v1.3, you must put the following code around the add to cart button code: {if $product.id_product_attribute == 0} and the following after: {/if} Link to comment Share on other sites More sharing options...
corint1 Posted February 2, 2011 Share Posted February 2, 2011 Thanks for your answer was useful but with an amendment replacing "== 0" with "> 0"... will be a problem elsewhere ? Link to comment Share on other sites More sharing options...
rocky Posted February 2, 2011 Share Posted February 2, 2011 I thought products with attributes has an id_product_attribute greater than 0, which is why I said == 0, so that only products without attributes display "Add to cart". Using > 0 should hide the "Add to cart" button on all products that don't have attributes. Link to comment Share on other sites More sharing options...
corint1 Posted February 2, 2011 Share Posted February 2, 2011 Thanks for your answer Link to comment Share on other sites More sharing options...
Liofey Posted April 19, 2012 Share Posted April 19, 2012 Hello rocky. I want to ask. Is it possible now to show available combinations via dropdown select? I mean like this case. I have combinations like this : 1. Color Black size M 2. Color Black size S 3. Color Orange size S Can we update the product.tpl so it could be dynamically changing (using javascript on change maybe) So if the customer choose color black it will show attribute groups size with have value M and S. But if the customer choose the orange color it will show only "S" value in Size. 1 Link to comment Share on other sites More sharing options...
burakco Posted July 4, 2012 Share Posted July 4, 2012 Hello rocky. I want to ask. Is it possible now to show available combinations via dropdown select? I mean like this case. I have combinations like this : 1. Color Black size M 2. Color Black size S 3. Color Orange size S Can we update the product.tpl so it could be dynamically changing (using javascript on change maybe) So if the customer choose color black it will show attribute groups size with have value M and S. But if the customer choose the orange color it will show only "S" value in Size. did you solve your preblem, i have same? 1 Link to comment Share on other sites More sharing options...
femo Posted August 6, 2012 Share Posted August 6, 2012 did you solve your preblem, i have same? did you solve your preblem, i have same? It would be very helpful... Link to comment Share on other sites More sharing options...
Anton_bcn Posted April 11, 2013 Share Posted April 11, 2013 (edited) Hi, about a combinations i have The question is which is more correct and better way to check if is set combinations? Is enough to put in *.tpl files : {if !isset ($groups)} //some code if not set combinations at all for this product <div></div> <div>Combinations NOT found! Show normal cart</div> {/if} //here is a code for all possibilities with or without combinations <div>Some code</div> {if isset ($groups)} //here is code which shows only if combinations founded <div>Combinations found! Do not show a cart, but show table combinations i use</div> {/if} Is this all correct way to check {if !isset ($groups)} ? And can i use same check in every module i have installed? Edited April 11, 2013 by anseme (see edit history) Link to comment Share on other sites More sharing options...
ajensen27 Posted August 9, 2013 Share Posted August 9, 2013 The code works beautifuly but isn't formatted very nicely. It would be awesome if someone could make it so that the attributes show up nicely in a table with the amount of product available for each. Link to comment Share on other sites More sharing options...
MaTaTuu Posted August 27, 2013 Share Posted August 27, 2013 (edited) It would be awesome if someone could make it so that the attributes show up nicely in a table with the amount of product available for each. That could be very useful to me too Did anyone that allready? Edited August 28, 2013 by MaTaTuu (see edit history) Link to comment Share on other sites More sharing options...
ShRon Posted January 8, 2014 Share Posted January 8, 2014 Bump. I have same problem here Link to comment Share on other sites More sharing options...
skadoic1 Posted July 16, 2014 Share Posted July 16, 2014 (edited) In that case, use the following code: {if isset($groups)}{strip} {l s='The following combinations are available:'} {foreach from=$combinations key=idCombination item=combination} {if $combination.quantity > 0} {assign var=attributes value=','|explode:$combination.list} {foreach from=$groups key=id_attribute_group item=group} {foreach from=$group.attributes key=id_attribute item=group_attribute} {foreach from=$attributes item=attribute name=attribute} {if $id_attribute == $attribute|substr:1:-1} {$group_attribute}{if !$smarty.foreach.attribute.last}, {/if} {/if} {/foreach} {/foreach} {/foreach} {/if} {/foreach}{/strip}{/if} if i understand it right this code is to showing only combinations that have quantites greater than 0. if it is this case, where should i put this code? what happens when some of existing combinations with quantites = 0 get new quantites? will this combinations be visible when the quantites changes from 0 to 1? thx in forward regards p.s i am using ver 1.6.0.8 is there any option to choose such thing in ver. 1.6.0.8 p.p.s. i found the option! ignore this post Edited July 16, 2014 by skadoic1 (see edit history) Link to comment Share on other sites More sharing options...
gr_fenix Posted September 9, 2014 Share Posted September 9, 2014 if i understand it right this code is to showing only combinations that have quantites greater than 0. if it is this case, where should i put this code? what happens when some of existing combinations with quantites = 0 get new quantites? will this combinations be visible when the quantites changes from 0 to 1? thx in forward regards p.s i am using ver 1.6.0.8 is there any option to choose such thing in ver. 1.6.0.8 p.p.s. i found the option! ignore this post Wich is the option? Show us. Thanks Link to comment Share on other sites More sharing options...
ZoZo21 Posted June 6, 2015 Share Posted June 6, 2015 (edited) Hy, First sorry for my bad english I want to show if the combination doesn`t exist, like text "this combination doesn`t exist", but i don`t want to show text "this product is no longer in stoc", in product-tpl. If i comment the text with no longer... automatic disable the text with this combination dosent exist...the add to cart dosent appaer if not exist the combination, but i want to show same this text "this combination doesn`t exist. Please help me how . Respect, Krisztian Edited June 6, 2015 by ZoZo21 (see edit history) Link to comment Share on other sites More sharing options...
rob84 Posted October 4, 2015 Share Posted October 4, 2015 Hello and thanks rocky for the code, works very good: {if isset($groups)}{strip} {l s='The following combinations are unavailable:'} {foreach from=$combinations key=idCombination item=combination} {if $combination.quantity == 0} {assign var=attributes value=','|explode:$combination.list} {foreach from=$groups key=id_attribute_group item=group} {foreach from=$group.attributes key=id_attribute item=group_attribute} {foreach from=$attributes item=attribute name=attribute} {if $id_attribute == $attribute|substr:1:-1} {$group_attribute}{if !$smarty.foreach.attribute.last}, {/if} {/if} {/foreach} {/foreach} {/foreach} {/if} {/foreach}{/strip}{/if} But how to not show the "{l s='The following combinations are unavailable:'}" if all combinations are available ? With this code the unavailable text appear if there are all combination available too. Thanks ! 1 Link to comment Share on other sites More sharing options...
informatikadomicile Posted November 6, 2015 Share Posted November 6, 2015 thansk for your post that nice but how to customise the view on css.Can i surround it with an id. Link to comment Share on other sites More sharing options...
skadoic1 Posted November 6, 2015 Share Posted November 6, 2015 (edited) Wich is the option? Show us. Thanks under preferences go to products page. Show Unavailable variations on the product page = No. the combinations with qty = 0 will not show on frontoffice if the qty changes from 0 to 1, the combination will be on frontoffice visible using prestashop 1.6.1.1 Edited November 6, 2015 by skadoic1 (see edit history) Link to comment Share on other sites More sharing options...
andyalber Posted January 25, 2016 Share Posted January 25, 2016 I have modified Rocky's code to display it on a table: {if isset($groups)} {strip} {l s='The following combinations are unavailable:'} <br /> <table> <thead> <tr> {foreach from=$groups key=id_attribute_group item=group} {if $group.attributes|@count} <th>{$group.name|escape:'html':'UTF-8'} </th> {/if} {/foreach} </tr> </thead> <tbody> {foreach from=$combinations key=idCombination item=combination} {if $combination.quantity == 0} <tr> {assign var=attributes value=','|explode:$combination.list} {foreach from=$groups key=id_attribute_group item=group} <td> {foreach from=$group.attributes key=id_attribute item=group_attribute} {foreach from=$attributes item=attribute name=attribute} {if $id_attribute == $attribute|substr:1:-1} {$group_attribute} {/if} {/foreach} {/foreach} </td> {/foreach} </tr> {/if} {/foreach} </tbody> </table> {/strip} {/if} I will try to create a "Select me!" button with jquery that allows the customer to actually choose that combination by clicking it. I hope this helps. And thanks Rocky for your code, it really helped me. Link to comment Share on other sites More sharing options...
system_error86 Posted July 1, 2016 Share Posted July 1, 2016 Hello guys is any way to hide the unavailable combinations form the default list? Thanks Link to comment Share on other sites More sharing options...
skadoic1 Posted July 14, 2016 Share Posted July 14, 2016 Hello guys is any way to hide the unavailable combinations form the default list? Thanks Where would you hide your unavailable combinations? Backoffice or frontoffice? As i know in backoffice you can't do it. But in Frontoffice i posted in this thread how to solve not to show combinations with no quantity. In prestashop is built in this option. Link to comment Share on other sites More sharing options...
dolec Posted April 26, 2018 Share Posted April 26, 2018 How can i show combination group name in cart summary or top cart block .Now when i add some combination to cart it displays only values of combinations like: 5,6 and we dont know if it is length or width . I would like to show length:5, width:6 i noticed that in block cart we have: {if isset($product.attributes_small)} <strong><a href="{$link->getProductLink($product, $product.link_rewrite, $product.category, null, null, $product.id_shop, $product.id_product_attribute)|escape:'html':'UTF-8'}" title="{l s='Product detail' mod='blockcart'}"> {$product.attributes_small}</a></strong> {/if} how can i get names of attrobutes (group name) 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