Плагин "Картинки как на Али" тема "Yourshop"

1. В настройках темы дизайна магазина переключите "Выбор характеристик товара" на "Показывать все значения в ряд"

2. Создайте файл alaali.css в теме дизайна магазина.
Содержимое файла:

/*product.cart.html*/
/*выравниваем блоки с картинками и без по вертикали*/
.options .inline-select a{
    vertical-align: middle;
}
/*убираем галку у куртинки с цветом*/
.options .inline-select.color a.alaali i{
    display: none;
}
/*стилизация блока с картинкой*/
.options .inline-select>a.alaali{ 
    line-height: 0;
    padding: 2px;
}
/*более чёткое выделение активной(выбранной) характеристики с картинкой*/
.options .inline-select>a.alaali.selected{ 
    border: 1px solid black;
}
/*параметры самой картинки в блоке*/
.alaali_img{
    height: 40px;
}
/*product.html*/
/*параметры картинки характеристики в блоке описания всех характеристик*/
.alaali_img2{ 
    width: 30px; 
}

3. Подключить этот файл стилей в head.html

Найдите код (последние строки в файле)

<!-- plugin hook: 'frontend_head' -->
{* @event frontend_head.%plugin_id% *}
{foreach $frontend_head as $_}{$_}{/foreach}

Добавьте после них код

<link rel="stylesheet" href="{$wa_active_theme_url}alaali.css?v{$wa_theme_version}">

4. Отредактируйте шаблон product.cart.html

найдите код

{if $product.sku_type}
        <!-- SELECTABLE FEATURES selling mode -->
        {$default_sku_features = $product.sku_features}
        {if $selectedSku}
            {foreach $sku_features_selectable as $sfs_id => $sfs}
                {if $sfs.id == $selectedSku}
                    {foreach explode(';', $sfs_id) as $feat_val}
                        {if $feat_val}
                            {$feat_val2 = explode(':', $feat_val)}
                            {$default_sku_features[$feat_val2[0]] = $feat_val2[1]}
                        {/if}
                    {/foreach}
                    {break}
                {/if}
            {/foreach}
        {/if}
        {if $theme_settings.selectable_features_control == 'inline' || (isset($product.params.selectable_features) && $product.params.selectable_features == 'inline')}
            <div class="options">
                {$features_count = $features_selectable|count}
                {foreach $features_selectable as $f}
                    {$f.name}:
                    <div class="inline-select{if $f.type == 'color'} color{/if}">
                        {foreach $f.values as $v_id => $v}
                            {if $features_count > 1 || ($features_count == 1 && isset($sku_features_selectable["`$f.id`:`$v_id`;"]))}
                                {if !isset($default_sku_features[$f.id])}{$default_sku_features[$f.id]=$v_id}{/if}
                                <a data-value="{$v_id}" href="#" class="{if $v_id == ifset($default_sku_features[$f.id])}selected{/if}{if $f.type !== 'color'} not-color-block{/if}{if $features_count == 1 && isset($sku_features_selectable["`$f.id`:`$v_id`;"]) && !$sku_features_selectable["`$f.id`:`$v_id`;"].available} disabled{/if}"{if $f.type == 'color'} style="{$v->style}; margin-bottom: 20px;"{/if}>
                                    {if $f.type == 'color'}{if $v_id == ifset($default_sku_features[$f.id])}<i class="fa fa-check"></i>{/if} <span class="color_name">{strip_tags($v)}</span>{else}{$v}{/if}
                                </a>
                            {/if}
                        {/foreach}
                        <input type="hidden" data-feature-id="{$f.id}" class="sku-feature" name="features[{$f.id}]" value="{ifset($default_sku_features[$f.id])}">
                    </div>
                {/foreach}
            </div>

и исправьте на

