lundi 19 février 2018

PrestaShop 1.7 attribute as check box?

Good day. There was such problem: it is necessary to implement for the goods the possibility of adding several goods to the basket, with the chosen sizes. I am digging through the AttributeGroup.php files.

private $groupTypeAvailable = array(
    'select',
    'checkbox',
    'color',
);

Next AdminAttributesController.php

$group_type = array(
        array(
            'id' => 'select',
            'name' => $this->trans('Drop-down list', array(), 'Admin.Global')
        ),
        array(
            'id' => 'checkbox',
            'name' => $this->trans('Radio buttons', array(), 'Admin.Global')
        ),
        array(
            'id' => 'color',
            'name' => $this->trans('Color or texture', array(), 'Admin.Catalog.Feature')
        ),
    );

and in product-variants.tpl

{elseif $group.group_type == 'checkbox'}
    <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="" type="checkbox" data-product-attribute="{$id_attribute_group}" name="group[{$id_attribute_group}]" value="{$id_attribute}">
            <span class="radio-label">{$group_attribute.name}</span>
          </label>
        </li>
      {/foreach}
    </ul>
  {/if}

For this I can choose several checkboxes, but the last selected is added to the basket.

enter image description here




Aucun commentaire:

Enregistrer un commentaire