Loyalty Opt In/Out

swellAPI.updateOptInCustomer(opts, onSuccess, onError)

This function can be used to opt customers in or out of the loyalty program. An opted in customer / loyalty member can earn/redeem points and get into tiers. An opted out customer will lose point balance and tier status. You need to pass the shouldOptIn with true, to opt a customer in, or false - to opt them out. If you wish to also award a customer with the create account campaign upon opting in, you should pass rewardOnOptIn:true as one of the opts.

$(document).on("swell:setup", function() {


      var onSuccess = function() {
        $("#success").show();
      }

      var onError = function(err) {
        $("#error").show();
      }

        swellAPI.updateOptInCustomer({shouldOptIn:true}, onSuccess, onError)

    });
  });
$(document).on("swell:setup", function() {


      var onSuccess = function() {
        $("#success").show();
      }

      var onError = function(err) {
        $("#error").show();
      }

        swellAPI.updateOptInCustomer({shouldOptIn:false}, onSuccess, onError)

    });
  });

Options

ParameterTypeDescription
shouldOptInboolean (true/false)Whether the customer in question should be opted in or out
rewardOnOptInboolean (true/false)Whether you would like to reward the customer with the create account reward upon opting them in

Parameters

ParameterTypeDescription
onSuccessfunctionThe function to be called if the customer is opted in / out successfully
onErrorfunctionThe function to be called if the customer is opted in / out unsuccessfully