这是我为virtuemart定制代码的一部分。问题在于数量框。基本上,用户能够更新购物车中第一个商品的价值,但之后的任何商品都因某些原因无法更改。它只是抛回数字“1”:我该如何解决?
<?php
$i = 1;
// vmdebug('$this->cart->products',$this->cart->products);
foreach ($this->cart->products as $pkey => $prow) {
?>
<div>
<div style="border-bottom:1px solid #f2f2f2;padding-top:12px;padding-bottom:12px;">
<div style="display:table-cell;width:345px;">
<?php if ($prow->virtuemart_media_id) { ?>
<span class="cart-images">
<?php
if (!empty($prow->image)) {
echo $prow->image->displayMediaThumb ('', FALSE);
}
?>
</span>
<?php } ?>
<?php echo JHTML::link ($prow->url, $prow->product_name) . $prow->customfields; ?>
</div>
<div style="display:table-cell;width:75px;text-align:center;">
<?php
// vmdebug('$this->cart->pricesUnformatted[$pkey]',$this->cart->pricesUnformatted[$pkey]['priceBeforeTax']);
echo $this->currencyDisplay->createPriceDiv ('basePriceVariant', '', $this->cart->pricesUnformatted[$pkey], FALSE);
// echo $prow->salesPrice ;
?>
</div>
<div style="display:table-cell;width:95px;text-align:center;">
<div style="display:inline-block;"><form action="<?php echo JRoute::_ ('index.php'); ?>" method="post" class="inline" id="quantity-update">
<input type="hidden" name="option" value="com_virtuemart"/>
<input type="text" autocomplete="off" class="quantity-input-checkout" size="2" maxlength="2" name="quantity" value="<?php echo $prow->quantity ?>"/>
<input type="hidden" name="view" value="cart"/>
<input type="hidden" name="task" value="update"/>
<input type="hidden" name="cart_virtuemart_product_id" value="<?php echo $prow->cart_item_id ?>"/></div>
<div style="display:inline-block;vertical-align:middle;margin-left:6px;"><a href="javascript:{}" onclick="document.getElementById('quantity-update').submit(); return false;" class="tip" title="Update the product quantity in the cart." id="store_cart_refresh" style="margin-right:7px;"><span class="alt"></span></a>
</form>
<a class="tip" title="Remove this product from the cart." href="<?php echo JRoute::_ ('index.php?option=com_virtuemart&view=cart&task=delete&cart_virtuemart_product_id=' . $prow->cart_item_id) ?>" id="store_cart_delete"><span class="alt"></span></a></div>
</div>
<div style="display:table-cell;width:100px;text-align:center;">
<?php echo "<span class='priceColor2'>" . $this->currencyDisplay->createPriceDiv ('taxAmount', '', $this->cart->pricesUnformatted[$pkey], FALSE, FALSE, $prow->quantity) . "</span>" ?>
<?php
if (VmConfig::get ('checkout_show_origprice', 1) && !empty($this->cart->pricesUnformatted[$pkey]['basePriceWithTax']) && $this->cart->pricesUnformatted[$pkey]['basePriceWithTax'] != $this->cart->pricesUnformatted[$pkey]['salesPrice']) {
echo '<span class="line-through">' . $this->currencyDisplay->createPriceDiv ('basePriceWithTax', '', $this->cart->pricesUnformatted[$pkey], TRUE, FALSE, $prow->quantity) . '</span><br />';
}
echo $this->currencyDisplay->createPriceDiv ('salesPrice', '', $this->cart->pricesUnformatted[$pkey], FALSE, FALSE, $prow->quantity) ?>
</div>
</div>
</div>
<?php } ?>
<?php
$i = ($i==1) ? 2 : 1;
?>
答案 0 :(得分:0)
输入名称是数量......它应该类似于quantity_id so quantity_1,quantity_2等,否则可能很难以正确的顺序获取后端的值。