1

我正在尝试在 Magento 中设置分组产品。我想要完成的是添加“添加到购物车” - 每个分组选项后面的按钮,该按钮仅将此产品添加到购物车而不是孔分组产品。

我已经设法获得“阅读更多”按钮来使用

<?php echo $this->htmlEscape($_item->getProductUrl()) ?>

这将显示产品。

问题是,当我添加“添加到购物车”按钮时它显示错误,因为我还没有选择金额。(加入购物车前请选择数量)

是否可以为分组产品设置默认金额 = 1,然后为每个产品添加“添加到购物车”按钮?就像我对“阅读更多”所做的那样?

更新
这是我的 grouped.phtml 的外观:

?>
<?php $this->setPreconfiguredValue(); ?>
<?php $_product = $this->getProduct(); ?>
<?php $_associatedProducts = $this->getAssociatedProducts(); ?>
<?php $_hasAssociatedProducts = count($_associatedProducts) > 0; ?>
<?php if ($_product->isAvailable() && $_hasAssociatedProducts): ?>
    <p class="availability in-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('In stock') ?></span></p>
<?php else: ?>
    <p class="availability out-of-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
<?php echo $this->getChildHtml('product_type_data_extra') ?>
<table class="data-table grouped-items-table" id="responsive-table">
    <thead>
    <tr>
        <th><?php echo $this->__('Product Name') ?></th>
        <th><?php echo $this->__('Metode (hvordan)') ?></th>
        <th><?php echo $this->__('Sted (hvor)') ?></th>
        <th><?php echo $this->__('Tilgængelighed') ?></th>
        <th><?php echo $this->__('Fast Startdato') ?></th>
        <?php if ($this->getCanShowProductPrice($_product)): ?>
        <th><?php echo $this->__('Price') ?></th>
        <?php endif; ?>
        <?php if ($_product->isSaleable()): ?>
        <th><?php echo $this->__('Qty') ?></th>
        <?php endif; ?>
    </tr>
    </thead>
    <tbody>
    <?php if ($_hasAssociatedProducts): ?>
    <?php foreach ($_associatedProducts as $_item): ?>
    <?php $_finalPriceInclTax = $this->helper('tax')->getPrice($_item, $_item->getFinalPrice(), true) ?>
    <tr>
        <td data-title="Produkt navn"><?php echo $this->htmlEscape($_item->getName()) ?></td>
        <td data-title="Metode (hvordan)"><?php echo $_item->getAttributeText('prod_media'); ?></td>
        <td data-title="Sted (hvor)"><?php echo $_item->getAttributeText('prod_place_region'); ?></td>
        <td data-title="Tilgængelighed"><?php echo $_item->getAttributeText('prod_availability'); ?></td>
        <td data-title="Fast Startdato"><?php echo $this->htmlEscape($_item->getprod_date_startday()); ?></td>
        <td data-title="Pris">
        <?php if ($this->getCanShowProductPrice($_item)): ?>
        <?php echo $this->getPriceHtml($_item, true) ?>
        <?php echo $this->getTierPriceHtml($_item) ?>
        <?php endif; ?>
        </td>

        <?php echo $this->getTierPriceHtml($_item) ?></td>
        <?php if ($_product->isSaleable()): ?>
        <td>



        <button type="button" title="Læs mere" class="button " onclick="setLocation('<?php echo $this->htmlEscape($_item->getProductUrl()) ?>'); return false; "><span><span>Læs mere</span></span></button>
        <input type="button" title="<?php echo $this->__('Add to Cart') ?>" class="addtocart" onclick="setLocation('<?php echo Mage::getUrl('checkout/cart/add', array('product'=>$row['product_id'],'qty'=>1)) ?>')" />
        <?php if ($_item->isSaleable()) : ?>
        <input type="text" name="super_group[<?php echo $_item->getId() ?>]" maxlength="12" value="<?php echo $_item->getQty()*1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
        <?php else: ?>
        <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
        <?php endif; ?>

        </td>
        <?php endif; ?>
    </tr>
    <?php endforeach; ?>
    <?php else: ?>
       <tr>
       <td colspan="<?php if ($_product->isSaleable()): ?>4<?php else : ?>3<?php endif; ?>"><?php echo $this->__('No options of this product are available.') ?></td>
       </tr>
    <?php endif; ?>
    </tbody>
</table>
<script type="text/javascript">decorateTable('super-product-table')</script>
4

2 回答 2

1
 array('product'=>$_item->getId(),'qty'=>1)) ?>')"
于 2014-04-27T18:03:25.800 回答
0

编辑

<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="addtocart" onclick="setLocation('<?php echo Mage::getUrl('checkout/cart/add', array('product'=>$_product->getProductId(),'qty'=>1)) ?>')"/>
于 2013-03-06T21:37:42.320 回答