Hi Everyone!
I would really appreciate if anyone could give me a hand here
I’m on a very very tight deadline and there is no much I need to get done, so any pointers are really appreciated!!!
I’ve been trying to make this work:
So far I’ve created beside content:
- Two collections
Planestestimonial - #dataset1
tracking purchases - that corresponds to “PlanEvents” on the example //#tracking (write mode only) - button
#comprar. not connected to anything
ISSUES
On click event on #comprar does not open any lightbox on preview, nor prompts user to log in…
On Click event on #comprar does not save any record on tracking purchases collection
Here is the code I’m using on the dynamic Item page:
import wixWindow from ‘wix-window’ ;
import wixPay from ‘wix-pay’ ;
import wixPaidPlans from ‘wix-paid-plans’ ;
import wixUsers from ‘wix-users’ ;
$w.onReady( () => {
const currentPlanObject = $w( “#dataset1” ).getCurrentItem();
const planId = currentPlanObject._id;
const planPrice = currentPlanObject.price;
$w( ‘#comprar’ ).onClick((event) => {
let user = wixUsers.currentUser;
let isLoggedIn = user.loggedIn;
if (!isLoggedIn) {
wixUsers.promptLogin().then(() => {
processPlan(planId, planPrice);
})
} else {
processPlan(planId, planPrice);
}
});
});
function processPlan(myId, myPrice) {
if (myPrice > 0 ) {
wixPaidPlans.orderPlan(myId).then(orderObject => {
wixWindow.openLightbox( “confirm” , orderObject)
.then((goForIt) => {
if (goForIt) {
wixPay.startPayment(orderObject.wixPayOrderId);
}
});
})
} else {
wixPaidPlans.orderPlan(myId).then(orderObject => {
wixWindow.openLightbox( “congrats” , orderObject);
})
}
}
*/
export function repeater1_itemReady($item, itemData, index) {
}
export function comprar_click(event) {
}
AS FOR THE JS PAGE:
export function multiply(factor1, factor2) {
return factor1 * factor2;
}
// For inserting data into a collection.
import wixData from ‘wix-data’ ;
// The onPlanPurchased() event is fired when a plan
// is purchased, or a free plan is ordered.
// Get the order information
// from the event’s order object.
export function wixPaidPlans_onPlanPurchased(event) {
// The PlanEvents collection has a title field,
// in which we insert the type of transaction.
// The collection also has a data field,
// where we will insert information about the order
// from the event’s order object (json).
if (event.order.price.amount === 0 ) {
let orderData = {
“title” : “Free plan purchased” ,
“data” : event.order
};
wixData.insert( “Tracking purchases” , orderData);
} else {
let orderData = {
“title” : “Regular plan purchased” ,
“data” : event.order
};
wixData.insert( “Tracking purchases” , orderData);
}
}
Thanks!!!
Iz