Hi all,
I’m trying to use the Pricing-Plans-Backend postponeEndDate function and, while I can get it to work, I’m not quite sure how to set the date and time correctly? Here’s the code I have currently:
import { checkout , orders } from ‘wix-pricing-plans-backend’ ;
let options = {
suppressAuth : true
}
export async function wixPricingPlans_onOrderStarted ( event ) {
const orderId = event . entity . order . _id ;
**let** year = **new** Date (). getFullYear ();
**const** endDate = **new** Date ( 'December 31, ' + year + ' 07:00:00' )
**try** {
**const** order = **await** orders . postponeEndDate ( orderId , endDate , options );
**return** order ;
} **catch** ( error ) {
console . error ( error );
}
}
Essentially, once a user purchases a plan and starts it, I’m using this function to postpone the end date to December 31st of the current year.
I think that I’m doing this correctly but the date always defaults to December 30th - not the 31st.
I’ve played around and tried setting it to January 1st or 2nd of the next year to account for possible timezone differences but that hasn’t yielded anything decent and, in some weird cases, returned December 29th.
There doesn’t seem to be much about this particular function online aside from the Velo docs so I’m kind of at my wits end trying to troubleshoot it.
I’d really appreciate any advice anyone can offer!