PasiniOnline Posted May 2, 2012 Share Posted May 2, 2012 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 More sharing options...
Mike Kranzler Posted May 2, 2012 Share Posted May 2, 2012 Hi PasiniOnline, You can set a specific default combination easily in your Back Office using the Combinations Generator for that product. I hope this helps. -Mike Link to comment Share on other sites More sharing options...
PasiniOnline Posted May 10, 2012 Author Share Posted May 10, 2012 Thanks for this Mike. Problem is I have 7,500 products in my store so I need it to be more streamlined and easy to achieve than that, hence why I went with the code stated above. Any ideas? Thanks. Link to comment Share on other sites More sharing options...
tomerg3 Posted May 10, 2012 Share Posted May 10, 2012 You can check the group id, and only display the option if it matches the ID of the colour group Link to comment Share on other sites More sharing options...
PasiniOnline Posted May 10, 2012 Author Share Posted May 10, 2012 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 More sharing options...
tomerg3 Posted May 10, 2012 Share Posted May 10, 2012 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 More sharing options...
PasiniOnline Posted May 10, 2012 Author Share Posted May 10, 2012 Yeah I sort of got that idea the minute I posted the last message! Thanks ever so much, that's fixed the problem. Link to comment Share on other sites More sharing options...
tomerg3 Posted May 10, 2012 Share Posted May 10, 2012 You may also want to check out http://www.presto-changeo.com/en/content/7-default-attribute-alert You can add a JS alert in case the customer tries to add to cart without changing the default attributes. Link to comment Share on other sites More sharing options...
Mike Kranzler Posted May 11, 2012 Share Posted May 11, 2012 Thanks tomerg3! I'll go ahead and mark this thread as solved. Happy selling! -Mike Link to comment Share on other sites More sharing options...
CarriedAwayCrafts Posted May 15, 2012 Share Posted May 15, 2012 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 More sharing options...
tomerg3 Posted May 15, 2012 Share Posted May 15, 2012 This is exactly the place you wanna ask. Hopefully you'd find some help. I'm currently away on a working "vacation", I'll try to check back in if no one else can help. 1 Link to comment Share on other sites More sharing options...
CarriedAwayCrafts Posted May 15, 2012 Share Posted May 15, 2012 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 More sharing options...
melksog Posted March 14, 2014 Share Posted March 14, 2014 Does it works on ps 1.5.6? Link to comment Share on other sites More sharing options...
Recommended Posts