Jump to content

How to enable "Please Select" text in drop-down on combinations?


amorxoigel

Recommended Posts

The question is about having a prompt appearing by default in the dropdown box for a product attribute, rather than the value of the attribute for the default combination.

 

On many websites you would see "--Please Select--" or something similar in the box, and you would not be able to proceed unless you make a selection from the dropdown list.

 

This removes the risk of the customer just placing the default combination in the cart - they would be forced to select the desired attribute(s). This avoids subsequent order queries/amendments, issuing of credit notes, etc.

I tried to change the product-variants.tpl by adding this line after the foreach
 

"{if $group.group_type == 'select'}
        <select
          class="form-control form-control-select"
          id="group_{$id_attribute_group}"
          data-product-attribute="{$id_attribute_group}"
          name="group[{$id_attribute_group}]"
          >

          {foreach from=$group.attributes key=id_attribute item=group_attribute}
            <option value="{$id_attribute}" title="{$group_attribute.name}"{if $group_attribute.selected} selected="selected"{/if}>{$group_attribute.name}</option>
          {/foreach}

<option value="--choose--" selected="selected" title="--choose--">{l s='--Please select--'}</option>
        </select>"

 

Now actually when i load a product page it show the "please select" in the select form. The only problem is everytime i select any other value it refresh again and set back to "please select".
Any ideas how to solve it?

Prestashop 1.7.5.0

themes/xxx/templates/catalog/_partials/product-variants.tpl
Thank you guys!

Link to comment
Share on other sites

11 hours ago, JBW said:

Put your option before the foreach and remove the selected="selected" attribute.

Hey, thanks you for ur reply.
I already tried what u suggested but it doesnt work.
If i do what u suggested when i load the product page it will show the standard combination in the label instead of "please select" 😕

Link to comment
Share on other sites

  • 2 months later...
  • 1 year later...
  • 2 weeks later...
1 hour ago, Jose Lorenzini said:

add this before your foreach

<option value="">--- Select ---</option>

This will cause major issue when the customer forgets to choose one attribute and tries to add it to cart. And doesn't work for color or select boxes

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...