2013-05-12 42 views
0

这是我为virtmart定制的代码的一部分。问题在于数量框。基本上,用户可以更新购物车中第一件商品的价值,但之后的任何商品都不能因某种原因而更改。它只是抛回数字“1”:我如何解决它?数量箱未更新PHP

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

输入名称是数量...它应该像这样quantity_id QUANTITY_1,QUANTITY_2等,否则可能很难抢在正确的顺序与后端的值。