Единицы измерений msProductOptions

Есть два вопроса
Первый

Вывод списка опций
[[!msProductOptions?
&onlyOptions=`long`
&tpl=`myOpt`]]
Чанк myOpt
{foreach $options as $option}
    <div class="row">
        <div class="col-7"><strong>{$option.caption}:</strong></div>
        <div class="col-5">
            {if $option.value is array}
                {$option.value| join : ', '}{$option.measure_unit}
            {else}
                {$option.value}{$option.measure_unit}
            {/if}
        </div>
    </div>
{/foreach}
На выходе получаю


Как подставить единицы измерения для каждого размера, а не в конце строки.


И второй вопрос как подставить единицы измерения в корзину
Вывод корзины
[[!msCart?
               &tpl=`cartTpl2`
               &includeThumbs=`cart`
               ]]
Место в чанке с выводом опций
{if $product.options?}
                                {foreach $product.options as $key => $option}
                                    {if $key in ['modification','modifications','msal']}{continue}{/if}
                            
                                    {set $caption = $product[$key ~ '.caption']}
                                    {set $caption = $caption ? $caption : ('ms2_product_' ~ $key) | lexicon}
                                    
                                    {if $option is array} 
                                    {$caption} - {$option | join : '; '}
                                    {else}
                                    
                                    {$caption}: {$option}
                                    {/if}
                                    
                                {/foreach}
                            {/if}
Весь чанк корзины

{$_modx->lexicon->load('minishop2:product')}

<div id="msCart">
  <h1 class="h2">[[*pagetitle]]<p class="ms2_total_count" id="prodCount">{$total.count}</p><span id="countLex"></span></h1>
    {if !count($products)}
        {'ms2_cart_is_empty' | lexicon}
    {else}
        <div class="table-responsive">
            <table class="table table-striped cart-product_row">

                {foreach $products as $product}
                    <tr class="cart_tr" id="{$product.key}">
                        <td class="image">
                          <div class="d-flex cart_row">
                            <div class="cartIm">
                                                      
                            {* get main modification *}
			    {set $modification = []}
                            {if $product.options and $product.options.modification?}
                                {set $modification = $_modx->runSnippet('!msOptionsPrice.modification',[
                                'product' => $product.id,
                                'includeThumbs' => 'cart',
                                'where' => json_encode([
                                    'msopModification.id' => $product.options.modification
                                ]),
                                'return' => 'data'
                                ])}
                                {set $modification = $modification[0]}
                            {/if}
                            
                            {*$modification|print_r*}
                            {if $modification['cart']?}
                                {set $product.cart = $modification['cart']}
                            {/if}
			    {if $modification['old_price']?}
			    	{set $product.old_price = $modification['old_price']}
			    {/if}
			    
                           
                            {* get all modification *}
                            {if $product.options and $product.options.modifications?}
                                {set $modifications = $_modx->runSnippet('!msOptionsPrice.modification',[
                                'product' => $product.id,
                                'type' => '1,2,3',
                                'sortby'=> 'type',
                                'includeThumbs' => 'cart',
                                'where' => json_encode([
                                    'msopModification.id:IN' => $product.options.modifications
                                ]),
                                'return' => 'data'
                                ])}
                            {/if}
                          
                            
                           
                            {if $product.cart?}
                                <a href="{$product.id | url}"><img class="cart_thumb" src="{$product.cart}" alt="{$product.pagetitle}" title="{$product.pagetitle}"/></a>
                            {else}
                                <img src="{'assets_url' | option}components/minishop2/img/web/ms2_small.png"
                                     srcset="{'assets_url' | option}components/minishop2/img/web/ms2_small@2x.png 2x"
                                     alt="{$product.pagetitle}" title="{$product.pagetitle}"/>
                            {/if}
                            </div>
                            <div class="cartTi">
                            {if $product.id?}
                                <span class="prodTitle"> {$product.pagetitle}</span>
                            {else}
                                {$product.name}
                            {/if}
                            
                            {*print_r($product)*}
                            
                           
                            
                            {if $product.options?}
                                {foreach $product.options as $key => $option}
                                    {if $key in ['modification','modifications','msal']}{continue}{/if}
                            
                                    {set $caption = $product[$key ~ '.caption']}
                                    {set $caption = $caption ? $caption : ('ms2_product_' ~ $key) | lexicon}
                                    
                                    {if $option is array} 
                                    {$caption} - {$option | join : '; '}
                                    {else}
                                    
                                    {$caption}: {$option}
                                    {/if}
                                    
                                {/foreach}
                            {/if}
                            
        
                            
                            {if $modifications}
                               <span class="prodTitle"> Артикул: 
                                {foreach $modifications as $tmp}
                                    {$tmp['article']}
                                {/foreach}
                                </span>
                            {/if}
                            
                           
                            </div>
                            
                            </div>
                        </td>
                        
                        <td class="price">
                            <span class="mr-2 text-nowrap">{$product.price} </span> р
                        </td>
                        <td class="count">
                            <form method="post" class="ms2_form" role="form">
                                <input type="hidden" name="key" value="{$product.key}"/>
                                <div class="form-group">
                                    <div class="input-group">
                                      <div class="quantity">
                  											<input type="number" name="count" value="{$product.count}" class="form-control" min="1" max="1000" step="1" value="1"/>
                  										</div>
                                    </div>
                                    <button class="btn" type="submit" name="ms2_action" value="cart/change">↻</button>
                                </div>
                            </form>
                        </td>
                        <td class="product_cost">
                          <div class="product_cost-wrapper">
                              <span class="prodNew">{$product.cost}</span>
                              р
                            </div>
                        </td>
                        <td class="remove">
                            <form method="post" class="ms2_form text-md-right">
                                <input type="hidden" name="key" value="{$product.key}">
                                <button class="btn btn-danger cart_reset" type="submit" name="ms2_action" value="cart/remove"><span></span></button>
                            </form>
                        </td>
                    </tr>
                {/foreach}

               
            </table>
            
             <div class="cart_footer">
                <div class="total_cost">
                    <span class="total_cost-lex">Общая сумма</span>
                    <span class="ms2_total_cost h2">{$total.cost}</span> <span class="h2">p</span>
                </div>
                <a href="[[~35]]" class="button button-red">Оформить заказ</a>
            </div>
        </div>


    {/if}
</div>
На выходе получаю
Юрий
12 октября 2019, 07:44
modx.pro
764
0

Комментарии: 0

Авторизуйтесь или зарегистрируйтесь, чтобы оставлять комментарии.
0