But, if I assign the ID manually, rather than using $ smarty.foreach.mycart.index, then everything works.
Please tell me what I'm doing wrong?
__________
Пытаюсь сделать, чтобы при нажатии на кнопку удалить товар из тележки, но при данном шаблоне тележка очищается полностью.
Но, если я приписываю ID вручную, а не использую $smarty.foreach.mycart.index, то все работает.
Подскажите пожалуйста что я делаю неправильно?
Code: Select all
{* viewcartform template *}
<style>
.viewcartform th {
text-align: left;
}
</style>
<div class="viewcartform">
{* if the smarty variable orders_simpleviewcart is not set, then don't provide a form for adjusting quantities *}
{if !isset($cartitems) || count($cartitems) == 0 }
<div class="alert alert-warning">Your cart is empty</div>
{else}
{if isset($formstart) && !isset($orders_simpleviewcart)}{$formstart}{/if}
<table class="table" width="100%">
<thead>
<tr>
<th>1</th>
<th>2</th>
<th>3</th>
<th>4</th>
<th>5</th>
<th>6</th>
<th width="1%">DELETE</th>
</tr>
</thead>
<tbody>
{foreach from=$cartitems item='oneitem' name='mycart'}
<tr>
<td>{$oneitem->sku}</td>
<td>{$oneitem->summary}</td>
<td>
{if $oneitem->type != 1 || !isset($oneitem->quantity_box)}
{$oneitem->quantity}
{else}
{$oneitem->quantity_box}
{/if}
</td>
<td>{$oneitem->unit_price|as_num:2} {$currencysymbol}</td>
<td>{$oneitem->unit_discount|as_num:2} {$currencysymbol}</td>
<td>{$oneitem->item_total|as_num:2} {$currencysymbol}</td>
<td>{if isset($oneitem->remove_box)}
{assign var=ids value=$smarty.foreach.mycart.index}
<input type="hidden" id="checkbox{$smarty.foreach.mycart.index}" name="md899bcart_remove_{$smarty.foreach.mycart.index}" value="1">
<button onclick="$(`#checkbox{$smarty.foreach.mycart.index}`).val(`0`);document.getElementById(`md899bmoduleform_1`).submit();" name="md899bcart_adjust" class="remove" >×</button>
{/if}
{debug}
</td>
</td>
</tr>
{/foreach}
</tbody>
<tfoot>
<tr>
<td colspan="5" align="right">Вес заказа:</td>
<td>≈ {math equation="x / y" x=$cartweight y='100' format="%d"} кг</td>
<td></td>
</tr>
<tr>
<td colspan="5" align="right">ИТОГО:<br>
<em>({$Cart2->Lang('infosubtotal')})</em>
</td>
<td>{$currencysymbol}{$carttotal|as_num:2}</td>
<td></td>
</tr>
{if isset($formstart) && !isset($orders_simpleviewcart)}
<tr>
<td colspan="7">
<input type="submit" name="{$actionid}cart_empty_cart" value="{$Cart2->Lang('empty_cart')}"/>
</td>
</tr>
{/if}
</tfoot>
</table>
{if isset($formstart) && !isset($orders_simpleviewcart)}{$formend}{/if}
{/if}
</div>