How to let users select variants on the Wishlist page itself?

On the wishlist page, by default the user is prompted to visit the corresponding product page to select the variant whenever the variant selection is required before adding the item to Shopping Cart.

However, using some custom Javascript implementation, we can skip this step and display the list of available variants asynchronously on the Wishlist page itself.

Before (the default behavior)
After (modified behavior)


1. Create a new snippet titled wishlist-enhancements. It creates the file snippets/wishlist-enhancements.liquid. If this file already exists, skip this step.

2. Add the following code to it. If WishlistLoadedCallback is already defined, append the inner code of the following function to it.

{% unless template %}
<!-- Begin Smart Wishlist Callback -->
<script type="text/javascript">

      var temp_product_variant=$("#select_variant").val().split(".");

  $('#variant_selection_modal').on('', function(e) {

    var source_url=$(this).find("#visit_product_button").attr("data-url");     

    $.getJSON( source_url+".json", function(data) {
      var temp_select='<select id="select_variant">';
      var temp_variants = data.product.variants;
        temp_select+='<option value="'+temp_variant.product_id+'.''">'+temp_variant.title+'</option>';

{% endunless %}

3. Add the following code anywhere before closing </head> in layout/theme.liquid. If already added, you can skip this step.

{% include 'wishlist-enhancements' %} 

Leave a Reply

Your email address will not be published. Required fields are marked *