0

私はMagentoを初めて使用します。商品詳細ページで foreach を使って属性を表形式で表示しています。私が直面している問題は、数量ボックスに値を入力すると、foreachループを使用して数量ボックスを表示しているため、カートページに最後の数量値が表示されることです.入力した正確な値を表示する必要があります数量ボックス。コード:

    <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

どんな助けでも大歓迎です!.

4

1 に答える 1

0

私は解決策を得ました。

クエリ文字列を使用して、数量値をカートにフェッチできます。

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

上記のクエリ文字列を href で使用できます。

お役に立てれば。

于 2013-05-16T12:09:25.620 に答える