0

有没有办法改变产品选项的位置?我想在产品数量下方显示选项。我试图调用 wrapper.phtmlapp/design/frontend/gallins/default/template/catalog/product/view/addtocart.phtml但无法使其正常工作。

我现在拥有的是:

- option
- qty
- add to cart button

但我不想在数量以下显示选项。

addtocart.phtml ->

<?php $_product = $this->getProduct(); ?>
<?php $buttonTitle = $this->__('Add to Cart'); ?>
<?php if ($_product->isSaleable()): ?>
<div class="add-to-cart">
    <?php if (!$_product->isGrouped()): ?>
        <div class="quantity">
            <label for="qty"><?php echo $this->__('Qty:') ?></label>
            <input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
            <div class="clear"></div>
        </div>
    <?php endif; ?>
    <!-- This is where I want to show options -->
    <button type="button" title="<?php echo $buttonTitle ?>" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><span><?php echo $buttonTitle ?></span></span></button>
    <?php echo $this->getChildHtml('', true, true) ?>
</div>

我试过<?php echo $this->getChildHtml('wrapper')了,但是没有用。

4

1 回答 1

0

您必须在 2 个文件中进行 2 处更改,就好像您有产品选项一样

addtocart.phtml

<?php $_product = $this->getProduct(); 
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());
?>

<?php $buttonTitle = $this->__('Add to Cart'); ?>
<?php if($_product->isSaleable()): ?>
    <div class="add-to-cart">
        <?php if(!$_product->isGrouped()): ?>

        <?php if (count($_attributes) == 0):?>
        <label for="qty"><?php echo $this->__('Qty:') ?></label>
        <input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
        <?php endif; ?>

        <?php endif; ?>
        <button type="button" title="<?php echo $buttonTitle ?>" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><span><?php echo $buttonTitle ?></span></span></button>
        <?php echo $this->getChildHtml('', true, true) ?>
    </div>
<?php endif; ?>

并且还请更改 options\configurable.phtml 文件更改,如下所示

<?php
$_product    = $this->getProduct();
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());
?>
<?php if ($_product->isSaleable() && count($_attributes)):?>
   <label for="qty"><?php echo $this->__('Qty:') ?></label>
        <input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />

    <dl>
    <?php foreach($_attributes as $_attribute): ?>
        <dt><label class="required"><em>*</em><?php echo $_attribute->getLabel() ?></label></dt>
        <dd<?php if ($_attribute->decoratedIsLast){?> class="last"<?php }?>>
            <div class="input-box">
                <select name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" class="required-entry super-attribute-select">
                    <option><?php echo $this->__('Choose an Option...') ?></option>
                  </select>
              </div>
        </dd>
    <?php endforeach; ?>
    </dl>
    <script type="text/javascript">
        var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);
    </script>
<?php endif;?>

让我知道我是否可以为您提供更多帮助。

于 2013-05-15T11:57:50.353 回答