Cannot find module ‘bookings-v2-pricing-spi’ ” with bookings custom pricing plugin

Hello

Trying to implement custom pricing plugin to ad a 3% surcharge into my base booking service price.

Followed this tutorial (which doesn’t work):

This is code in my .js file:

export function calculatePrice(options) {

const originalPrice = options.servicePrice;
const surchargePercentage = 3; // 3% surcharge
const surchargeAmount = originalPrice * (surchargePercentage / 100);
const totalPrice = originalPrice + surchargeAmount;

console.log("Calculating price for service:", options.serviceId);
console.log("Original price:", options.servicePrice);
console.log("Surcharge amount:", surchargeAmount);
console.log("Total price:", totalPrice);

return {
    calculatedPrice: Math.round(totalPrice * 100) // Convert to cents
};

}

this is the -config.js file:

export function getConfig() {
return {
pricingProviderName: “calculatePrice”,
};
}

Can someone please tell me where im going wrong?

Error logs:

“message”:
“Cannot read properties of null (reading ‘servicePrice’)”

The error you’re seeing, "Cannot read properties of null (reading 'servicePrice')" suggests that the options object passed to the calculatePrice function might not be populated properly or is null. This happens when servicePrice is not provided as expected, so the function is trying to access a property of a null or undefined object.

Thanks, yeah i seem to be having no end of trouble. The wix documentation is very poor, outdated, doesnt explain things…Ive now shifted to just trying to get this working:

Tutorial: Bookings Pricing Service Plugin

In this 1st part of the code:

import { getPrices } from ‘backend/queries’;
export const calculatePrice = async (options, context) => {
const prices = getPrices();
const additionalField

It fails on the import statement.

I assume this is cause “queries” needs to be setup as backend module. But the documentation doesnt explains this at all. or what should be contained in that module. to call the GetPrices function.

So frustrating!

Can anyone guide me?

I understand your frustration. Wix documentation can be a real pain when it skips the basics. you can try these steps and see if it works out for you.

  1. Create the Backend File
    In your site’s backend (where all the behind-the-scenes magic happens), add a file called queries.js. This is like setting up a kitchen where you’ll cook up your pricing info.
  2. Add the Function
    Inside queries.js, you’ll need a function called getPrices. For now, you can keep it simple, like this:

javascript

Copy code

export function getPrices() {
    return Promise.resolve([
        { id: 1, name: "Basic Package", price: 100 },
        { id: 2, name: "Premium Package", price: 200 }
    ]);
}

Think of it as a placeholder menu. You can swap it later for something more dynamic, like pulling prices from a database or an API.
3. Connect the Dots
Now, back in the frontend (the part users see), you’ll import that function like this:

javascript

Copy code

import { getPrices } from 'backend/queries';

This tells Wix to grab your pricing logic from the backend.
4. Test It Out
Try calling the function in your code and see if it gives you the prices:

javascript

Copy code

getPrices()
    .then(prices => console.log(prices))
    .catch(err => console.error("Oops, something went wrong:", err));

Open the browser console and make sure it’s spitting out your test data.

If it doesn’t work, don’t panic—it’s usually something small like a typo or Wix being temperamental. Let me know if you hit a snag, and we’ll sort it out!

Then so much for the effort in your response. Makes sense.

What I was originally trying to Achieve was some pricing logic that gets Calculated price for any booking service adds 3% Onto it As a service fee (To cover stripe cost) then presents the final cost to the client.

It should be so simple. I’ve attempted to use the tutorial above as a guide But even that wouldn’t work cause of the poor documentation.

Are you able to help me with my code?

Many thanks, Stu

yes we can help you with the work through a meeting where we can understand your problem even better and assist you in achieving what you want can you provide me anything through which we can connect

Hi thanks but I’m not looking for a paid engagement here if that is what you were meaning… rather some advice on a forum.

It should be a reasonably small snippet of code to achieve what I need to

Just was after a bit of a Headstart is all considering the documentation is so poor