[SOLVED] How to show available combinations - Theme development / Integration - PrestaShop

Jump to content

Photo

[SOLVED] How to show available combinations

#1

Posted 26 June 2010 - 06:25 PM

vasikgreif

    PrestaShop Apprentice

  • Members
  • PipPip
  • 57 Active Posts
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

#2

Posted 27 June 2010 - 01:24 AM

rocky

    PrestaShop Legend

  • US Moderators
  • 10220 Active Posts
No, it's not possible. It would require dynamically changing the options in the dropdowns, which would be difficult.
Nethercott Constructions - PrestaShop modules and guides

#3

Posted 27 June 2010 - 05:18 AM

vasikgreif

    PrestaShop Apprentice

  • Members
  • PipPip
  • 57 Active Posts
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...

#4

Posted 27 June 2010 - 06:36 AM

rocky

    PrestaShop Legend

  • US Moderators
  • 10220 Active Posts
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.
Nethercott Constructions - PrestaShop modules and guides

#5

Posted 27 June 2010 - 01:56 PM

vasikgreif

    PrestaShop Apprentice

  • Members
  • PipPip
  • 57 Active Posts
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.

#6

Posted 27 June 2010 - 10:58 PM

rocky

    PrestaShop Legend

  • US Moderators
  • 10220 Active Posts
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}

Nethercott Constructions - PrestaShop modules and guides

#7

Posted 28 June 2010 - 08:00 AM

vasikgreif

    PrestaShop Apprentice

  • Members
  • PipPip
  • 57 Active Posts
Thanks, works like a charm!

#8

Posted 29 July 2010 - 11:09 AM

lightdown

    PrestaShop Newbie

  • Members
  • Pip
  • 7 Active Posts
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, PDRD
140, 80, W-23
140, 80, w27
210, 280, w-24

Its 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 selects

Anyone knows how to make this?
Thanks for all

#9

Posted 29 July 2010 - 10:42 PM

rocky

    PrestaShop Legend

  • US Moderators
  • 10220 Active Posts
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.
Nethercott Constructions - PrestaShop modules and guides

#10

Posted 28 August 2010 - 06:50 PM

guest*

    PrestaShop Legend

  • Banned
  • PipPipPipPipPipPip
  • 12270 Active Posts

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 --> " ?

#11

Posted 29 August 2010 - 12:57 AM

rocky

    PrestaShop Legend

  • US Moderators
  • 10220 Active Posts
You can add this code wherever you want it to appear. You shouldn't overwrite any other code.
Nethercott Constructions - PrestaShop modules and guides

#12

Posted 29 August 2010 - 12:52 PM

guest*

    PrestaShop Legend

  • Banned
  • PipPipPipPipPipPip
  • 12270 Active Posts
ok. Thx, I try.

#13

Posted 14 December 2010 - 01:45 PM

Danny Sam

    PrestaShop Newbie

  • Members
  • Pip
  • 3 Active Posts

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?

#14

Posted 15 December 2010 - 06:09 AM

Danny Sam

    PrestaShop Newbie

  • Members
  • Pip
  • 3 Active Posts
can any one help me on this? I want to show the available combinations along with the reference and the cost. pls help..

#15

Posted 15 December 2010 - 11:38 AM

Dmcwebd

    PrestaShop Apprentice

  • Members
  • PipPip
  • 55 Active Posts
is there any way to show the stock for each combination?
that would be great
thx

#16

Posted 20 January 2011 - 04:38 PM

em.pe

    PrestaShop Newbie

  • Members
  • Pip
  • 8 Active Posts

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.

#17

Posted 01 February 2011 - 12:54 PM

Cosmi

    PrestaShop Newbie

  • Members
  • Pip
  • 18 Active Posts
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!

#18

Posted 01 February 2011 - 09:05 PM

corint1

    PrestaShop Apprentice

  • Members
  • PipPip
  • 178 Active Posts
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

#19

Posted 01 February 2011 - 11:58 PM

rocky

    PrestaShop Legend

  • US Moderators
  • 10220 Active Posts
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}

Nethercott Constructions - PrestaShop modules and guides

#20

Posted 02 February 2011 - 06:31 AM

corint1

    PrestaShop Apprentice

  • Members
  • PipPip
  • 178 Active Posts
Thanks for your answer was useful but with an amendment replacing "== 0" with "> 0"... will be a problem elsewhere ?


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cookies help us deliver our services. By using our services, you agree to use our cookies.     Learn more