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:
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.
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.
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.
Add the Function
Inside queries.js, you’ll need a function called getPrices. For now, you can keep it simple, like this:
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:
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.
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