{if $product.sku_type}
        <!-- SELECTABLE FEATURES selling mode -->
        {$feature_images = shopAlaaliHelper::getFeaturesImg($product.id)}
        {$default_sku_features = $product.sku_features}
        {if $selectedSku}
            {foreach $sku_features_selectable as $sfs_id => $sfs}
                {if $sfs.id == $selectedSku}
                    {foreach explode(';', $sfs_id) as $feat_val}
                        {if $feat_val}
                            {$feat_val2 = explode(':', $feat_val)}
                            {$default_sku_features[$feat_val2[0]] = $feat_val2[1]}
                        {/if}
                    {/foreach}
                    {break}
                {/if}
            {/foreach}
        {/if}
        {if $theme_settings.selectable_features_control == 'inline' || (isset($product.params.selectable_features) && $product.params.selectable_features == 'inline')}
            <div class="options">
                {$features_count = $features_selectable|count}
                {foreach $features_selectable as $f}
                    {$f.name}:
                    <div class="inline-select{if $f.type == 'color'} color{/if}">
                        {foreach $f.values as $v_id => $v}
                            {if in_array($v_id,$feature_images[$f.id]['id'])}
{$v_img = "<img src='"|cat:$feature_images[$f.id]['img'][$v_id]|cat:"' title='"|cat:$feature_images[$f.id]['value'][$v_id]|cat:"' class='alaali_img'/>"}
                            {/if}
                            {if $features_count > 1 || ($features_count == 1 && isset($sku_features_selectable["`$f.id`:`$v_id`;"]))}
                                {if !isset($default_sku_features[$f.id])}{$default_sku_features[$f.id]=$v_id}{/if}
                                {if in_array($v_id,$feature_images[$f.id]['id'])}
                                    <a data-value="{$v_id}" href="#" class="alaali{if $v_id == ifset($default_sku_features[$f.id])} selected{/if}">
                                        {$v_img}
                                    </a>
                                {else}
                                <a data-value="{$v_id}" href="#" class="{if $v_id == ifset($default_sku_features[$f.id])}selected{/if}{if $f.type !== 'color'} not-color-block{/if}{if $features_count == 1 && isset($sku_features_selectable["`$f.id`:`$v_id`;"]) && !$sku_features_selectable["`$f.id`:`$v_id`;"].available} disabled{/if}"{if $f.type == 'color'} style="{$v->style};"{/if}>
                                    {if $f.type == 'color'}{if $v_id == ifset($default_sku_features[$f.id])}<i class="fa fa-check"></i>{/if} <span class="color_name">{strip_tags($v)}</span>{else}{$v}{/if}
                                </a>
                                {/if}
                            {/if}
                        {/foreach}
                        <input type="hidden" data-feature-id="{$f.id}" class="sku-feature" name="features[{$f.id}]" value="{ifset($default_sku_features[$f.id])}">
                    </div>
                {/foreach}
            </div>

5. Отредактируйте шаблон product.html

найдите код

{$wa->globals('last_crumb', $product.name)}
{capture name=features_block}
    {if $product.features}
        <table class="features">
            {foreach $product.features as $f_code => $f_value}
                <tr{if $features[$f_code].type == 'divider'} class="divider"{/if}>
                    <td class="name">
                        {$features[$f_code].name|escape}
                    </td>
                    <td class="value" {if $f_code|escape == 'color' || $f_code|escape == 'weight'}itemprop="{$f_code|escape}"{/if}>
                        {if is_array($f_value)}
                            {if $features[$f_code].type == 'color'}
                                {implode('
 ', $f_value)}
                            {else}
                                {implode(', ', $f_value)}
                            {/if}
                        {else}
                            {$f_value}
                        {/if}
                    </td>
                </tr>
            {/foreach}
        </table>
    {/if}
{/capture}

и исправьте на

{$wa->globals('last_crumb', $product.name)}
{capture name=features_block}
    {if $product.features}
        {$feature_images = shopAlaaliHelper::getFeaturesImg_code($product.id,false)}
        <table class="features">
            {foreach $product.features as $f_code => $f_value}
                <tr{if $features[$f_code].type == 'divider'} class="divider"{/if}> 
                    <td class="name">
                        {$features[$f_code].name|escape}
                    </td>
                    <td class="value" itemprop="{$f_code|escape}"> 
                        {if is_array($f_value)} 
                            {if $features[$f_code].type == 'color'} 
                                {foreach $f_value as $v_id => $value} 
                                    {if in_array($v_id,$feature_images[$f_code]['id'])} 
                                        {$v_img = "<img src='"|cat:$feature_images[$f_code]['img'][$v_id]|cat:"' title='"|cat:$feature_images[$f_code]['value'][$v_id]|cat:"' class='alaali_img2' >"}
                                        {$v_img} {$feature_images[$f_code]['value'][$v_id]}<br /> 
                                    {else} 
                                        <span style="padding-left: 11px; line-height: 150%;">{$value}</span><br /> 
                                    {/if} 
                                {/foreach} 
                            {else} 
                                {foreach $f_value as $v_id => $value} 
                                    {if in_array($v_id,$feature_images[$f_code]['id'])} 
                                        {$v_img = "<img src='"|cat:$feature_images[$f_code]['img'][$v_id]|cat:"' title='"|cat:$feature_images[$f_code]['value'][$v_id]|cat:"' class='alaali_img2' />"}
                                        {$v_img} <span>{$feature_images[$f_code]['value'][$v_id]}</span><br /> 
                                    {else} 
                                        <span style="padding-left: 33px; line-height: 150%;">{$value|escape}</span><br /> 
                                    {/if} 
                                {/foreach} 
                            {/if} 
                        {else} 
                            {assign var=v_id value=$f_value} 
                                {if in_array($v_id,$feature_images[$f_code]['id']) || in_array($v_id,$feature_images[$f_code]['value'])} 
                                    {$v_img = "<img src='"|cat:$feature_images[$f_code]['img'][$v_id]|cat:"' title='"|cat:$feature_images[$f_code]['value'][$v_id]|cat:"' class='alaali_img2' />"}
                                    {$v_img}<br /> 
                                {else} 
                                    <span style="padding-left: 33px; line-height: 150%;">{$f_value|escape}</span><br /> 
                                {/if} 
                        {/if} 
                    </td> 
                </tr> 
            {/foreach}
        </table>
    {/if}
{/capture}


Последнее обновление: 27 марта 2018
Эта статья была полезна? Да Нет

0 комментариев


    Добавить комментарий

    Чтобы добавить комментарий, зарегистрируйтесь или войдите