2013-04-17 28 views
0

我是Magento的新手。 我正在使用產品詳細信息頁面中的foreach以表格格式顯示屬性。 我面臨的問題是當我在任何數量框中輸入數值時,它將最後一個數值輸入購物車頁面,因爲我使用foreach循環來顯示數量框。我需要顯示我輸入的確切數值數量框。 代碼:將從多個數量框中輸入的數量框值從magento中取出到購物車頁面

<table border="1" style="width:100%;"> 
      <thead> 
       <tr> 
        <th>Fabric</th> 
        <th>Color</th> 
        <th>Required Qty</th> 
        <th>Total Cost</th> 
        <th>Cart</th> 
       </tr> 
      </thead> 
      <?php 

$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'fabric'); 
$buttonTitle = $this->__('Add to Cart'); 
$i=0;foreach ($attribute->getSource()->getAllOptions(true, true) as $option){ 
    $i++; 
if($i==1) continue; 
?> 

      <tbody> 

       <tr> 
        <td> 
         <?php echo $attributeArray[$option['value']] = $option['label']; 
?> 
        </td> 
        <td> 
         <select name="color" id="color"> 
          <option>Select Color</option> 
         <?php 
         $color = Mage::getModel('eav/config')->getAttribute('catalog_product', 'fabric_color'); 
$j=0;foreach ($color->getSource()->getAllOptions(true, true) as $option_color){ 
    $j++; 
    if($j==1) continue;?> 
    <option value="<?php echo $option_color['value'];?>" price="<?php echo $option_color['price'];?>"><?php echo $option_color['label'];?></option> 


<? } 
         ?> 
          </select> 
        </td> 
        <td> 

         <?php if($_product->isSaleable()): ?> 
         <div class="add-to-cart"> 
          <?php if(!$_product->isGrouped()): ?> 
          <label for="qty"><?php echo $this->__('Qty:') ?></label> 
          <div class="qty_pan"> 
           <input type="text" name="qty" id="qty<?=$i;?>" maxlength="12" value="1" title="<?php echo $this->__('Qty') ?>" class="input-text qty" /> 
          </div> 
          <?php endif; ?> 
         </div>  
         <?php endif; ?> 

        </td> 
        <td ><span class="qty<?=$i;?>" id=""><?php echo $_product->getPrice();?></span></td> 
        <td> 
         <button type="button" title="<?php echo $buttonTitle ?>" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><span><?php echo $buttonTitle ?></span></span></button> 
<!--      <span id='ajax_loader' style='display:none'><img src='<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif')?>'/></span>--> 

     <?php //echo $this->getChildHtml('', true, true) ?> 

        </td> 
       </tr> 

      </tbody> 

<?php }?> 
     </table> 

截圖: https://imageshack.us/scaled/large/12/detailpage.png

任何幫助表示讚賞!

回答

0

我得到了解決方案。

我們可以使用查詢字符串將數量值提取到購物車。

Yourdomain.com/checkout/cart/add?product=getId();?> &數量= 1

可以使用在HREF上述查詢字符串。

希望這有助於。

相關問題