简体   繁体   中英

quantity box not updating PHP

this is part of my customised code for virtuemart. the issue is with the quantity box. basically, a user is able to update the value for the first item in the cart, but any items after that cannot be changed for some reason. it just throws back the number "1": how can i fix it?

<?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;
 ?>

输入名称为quantity ...,其名称应类似于quantity_id,因此quantity_1,quantity_2等,否则可能很难以正确的顺序获取后端的值。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM