I was wondering if anyone can please help me figure out why my code is not working?
I am using the Wix-Pricing-Plans Api and followed the instructions, but I am not able to trigger the startOnlinePurchase event for each item in my repeater.
When I check the console log I get all the plan information for the first plan in the repeater. (Plan Id, Price, Description etc.)
It should be simple and I am sure I am missing something small but just cannot figure out what it is sorry if anyone could help that would be greatly appreciated.
@certified-code I have not been able to fix this just wondering if you had any suggestions? If not no worries I will just have to try a different way but would prefer this method I just for some reason am struggling with this API.
I have now figured this out and it does work. Now it allows the current plan displayed in the repeater to be purchased directly by the click of the button.
Here is my code:
import wixPaidPlans from 'wix-paid-plans';
import wixData from 'wix-data';
$w.onReady( function () {
$w("#button1").onClick( (event) => {
let $item = $w.at(event.context);
let clickedItemData = $item("#dataset2").getCurrentItem();
let planId = clickedItemData._id
wixPaidPlans.orderPlan(planId)
.then((myOrder) => {
let myOrderId = myOrder.orderId;
let myWixPayOrderId = myOrder.wixPayOrderId;
console.log(planId);
});
})
})