shoppingmallv2/app/Views/front/product/addCart.php
최준흠git config git config --helpgit config --global user.name 최준흠 42af053f90 shoppingmallv2 init...
2023-08-05 23:24:24 +09:00

21 lines
1.1 KiB
PHP

<?= form_open("ecommerce/addCart", ['method' => 'post']) ?>
<?= form_hidden("product_uid", $viewDatas['entity']->getPrimaryKey()) ?>
<input type="hidden" id="price" name="price" value="<?= ($viewDatas['entity']->getPrice()) * 1 ?>">
<?php
$quantityOptions = [DEFAULTS['EMPTY'] => "구매수량 선택"];
for ($i = 1; $i <= $viewDatas['entity']->getStock(); $i++) {
$quantityOptions[$i] = $i . "개";
}
?>
구매 수량 : <?= form_dropdown('quantity', $quantityOptions, 1, ['onChange' => "cal_price(this.options[this.selectedIndex].value)"]); ?>
구매 금액 : <span id="order_price"><?= number_format($viewDatas['entity']->getPrice() * 1) ?></span>원
<?= form_submit('', '최소:1 ~ 최대:' . $viewDatas['entity']->getStock(), array("class" => "btn btn-outline btn-primary")); ?>
<?= form_close(); ?>
<script>
function cal_price(quantity) {
var price = 0;
price = <?= $viewDatas['entity']->getPrice() ?> * quantity;;
document.getElementById('price').value = price;
document.getElementById('order_price').textContent = new Intl.NumberFormat().format(price);
}
</script>