Jump to content

Disable Default Attribute Values


Recommended Posts

Doh, I wrote a long post, then the forum ate it.  Let's try this again.

 

This question, or similar has been asked before, however the answers I've seen are not satisfactory.

 

As of PrestaShop 1.6.1.4 there is still a default combination for a product, however for some attributes this is not logical.

For example, people don't come in a default size, therefore it is not logical to have a default t-shirt size or default shoe size.

A dropdown should say "Please select" until the customer chose a size.  There should not be any value there until the customer puts it there.

 

What the shop should do:

1.  Force the customer to choose a size (and not set a default one)

2.  Hide the Add to Cart button until a valid attribute value was selected

 

Please suggest how to implement this cleanly.

 

Some of the suggestions I've seen:

1.  Use a JavaScript popup to ask the customer if they remembered to change the default attribute value.  This is not a good solution because there shouldn't be a default value for some attributes, and JavaScript popups aren't optimal anyway.

2.  Add the value "Please select" to each attribute type and set the quantity of the resulting combinations to 0 (zero).  This is a bad solution because the shop shows a confusing and misleading message that the product is out of stock, when in fact this is only due to the fact that a valid attribute value has not yet been selected.

 

I consider my question critical as it prevents many ordering mistakes.  Please help.

 

Thanks in advance!

Edited by r00tb33r (see edit history)
  • Like 4
Link to comment
Share on other sites

  • 3 weeks later...

Doh, I wrote a long post, then the forum ate it.  Let's try this again.

 

This question, or similar has been asked before, however the answers I've seen are not satisfactory.

 

As of PrestaShop 1.6.1.4 there is still a default combination for a product, however for some attributes this is not logical.

For example, people don't come in a default size, therefore it is not logical to have a default t-shirt size or default shoe size.

A dropdown should say "Please select" until the customer chose a size.  There should not be any value there until the customer puts it there.

 

What the shop should do:

1.  Force the customer to choose a size (and not set a default one)

2.  Hide the Add to Cart button until a valid attribute value was selected

 

Please suggest how to implement this cleanly.

 

Some of the suggestions I've seen:

1.  Use a JavaScript popup to ask the customer if they remembered to change the default attribute value.  This is not a good solution because there shouldn't be a default value for some attributes, and JavaScript popups aren't optimal anyway.

2.  Add the value "Please select" to each attribute type and set the quantity of the resulting combinations to 0 (zero).  This is a bad solution because the shop shows a confusing and misleading message that the product is out of stock, when in fact this is only due to the fact that a valid attribute value has not yet been selected.

 

I consider my question critical as it prevents many ordering mistakes.  Please help.

 

Thanks in advance!

 

Hi,

 

The default attribute already selected is a big problem for a fashion shop :(

 

Did you solve it?

 

Thanks

Angela

Link to comment
Share on other sites

  • 3 months later...

I also have this problem, coming from an HTML background when creating a drop-down there is always the top default value which states "select" or "choose" and then the form cannot be submitted unless a value has been selected meaning not the fist one. This really is pretty basic and I am surprised at this oversite

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...

If You have a product that have like 5x attributes and they have quantity more than 0 add one that will have 0. I noticed when You add attribute with quantity 0 to product PS always ask costumer to pick attribute.

 

One problem with this is when You enter Products > Monitoring You will have all products with attributes quantity 0 ;(

Edited by c64girl (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 1 year later...

Whats more annoying with this default attribute.
If you have colour options and the default colour is out of stock. The whole product in the categroy view shows as out of stock.

 

If clicking "add to cart" from the category view, a lightbox should pop up and ask which option they want.

  • Like 1
Link to comment
Share on other sites

  • 4 months later...
  • 2 months later...
  • 5 months later...
  • 1 year later...

I'm looking for ideas as well (1.6 or TB)

  • Default product "choose" can be out of stock. The customer sees an out of stock error message like "choose is out of stock" when ordering by mistake. But I have to show other out of stock items; I don't know how to make a special case for the default showing and the other out-of-stock not showing.
     
  • HTML5 and such are new to me; modern browsers can refuse to select a selection called
    <select>
    <optgroup>choose</optgroup> 
    <option>small</option>
    <option>large</option>
    </select>
    They also refuse options with disabled written after option, and prefer a value there called value="" over the value the customer sees, so there are HTML methods that someone might know how to use.

     
  • Javascript.
    My old html site has something like these examples
    w3schools.com/js/js_validation.asp
    When I look at the source code of Prestashop I.6 I can see stuff about form validation but am not quite sure how to change it. The script could either change viability settings on the order button or pop-up an alert and make the form unusable.

    Searching for solutions I find
    w3schools.com/jsref/event_preventdefault.asp 
    ...and that preventdefault is something that people use on Prestashop 1.6 web sites, so this is quite close to a solution.

    Somebody somewhere must know the answer. Any ideas welcome!
Edited by johnrobertson
added html bit in case it prompts someone (see edit history)
Link to comment
Share on other sites

PS 1.6 - possibly solved
TB 1.10 - for drop down menus - SOLVED
... for me at least - with an answer on another forum about a free theme called Niara which might not work on PS1.6 but is pretty similar in the template.tpl file.

If the same area about select menus is different in a Prestashop 1.6 theme product.tpl file, you could use an online text comparison tool to find the important change between code snippets below, then guess where to put it in the file.

The theme also needs to have a javascript that reacts to non-existent products being displayed. This theme hides the order button when there's a non-existent product. Maybe other themes do. I doubt I can answer questions about it beyond that, but you can find the original post with a search engine and these scripts. Replace this bit of product.tpl with its long option value...

{if ($group.group_type == 'select')}
  <select name="{$groupName}" id="group_{$id_attribute_group|intval}" class="form-control attribute_select no-print">
    {foreach from=$group.attributes key=id_attribute item=group_attribute}
      <option value="{$id_attribute|intval}"{if (isset($smarty.get.$groupName) && $smarty.get.$groupName|intval == $id_attribute) || $group.default == $id_attribute} selected="selected"{/if} title="{$group_attribute|escape:'html':'UTF-8'}">{$group_attribute|escape:'html':'UTF-8'}</option>
    {/foreach}
  </select>
{elseif ($group.group_type == 'color')}

...with this replacement that has a shorter option value defined a line further up. It only works on drop-down menus but could probably be adapted.

{if ($group.group_type == 'select')}
  <select name="{$groupName}" id="group_{$id_attribute_group|intval}" class="form-control attribute_select no-print">
    <option value="0" selected="selected" title="{l s='Choose'}">{l s='Choose'}</option>
    {foreach from=$group.attributes key=id_attribute item=group_attribute}
      <option value="{$id_attribute|intval}" title="{$group_attribute|escape:'html':'UTF-8'}">{$group_attribute|escape:'html':'UTF-8'}</option>
    {/foreach}
  </select>
{elseif ($group.group_type == 'color')}

The new attribute is called "choose", which makes sense and can be translated in the back office.

I transcribed this so you can find it with a search engine. Hope it helps someone else as much as it has helped me.

Edited by johnrobertson (see edit history)
Link to comment
Share on other sites

  • 5 months later...
  • 10 months later...

I just added CSS to hide all the attributes that are not avalable:

 

#product .st_unavailable_combination {
    display: none !important;
    visibility: hidden !important;
}

 

And changed the translation to pick other attribute

 

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...