我需要从第一个产品中删除“添加到购物车”按钮。
请指导我编辑list.phtml文件中的代码。
<p>
<?php
if ($merchant_name){
?>
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>">
<button type="button" title="View Product Detail" class="button btn-cart"><span><span>View Product Detail</span></span>
</button>
</a>
<?php }
if ($product = Mage::getModel('catalog/product')->load($_product->getId()));
{
?>
<?php if ($product->getIsEbayaffiliate()) { ?>
<a href="<?php echo $product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>">
<button type="button" title="View Product Detail" class="button btn-cart"><span><span>View Product Detail</span></span>
</button>
</a>
<?php } else { ?>
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="<?php if($enableAjax): ?>setLocationAjax<?php else: ?>setLocation<?php endif; ?>('<?php echo $this->getAddToCartUrl($_product) ?>','<?php echo $_product->getId()?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span>
</button>
<?php } ?>
<?php } ?>
</p>
<?php } else { ?>
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="<?php if($enableAjax): ?>showOptions('<?php echo $_product->getId()?>')<?php else: ?>setLocation('<?php echo $this->getAddToCartUrl($_product) ?>','<?php echo $_product->getId()?>')<?php endif;?>"><span><span><?php echo $this->__('Add to Cart') ?></span></span>
</button>
<a href='<?php echo $this->getUrl(' ajax/index/options ',array('product_id '=>$_product->getId()));?>' class='fancybox' id='fancybox<?php echo $_product->getId()?>' style="display: none;"><?php echo $this->__('Add to Cart') ?></a>
<?php } ?>
<?php else: ?>
<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
如果您需要完整的代码,请告诉我。
答案 0 :(得分:0)
只需删除以下代码:
else { ?>
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="<?php if($enableAjax): ?>setLocationAjax<?php else: ?>setLocation<?php endif; ?>('<?php echo $this->getAddToCartUrl($_product) ?>','<?php echo $_product->getId()?>')"><span> <span><?php echo $this->__('Add to Cart') ?></span></span>
</button>
<?php } ?>
请注意braclets!
并进一步移除<button>
一些行:
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="<?php if($enableAjax): ?>showOptions('<?php echo $_product->getId()?>')<?php else: ?>setLocation('<?php echo $this->getAddToCartUrl($_product) ?>','<?php echo $_product->getId()?>')<?php endif;?>"><span><span><?php echo $this->__('Add to Cart') ?></span></span>
答案 1 :(得分:0)
解析错误:语法错误,意外'}' 您的代码中存在一些语法错误。检查php和html之间的所有大括号来解决它。之后,只需删除添加到购物车的按钮标签即可。