CakeCarts/templates/Carts/index.php

84 lines
3.5 KiB
PHP

<?php
/**
* @var \App\View\AppView $this
* @var \CakeCarts\Model\Entity\Cart $cart
*/
?>
<div class="carts index content">
<h3><?= __('My Cart') ?></h3>
<div class="table-responsive">
<table>
<thead>
<tr>
<th><?= '#' ?></th>
<th><?= 'Foreign Key' ?></th>
<th><?= 'Model' ?></th>
<th><?= 'Qty' ?></th>
<th><?= 'Price' ?></th>
<th><?= 'Subtotal' ?></th>
<th class="actions"><?= __('Actions') ?></th>
</tr>
</thead>
<tbody>
<?php
$cnt = 1;
foreach ($cart->cart_items as $cartItem): ?>
<?php /* @var \CakeCarts\Model\Entity\CartItem $cartItem */ ?>
<tr>
<td><?= $cartItem->position === null ? $cnt : $this->Number->format($cartItem->position) ?></td>
<td><?= $cartItem->foreign_key_uuid ?? $cartItem->foreign_key ?></td>
<td><?= $cartItem->model; ?></td>
<td>
<?= $this->Form->control('qty', [
'label' => false,
'min' => 1,
'step' => 1,
'default' => $cartItem->qty,
'value' => $cartItem->qty,
'style' => 'width: 120px;',
'type' => 'number',
'data-cart-item-id' => $cartItem->id,
'hx-put' => $this->Url->build([
'controller' => 'CartItems',
'action' => 'edit',
$cartItem->id,
]),
'hx-swap' => 'none',
'hx-include' => '[name="_csrfToken"], [data-cart-item-id="' . $cartItem->id . '"]',
]) ?>
</td>
<td>
<?= $this->Form->control('price', [
'label' => false,
'min' => 0,
'default' => $cartItem->price,
'value' => $cartItem->price,
'style' => 'width: 120px;',
'type' => 'text',
'data-cart-item-id' => $cartItem->id,
'hx-put' => $this->Url->build([
'controller' => 'CartItems',
'action' => 'edit',
$cartItem->id,
]),
'hx-swap' => 'none',
'hx-include' => '[name="_csrfToken"], [data-cart-item-id="' . $cartItem->id . '"]',
]) ?>
</td>
<td><?= $cartItem->subtotal === null ? '' : $this->Number->currency($cartItem->subtotal, 'USD') ?></td>
<td class="actions">
<?= $this->Form->postLink(__('Delete'), [
'controller' => 'CartItems',
'action' => 'delete',
$cartItem->id
], ['confirm' => __('Are you sure you want to delete # {0}?', $cartItem->id)]) ?>
</td>
</tr>
<?php
$cnt++;
endforeach; ?>
</tbody>
</table>
</div>
</div>