Add to cart button in related product page in magento
to add "add to cart" button on related product page please open the related.phtml page:-
app/design/frontend/default/your theme/template/catalog/product/list/related.phtml
add below line of code in related .phtml page:-
<form action="<?php echo $this->getAddToCartUrl($_item) ?>" method="post" id="product_addtocart_form_<?php echo $_item->getId()?>"<?php if($_item->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
<?php if(!$_item->isGrouped()): ?>
<input type="text" name="qty" id="qty" maxlength="12" value="<?php echo ($this->getMinimalQty($_item)?$this->getMinimalQty($_item):1) ?>" />
<label for="qty"><?php echo $this->__('Qty') ?>:</label>
<?php endif; ?>
<button type="button" onclick="this.form.submit()"><span><span><span><?php echo $this->__('Add to Cart') ?></span></span></span></button>
</form>
Your are Done!!!!!!!!!!!!!!
to add "add to cart" button on related product page please open the related.phtml page:-
app/design/frontend/default/your theme/template/catalog/product/list/related.phtml
add below line of code in related .phtml page:-
<form action="<?php echo $this->getAddToCartUrl($_item) ?>" method="post" id="product_addtocart_form_<?php echo $_item->getId()?>"<?php if($_item->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
<?php if(!$_item->isGrouped()): ?>
<input type="text" name="qty" id="qty" maxlength="12" value="<?php echo ($this->getMinimalQty($_item)?$this->getMinimalQty($_item):1) ?>" />
<label for="qty"><?php echo $this->__('Qty') ?>:</label>
<?php endif; ?>
<button type="button" onclick="this.form.submit()"><span><span><span><?php echo $this->__('Add to Cart') ?></span></span></span></button>
</form>
Your are Done!!!!!!!!!!!!!!
Purushotam You Just Rock.....
ReplyDeleteWhen I add the first related product to the cart - it strangely adds to main product to the cart and the related product.
ReplyDeleteWhen I add the second related product on the list - then everything is fine... also with #3, ¤4 and so on.
But the first product fails - do you know why?
Thanks for your comments, please let me know which magento version you using So i can check this issue..
ReplyDeleteI think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article. Best Magento 2 Hosting Plans
ReplyDelete