0

For some reason adding a product to my wishlist changes the markup of my add to wishlist button.

Screenshots:

Before adding to wishlist

<a href="#" class="action towishlist wishlist-button" data-post="data-post-here" data-action="add-to-wishlist"><span>+ Add to wishlist</span></a>

enter image description here

After adding to wishlist

<div class="split button wishlist">
        <button type="button" data-post="data-post-here" data-action="add-to-wishlist" class="label action split">
            <span>+ Add to wishlist</span>
        </button>
        <button class="action toggle change" title="Add to:" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
            <span>Add to:</span>
        </button>
        <ul class="items" data-target="dropdown" aria-hidden="true">

                <li class="item">

                        <span data-post="data-post-here" data-action="add-to-wishlist" title="Wish List">
                            Wish List
                        </span>

                </li>

                <li class="item">

                        <span class="action new" data-post-new-wishlist="data-post-here" data-action="add-to-wishlist" title="Create New Wish List">
                            <span>Create New Wish List</span>
                        </span>

                </li>

        </ul>
    </div>

enter image description here

The template used to render the wishlist and add to bag button is /var/www/vhosts/client-name/production/htdocs/app/design/frontend/**VENDOR**/**THEME**/Magento_Catalog/templates/product/view/addtocart.phtml.

Yet once a product has been added to my wishlist it appears to use this template - vendor/magento/module-multiple-wishlist/view/frontend/templates/behaviour.phtml.

1 Answer 1

0

It appears the reason for this is to render a dropdown with additional options such as add a product to a new wishlist.

As I don't require this functionality I've removed the behaviour.phtml template via my XML. The button now remains consistent, the only downside is the user now needs to go to the wishlist page to add a new wishlist.

app/design/frontend/**VENDOR**/**THEME**/Magento_Catalog/layout/catalog_product_view.xml

<?xml version="1.0" ?>
<page layout="3columns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <!-- Remove wishlist behaviour -->
        <referenceBlock name="wishlist_behaviour" remove="true" />
    </body>
</page>

Hopefully this will help someone out who runs into the same confusion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.