Preventing customers from canceling specific products in Affinity

Leverage custom code in Affinity to prevent customers from canceling specific products.

Merchants may want to prevent customers from canceling specific products.

This guide explains how you can use the product ID to prevent customers from canceling specific products, and have the customer contact the merchant instead for assistance.

πŸ“˜

Platform:

  • Shopify Checkout Intergration
  • Recharge Checkout on Shopify

Implementing cancelation prevention for specific products

Use the following script to prevent customers from canceling specific products. Replace <PRODUCTID> with the actual product ID from the merchant's ecommerce platform:

<script>
// Define the list of product IDs that are not eligible for direct cancellation
const uncancellableProductIds = [<PRODUCTID>];

// Customize the message to guide customers to contact you
const alertMessage = "To cancel this product, please reach out to us at [email protected]";

// Listen for the cancellation flow event
document.addEventListener(
  "Recharge::extension::cancellation_flow",
  (event) => {
    const { subscription } = event.detail;
    const subscriptionProductId = subscription.shopify_product_id;
    
    // Check if the product is in the list of uncancellable products
    if (uncancellableProductIds.includes(subscriptionProductId)) {
      // Prevent the default cancellation flow
      event.preventDefault();
      
      // Display an alert to guide customers
      window.alert(alertMessage);
    }
  }
);
</script>

🚧

Warning

It is important to consider and incorporate Automatic Renewal Laws (ARL) into any custom cancelation process to ensure legal compliance. See Automatic Renewal Law (ARL) and Recharge to learn more about ARLs and how Recharge remains compliant, providing you with insights into how to configure your own setup.

How the script works

The script listens for the cancelation event trigger that the customer triggers and checks if the product matches the restricted IDs:

  • If there's a match, the cancelation process is interrupted and a message displays advising customers to contact support for assistance.
  • If there is not a match, the customer is sent through the regular cancelation process.

πŸ“˜

Note:

You must be on the Recharge Pro plan, or a Custom plan, to make advanced customizations to the Affinity customer portal.




Need Help? Contact Us