wiseprt Posted April 3, 2015 Share Posted April 3, 2015 Hello, When a product has only one attribute value (for example for attribute "size" there is only the "XL") i want instead of the display of a select / option field to have a simple text with the value. Tried to edit/hack product.tpl but i couldn't find a solution. Any help will be appreciated. Best Regards Link to comment Share on other sites More sharing options...
MichałM Posted April 4, 2015 Share Posted April 4, 2015 Try this: Find {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> And replace: {if ($group.group_type == 'select')} {if ($group.attributes|@count == 1)} {foreach from=$group.attributes key=id_attribute item=group_attribute} {$group_attribute|escape:'html':'UTF-8'} <input type="hidden" id="group_{$id_attribute_group|intval}" name="{$groupName|escape:'html':'UTF-8'}" value="{$id_attribute|intval}" /> {/foreach} {else} <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> {/if} Link to comment Share on other sites More sharing options...
wiseprt Posted April 14, 2015 Author Share Posted April 14, 2015 Hello @MichałM, Thanks a lot this is working. The only change i want now is this: When an attribute (radio button type) has only one value i want the radio button to be already checked,cause know even is only one i have to select the value to proceed. Thanks again. Best Regards Link to comment Share on other sites More sharing options...
defuzed Posted April 14, 2015 Share Posted April 14, 2015 Hi wiseport, this is odd... the radio atrributes part of product.tpl (just below the select part that MichalM posted) should have the following: {if ($group.default == $id_attribute)} checked="checked"{/if} this sets the radio button to checked that corresponds to the products default combination (unless you have a product url with some hashes that change the combination). If you only have one radio attribute then surely this attribute should be present in the default combination? Link to comment Share on other sites More sharing options...
wiseprt Posted April 28, 2015 Author Share Posted April 28, 2015 Hello again, Everything is working fine with this attribute hack, but i have an issue with the blockcart popup window which is opens on press of the buy button. I want this popup window to include all the product attributes and only one (now there is only the weight attribute - i don't know why, i think was the default one but even after change the default attribute to another, the popup continuing to show the "weight" attribute. I noticed that the popup is in the blockcart.tpl file and the line which is for the attributes is this one: <span id="layer_cart_product_attributes"></span> i noticed also that the #id of the line is generating by the file ajax-cart.js in these lines: $('#layer_cart_product_attributes').text(''); if (product.hasAttributes && product.hasAttributes == true) $('#layer_cart_product_attributes').html(product.attributes); but i don't know what to moedify in order to have a display of all attributes selected in the cart popup. Best Regards Link to comment Share on other sites More sharing options...
wiseprt Posted April 28, 2015 Author Share Posted April 28, 2015 (edited) Hello, OK the issue was that i was not using the combination generator. Now i have added the combinations through the generator (instead of adding them one by one with the "new combination" button), and i can see all the attributes in the popup blockcart. My problem is that i want to display not only the values but the labels also. Any help? Best Regards Edited April 28, 2015 by wiseprt (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now