Gabrielwork16 Posted March 20, 2019 Share Posted March 20, 2019 Hi everyone! Sorry if this is not the correct place to this question, I don't find any other place to write in, and sorry again if my english isn't very good. My problem is the next: I has created a new table in db (mysql) called 'tallas' and I have the size's preferences of the users. Now, I need call this table since the page product-variants.tpl because I would like to put cheeked for default the option select by the customer. I create this function in classes/Product.php public function getTalla($id_customer){ $result = Db::getInstance()->ExecuteS(' SELECT `talla1` FROM `tallas` WHERE `cliente` = `$id_customer`'); return $result; } ok, I would like to receive for parameters the user id (I don't know how to do that yet) and I would like to receive the value of `talla1` and then I would like put cheeked the option selected by the customer here in the themes/asmart/templates/catalog/_partials/product-variants.tpl in the radio. <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> Sincerely I don't know any idea to how to do that, can someone help me? Thank you!!!!! Link to comment Share on other sites More sharing options...
Gabrielwork16 Posted March 21, 2019 Author Share Posted March 21, 2019 The problem is solved. I do that: in classes/Product.php public function getTalla(){ $variable = Context::getContext()->customer->id; $result = Db::getInstance()->ExecuteS('SELECT * FROM `tallas` WHERE `cliente` = `$variable`'); return $result; } in ProductController.php $this->context->smarty->assign('images_ex',$this->product->getTalla()); in product-variants.tpl {if $images_ex[0]['talla1'] == $group_attribute.name} checked="checked"{/if} I hope this can help someone in the future. Link to comment Share on other sites More sharing options...
giulym Posted August 26, 2019 Share Posted August 26, 2019 Nice! Do you know how to call a single variant of a product? I mean, as you did, but for the standard variants, for e.g. color. I need to do this: Tab 1: color Tab 2: radio if I repeat the product-variants.tpl in each tab, the selection doesn't work any idea? 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