giulym Posted August 23, 2019 Share Posted August 23, 2019 Hello, I have a problem with product.tpl and product-variants.tpl when a product has combinations. I select a color and the page refreshes automatically to show the product variation, but input isn't checked anymore. This happens with all the variants (color, radio...). If I choose between 2 attributes in a dropdown input, page refreshes and the update doesn't stay checked. Do you know why this happens? product.tpl {block name='product_buy'} <form action="{$urls.pages.cart}" method="post" id="add-to-cart-or-refresh"> <input type="hidden" name="token" value="{$static_token}"> <input type="hidden" name="id_product" value="{$product.id}" id="product_page_product_id"> <input type="hidden" name="id_customization" value="{$product.id_customization}" id="product_customization_id"> {block name='product_variants'} {include file='catalog/_partials/product-variants.tpl'} {/block} {if $product.is_customizable && count($product.customizations.fields)} {block name='product_customization'} {include file="catalog/_partials/product-customization.tpl" customizations=$product.customizations} {/block} {/if} {block name='product_add_to_cart'} {include file='catalog/_partials/product-add-to-cart.tpl'} {/block} {* Input to refresh product HTML removed, block kept for compatibility with themes *} {block name='product_refresh'}{/block} </form> {/block} .color, .custom-checkbox input[type="checkbox"] + span.color { width: 10px; height: 10px; border: 5px solid red; display: inline-block; cursor: pointer; text-align: center; background-size: contain; border-radius: 50%; } product.tpl (miniatures) <div class="product-variants"> {foreach from=$groups key=id_attribute_group item=group} {if !empty($group.attributes)} <div class="clearfix product-variants-item"> <span class="control-label">{$group.name}</span> {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} </select> {elseif $group.group_type == 'color'} <ul id="group_{$id_attribute_group}"> {foreach from=$group.attributes key=id_attribute item=group_attribute} <li class="float-xs-left input-container"> <label> <input class="input-color" type="radio" data-product-attribute="{$id_attribute_group}" name="group[{$id_attribute_group}]" value="{$id_attribute}"{if $group_attribute.selected} checked="checked"{/if}> <span {if $group_attribute.html_color_code}class="color" style="background-color: {$group_attribute.html_color_code}" {/if} {if $group_attribute.texture}class="color texture" style="background-image: url({$group_attribute.texture})" {/if} ><span class="sr-only">{$group_attribute.name}</span></span> </label> </li> {/foreach} </ul> {elseif $group.group_type == 'radio'} <ul id="group_{$id_attribute_group}"> {foreach from=$group.attributes key=id_attribute item=group_attribute} <li class="input-container float-xs-left"> <label> <input class="input-radio" type="radio" data-product-attribute="{$id_attribute_group}" name="group[{$id_attribute_group}]" value="{$id_attribute}"{if $group_attribute.selected} checked="checked"{/if} required> <span class="radio-label">{$group_attribute.name}</span> </label> </li> {/foreach} </ul> {/if} </div> {/if} {/foreach} </div> 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