Jump to content

[SOLVED] Defaulting attributes to unselected


Recommended Posts

Hi All,

 

I am using a line of code in my product.tpl which means when a product is opened by the user, both the size and colour attributes default to 'Please Select' rather than an actual size and colour. This is so the user has to manually choose what they want before they can proceed to add the product to the cart.

 

The code is:

<option value="{$group.default|intval}" title="Please Select">{l s='Please Select'}</option>

 

The problem I am having is my client only wants the colour to be set to 'Please Select' and the size to default to an actual size.

 

Does anybody know how to go about that?

 

Using Prestashop 1.4.7.1

 

thanks.

Link to comment
Share on other sites

I shall give that a try. If that is the case should the code look like this:

 

<option value="{$id_attribute_group_X.default|intval}" title="Please Select">{l s='Please Select'}</option>

 

Where 'X' correspondes to the size attribute ID?

Link to comment
Share on other sites

No, you can't just make up variable names ;)

 


<div id="attributes">
{foreach from=$groups key=id_attribute_group item=group}
{if $group.attributes|@count}
<p>
<label for="group_{$id_attribute_group|intval}">{$group.name|escape:'htmlall':'UTF-8'} :</label>
{assign var="groupName" value="group_$id_attribute_group"}
<select name="{$groupName}" id="group_{$id_attribute_group|intval}" onchange="javascript:findCombination();{if $colors|@count > 0}$('#wrapResetImages').show('slow');{/if};">


{if $id_attribute_group|intval == X}
add you code here, replace X with the Colour attribute group ID
{/if}


{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:'htmlall':'UTF-8'}">{$group_attribute|escape:'htmlall':'UTF-8'}</option>
{/foreach}
</select>
</p>

Link to comment
Share on other sites

I'm sorry if it's inappropriate to post to a topic after it's been marked as [sOLVED], but this is the only probable solution to my problem that I've been able to find. Will PasiniOnline's first solution (initial post above) work in the following?:

 

I need to make it so that a customer would be required to change all drop-down attribute menus from a default that says: "Please Choose From Below" to one of the other available attributes in the menu. Would his code do that? And if so- where exactly in my product.tpl would I place it? I'm configuring the NEW Prestashop theme 1.4.5 (referenced here) for PS 1.4.7.3.

 

If it's bad form to post to a [sOLVED] thread, then please let me know and I will gladly remove this post and refrain from such in the future (desperate to get my shop online so that I can start selling!)

 

Thanks in advance,

Tony

Link to comment
Share on other sites

Thanks tomerg3 for taking the time to check-in (and during a working "vacation" no less). Incidentally- in my scurrying about the web for answers, I sent an email via your website with similar questions on some code that I found there- so please don't even think about answering until you're back from holiday. Enjoy your time and try to do less 'Working' and More Vacationing.

 

Regards,

Tony

Link to comment
Share on other sites

  • 1 year later...
×
×
  • Create New...