Question:
How to redirect a user based on their subscription status?
Product:
Wix Editor on the Core premium plan
What are you trying to achieve:
I have a page which leads the user to the subscription page. I want to check, if the user has already subscribed, then they should be redirected to another page. The data being used is from Wix default data storage and there are no data collections created.
For users who have subscribed to your plans, do you want all the subscribers to go to the same page? Or do you want to redirect users based to specific pages based on the plans they have purchased, for example -
a person with a Gold Plan should be redirected to www.yoursite.com/gold-page
a person with a Platinum Plan should be redirected to www.yoursite.com/platinum-page
Then turn on Dev Mode from the toolbar at the top. You will see a code panel open up at the bottom.
Replace the code in the panel with the one I’ve provided below.
Make sure to rename plan1, plan 2 and plan3 and also their corresponding redirect URLs, i.e. redirect1, redirect2 and redirect3.
So lets say if the user has subscribed to the Gold Plan, the variables should be:
Thank you Pratham for sharing the code.
I have tried to use this code:
import { orders } from ‘wix-pricing-plans-frontend’;
import wixLocation from ‘wix-location’;
$w.onReady(function () {
// Function to handle button click
function handleDeepdiveButtonClick() {
let filters = {
‘orderStatuses’: [‘ACTIVE’]
};
When working with the listCurrentMemberOrders function, it’s essential to use the unique identifier (_id ) to check for specific orders, not the plan name. The _id field provides a reliable way to identify individual orders within your dataset.