Mukesh
Mukesh

Reputation: 7778

How to add "add to wishlist" button on product detail page in Magento

I am new to Magento.I am learning it. I want to add a button "Add to Wishlist" near to "add to cart" button in Magento product detail page. How can I do this so that the selected product will be added to wishlist.

Please Help Thanks.

Upvotes: 2

Views: 29511

Answers (4)

Gabriel
Gabriel

Reputation: 31

Simple go to: ...catalog/product/view/addto.phtml and then:

<a href="<?php echo $this->
helper('wishlist')->getAddUrl($_product) ?>">
<?php echo $this->__('Add to Wishlist') ?></a>

Upvotes: 3

Prithweema
Prithweema

Reputation: 141

Use the following code for 'Add to wishlist' button

<a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" 
   class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a>

Use the following code for 'Add to cart' button

<button type="button" title="<?php echo $this->__('Add to Cart') ?>" 
   class="button btn-cart" 
   onclick="setLocation('<?php echo $this->helper('checkout/cart')->getAddUrl($_product) ?>')">
    <span>
        <span><?php echo $this->__('Add to Cart') ?></span>
    </span>
</button>

Upvotes: 1

Doug McLean
Doug McLean

Reputation: 1309

I would have written this as a comment on Anx's answer but I don't have 50 reputation yet (funny system, surely comments are more trivial than answers?) so I'm adding another answer instead.

If you still have trouble after following Anx's advice then maybe you've got the same odd situation that I had - no entry in the core_config_data table for the config setting "wishlist/general/active". Even though it was marked as active in the admin panel. To fix it, I simply went to System > Configuration > Wishlist and clicked "Save Config" without changing anything. Presto, the entry appeared in core_config_data (along with "wishlist/email/email_template", "wishlist/email/email_identity" and "wishlist/wishlist_link/use_qty").

Upvotes: 0

aforankur
aforankur

Reputation: 1293

This feature already exist in Magento.

If you want to check this feature via Code than check this out -

<div class="add-to-box">
   <?php echo $this->getChildHtml('addto') ?>
</div>

This Code you can find within [Theme]/template/catelog/product/view.phtml.

This code causes to call "Add to wishlist" button in Product Detail Page and this button comes from [Theme]/template/catelog/product/view/addto.phtml.

From here you can manage this Button.


You can also enable or disable this feature via Admin Section -

To control the display of the Add to Wishlist link:

  1. From the Admin panel, select System > Configuration.
  2. In the Configuration panel on the left, under Customers, select the Wishlist tab.
  3. Click to expand the General Options section and do one of the following:

    • Set Enabled to Yes to display the Add to Wishlist link on category pages and product pages.

    • Set Enabled to No to remove the Add to Wishlist link from category pages and product pages.


Hope it'll be helpful.

Thanks!

Upvotes: 3

Related Questions