Requiring shoppers to login before they can add to wishlist

Intended Audience: Agencies / Software Developers / Shopify Experts / Merchants

This is an advanced feature and we recommend it is handled by a developer with knowledge on Shopify theme editor and programming skills such as HTML, CSS, Javascript and Liquid templating as required.

Before you customize a theme / Snippet, ensure you make a backup of your current live theme to make changes, so that you can discard and start again if needed.

Step 1: Navigate to your theme and click Actions > Edit code.

Step 2: Add a new file called swym-custom.liquid in the Snippets folder.

Add a new file called swym-custom.liquid to your Snippets folder. This file will contain the code for the login page redirect.

Step 3: Paste the below code to the newly created swym-custom.liquid file.

<!-- Custom Code to Add Wishlist behind Login. -->
<script defer>
  function swymCallbackFn(swat) {
    var isLoggedIn;
    {% if customer %}
    isLoggedIn = true;
    {% else %}
    isLoggedIn = false;
    {% endif %}
    if (isLoggedIn == false) {
      SwymUtils.getHostedURL = function() {
        /*    	Navigate to login page on click of swym-icons for wishlist page.*/
        return "/account/login";
      }
      //       Override launchpoints.
      swat.ui.open = function(){
        console.log("Not Logged IN!");
        swymRedirectToLogin();
      }
      //       Override default API implementations.
      swat.api.addToWishList = function(){
        console.log("Not Logged IN!");
        swymRedirectToLogin();
      }

//       Override API for Pop-up
      swat.ui.uiRef.addToWishlist =function(){
        console.log("Not Logged IN!");
        swymRedirectToLogin();
      }
    }
    function swymRedirectToLogin(customURL){
      var accountsPageURL = customURL || window.origin + "/account/login";
      window.location = accountsPageURL;
    }
  }
  if (!window.SwymCallbacks) {
    window.SwymCallbacks = [];
  }
  window.SwymCallbacks.push(swymCallbackFn);
</script>

This will ensure that your custom buttons are also given the same functionality.

Step 4: Include the file swym-custom.liquid to your theme.liquid. Include the newly added liquid file in the theme.liquid right below the swymSnippet.

 {% include 'swym-custom'%}

This would now ensure that the wishlist functionality is now behind a login.

Gorgias Integration - Early Access

Gift Registry- Early Access

Save for Later - Early Access

Let's discuss your needs!

Let's discuss your needs!

Let's discuss your needs!