Skip to content

Instantly share code, notes, and snippets.

@Sentinel-7
Last active February 2, 2023 14:53
Show Gist options
  • Save Sentinel-7/356d6a61fbd80ef0bc3e7dc872005b26 to your computer and use it in GitHub Desktop.
Save Sentinel-7/356d6a61fbd80ef0bc3e7dc872005b26 to your computer and use it in GitHub Desktop.
Выводим опции с проверкой остатков msOptionsPrice2
{set $tmp = '!msOptionsPrice.modification'|snippet:[
'product' => $_modx->resource.id,
'tpl' => 'tpl.msOptionsPrice.modification',
'return' => 'data',
'processOptions' => 1,
'showZeroPrice' => 0
]}
{if $tmp?}
<div class="size-row">
{'!msOptionsPrice.option' | snippet : [
'options' => 'size,color' ~ $_modx->config.msoptionsprice_include_modification_options,
'tpl' => '@INLINE {foreach $options as $name => $values}
<div class="card_content_info-label">{("ms2_product_" ~ $name) | lexicon}:</div>
<div class="selector">
<select name="options[{$name}]" class="selector__input input-sm form-control" id="option_{$name}">
<option value="" disabled>Пожалуйста, выберите</option>
{/foreach} '
]}
{foreach $tmp as $key => $row}
{set $mod = $row.modification}
{set $options = $row.options}
{if $mod.count > 0}
{foreach $options as $name => $v index=$index}
{if ($name|preg_match:'#.key#')}{var $k = $v}{else}{continue}{/if}
{set $value = $options[$k~'.value']}
{set $caption = $options[$k~'.caption']}
{set $unit = $options[$k~'.measure_unit']}
<option value="{$value}" name="options[{$k}]" id="options-{$k}-{$key}-{$_modx->resource.id}"> {$value}</option>
{/foreach}
{/if}
{/foreach}
</select>
</div>
</div>
{/if}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment