top of page

Forum Comments

"Buy Now" widget/link from Mindbody not working in Wix
In Coding with Velo
Redirect user after they purchase a plan
In Coding with Velo
Yakup
Dec 31, 2021
Copying the code I used on one of my sites. You need to add the event handler to the backend as well. Naturally you'll need to change the planIDs and page urls plus the image (#group4) that shows during the plan purchase confirmation. This works but the same code does not work on another site. Maybe @Yisrael (Wix) might give us some insight. // API Reference: https://www.wix.com/velo/reference/api-overview/introduction // “Hello, World!” Example: https://learn-code.wix.com/en/article/1-hello-world import wixLocation from 'wix-location'; import wixData from 'wix-data'; import wixUsers from 'wix-users'; function getUTCTime() { var utcTime = new Date() utcTime.setMinutes(utcTime.getMinutes() + utcTime.getTimezoneOffset()) console.log(utcTime) return utcTime } $w.onReady(async function () { let date = new Date() console.log(date) let newDate = date.setMinutes(date.getMinutes() - 1); console.log(date) wixLocation.onChange(async (location) => { let newPath = location.path; if (newPath.includes("status")) { // wixLocation.to("/paid-plan-purchase"); $w('#group4').show() $w('#membershipPlanPickerTpa1').hide() let user = wixUsers.currentUser; let userId = user.id; await wait(4000); let date = await getUTCTime() console.log(date) let newDate = date.setMinutes(date.getMinutes() - 1); console.log(date) wixData.query("PaidPlanPurchases") .eq("paymentStatus", "PAID") .eq("memberId", userId) //.ge("_createdDate", newDate) .find() .then((results) => { if (results.items.length > 0) { console.log("Found") let firstItem = results.items[0]; console.log(firstItem) let plan = firstItem.planID if (plan === "41e4fcbc-9ef9-4a21-adf9-46c5913638a9") { wixLocation.to("https://www.mattsoule.com/account/free-membership"); } else if (plan === "bfea41d3-a4bf-4f19-aec6-95346d3830fb") { wixLocation.to("https://www.mattsoule.com/account/master-stress-membership"); } } else { console.log("NotFound") $w('#group4').hide() $w('#membershipPlanPickerTpa1').show() // $w('#text108').show() // $w('#button1').show() } }) .catch((err) => { let errorMsg = err; }); } }); }); function wait(ms = 500) { return new Promise((res) => { setTimeout(() => { res("done") }, ms); }); } ===Backend js.=== import wixData from 'wix-data'; export function wixPaidPlans_onPlanPurchased(event) { console.log("Triggered") console.log(event) let plan = event.order.planId let toInsert = { "planID": event.order.planId, "memberId": event.order.memberId, "paymentStatus": event.order.paymentStatus, }; wixData.insert("PaidPlanPurchases", toInsert) .then((results) => { let item = results; console.log(item) console.log("Inserted to Database") }) .catch((err) => { let errorMsg = err; console.log("Error Inserted to Database") console.log(errorMsg) }); } export function test() { var utcTime = new Date() utcTime.setMinutes(utcTime.getMinutes() + utcTime.getTimezoneOffset()) console.log(utcTime) return utcTime }
1
0
Redirect user after they purchase a plan
In Coding with Velo
how do you make an infinite rotating animation?
In Site & Page Design
Amazing scroll effects with Editor X and Velo
In Coding with Velo
Yakup
Dec 07, 2021
Awesome. Thank you!
1
0
Amazing scroll effects with Editor X and Velo
In Coding with Velo
Redirect after member pricing plan sign up?
In Coding with Velo
Yakup
Nov 27, 2021
Here is a code that worked on one of my sites but it seems to not work on another one. You'll need to change the PlanID numbers and the page where you want to redirect the user to. #group4 is a loading icon gif which you can replace with your own. Let me know if this works for you. import wixLocation from 'wix-location'; import wixData from 'wix-data'; import wixUsers from 'wix-users'; $w.onReady(function () { wixLocation.onChange(async (location) => { let newPath = location.path; if (newPath.includes("status")) { // wixLocation.to("/paid-plan-purchase"); $w('#group4').show() $w('#membershipPlanPickerTpa1').hide() let user = wixUsers.currentUser; let userId = user.id; await wait(3000); let date = new Date() console.log(date) let newDate = date.setMinutes(date.getMinutes() - 1); console.log(date) wixData.query("PaidPlanPurchases") .eq("paymentStatus", "PAID") .eq("memberId", userId) .ge("_createdDate", date) .find() .then((results) => { if (results.items.length > 0) { console.log("Found") let firstItem = results.items[0]; console.log(firstItem) let plan = firstItem.planID if (plan === "41e4fcbc-9ef9-4a21-adf9-46c5913638a9") { wixLocation.to("/account/free-membership"); } else if (plan === "bfea41d3-a4bf-4f19-aec6-95346d3830fb") { wixLocation.to("/account/master-stress-membership"); } } else { console.log("NotFound") $w('#group4').hide() $w('#membershipPlanPickerTpa1').show() // $w('#text108').show() // $w('#button1').show() } }) .catch((err) => { let errorMsg = err; }); } }); }); function wait(ms = 500) { return new Promise((res) => { setTimeout(() => { res("done") }, ms); }); }
1
1
Redirect after member pricing plan sign up?
In Coding with Velo
Yakup
Nov 27, 2021
@pm325 Not even :)
How to make an image zoom with mouse scroll
In Coding with Velo
Integrate Affirm API with Wix?
In Coding with Velo
Integrate Affirm API with Wix?
In Coding with Velo

Yakup

More actions

This website was designed with Velo by Wix

bottom of page