What is the best way to disable the sharing feature inside the customers front end Wish List view of Magento 1.9.x? I've considered css but would prefer if it can be disabled in the code/layouts or code if it's not a hack, as the site I am working on is mainly private and requires login to view anything.
2 Answers
First Way: Share Button coming in bellow file
app\design\frontend\rwd\default\layout\wishlist.xml
OR
app\design\frontend\your_package\your_theme\layout\wishlist.xml
Find bellow code in above file
<block type="wishlist/customer_wishlist_button" name="customer.wishlist.button.share" template="wishlist/button/share.phtml" />
after comment like this way :
<!--<block type="wishlist/customer_wishlist_button" name="customer.wishlist.button.share" template="wishlist/button/share.phtml" />-->
Second Way: Add bellow code in local.xml file (app\design\frontend\your_package\your_theme\layout\local.xml
)
<?xml version="1.0"?>
<layout version="0.1.0">
<wishlist_index_index translate="label">
<reference name="customer.wishlist.buttons">
<action method="unsetChild"><name>customer.wishlist.button.share</name></action>
</reference>
</wishlist_index_index>
</layout>
-
Thanks Abdul, I used your second option (less work when theme is updated)! Works perfectly. Commented Jan 12, 2016 at 7:56
-
-
Hi Abdul, unfortunately my rep here is not good enough to vote! Answer accepted. I promise as soon as I get some rep I'll be back! Thanks again! Commented Jan 12, 2016 at 9:14
-
-
Also you could add the following in local.xml. This will prevent the form from being used if accessed directly by url:
<wishlist_index_share><remove name="formkey"/></wishlist_index_share>
– cmtickleCommented Sep 8, 2017 at 12:06
I would recommend also unsetting block name "wishlist.sharing" as without doing so the wishlist can still be reached by url http://www.yourmagentowebsite.com/wishlist/index/share/wishlist_id/1234/ and could be exploited by spammers (1234 is wishlist ID).
Comment out the following in wishlist.xml like so:
<!--<block type="wishlist/customer_sharing" name="wishlist.sharing" template="wishlist/sharing.phtml" /> -->
or add this in your local.xml:
<wishlist_index_share translate="label">
<reference name="my.account.wrapper">
<action method="unsetChild"><name>wishlist.sharing</name></action>
</reference>
</wishlist_index_share>
-
This is a useful addition to the accepted answer which only removes the link but still allows the form itself to be accessed and used. However, for completely disabling the wishlist sharing we really need to ensure that the form action route /wishlist/index/send/ is also not available. Hopefully though a spammer would find it difficult or impossible to spoof the formkey required to post to that route.– BlueCCommented Apr 23, 2018 at 8:29