PriceQuotes | getPriceQuote()

Question:
I’m having trouble getting getPriceQuote() to return data. I’m getting “Unable to handle the request.” I’ll paste the code below.

Product:
Wix Editor

What are you trying to achieve:
I have saved the quote id and am trying to get the data related to that quote to display on a member page.

What have you already tried:
I used the velo api data to write my code.

Additional information:
This is my code in a backend .jsw file. createQuote() does what it’s supposed to. findQuote() does not. I have checked that I am definitely entering the method and can return test data but priceQuotes.getPriceQuote(quoteId.id) is causing the error msg "Unable to handle the request. "

import { priceQuotes } from 'wix-billing-backend';
import wixData from 'wix-data';

export async function createQuote(cartData, user, quoteData, subtotal) {
    const now = new Date()
    const dueDate = new Date()
    dueDate.setDate(now.getDate() + 30)

    let customer = {
        "contactId": user.contactId,
        "email": user.loginEmail,
        "address": {
            "city": quoteData.qCity,
            "subdivision": quoteData.qShippingLine1,
            "postalCode": quoteData.qZip,
            "country": "USA",
            "addressLine": quoteData.qShippingLine1
        },
        "billingAddress": {
            "country": "USA",
            "streetAddress": {
                "value": user.contactDetails.addresses[0].addressLine,
                "type": "Name"
            },
            "addressLine": user.contactDetails.addresses[0].addressLine,
            "addressLine2": user.contactDetails.addresses[0].addressLine,
            "postalCode": user.contactDetails.addresses[0].postalCode,
            "subdivision": user.contactDetails.addresses[0].subdivision,
            "city": user.contactDetails.addresses[0].city
        },
        "shippingAddress": {
            "country": "USA",
            "streetAddress": {
                "value": quoteData.qShippingLine1,
                "type": "Name"
            },
            "addressLine": quoteData.qShippingLine1,
            "addressLine2": quoteData.qShippingLine2,
            "postalCode": quoteData.qZip,
            "subdivision": quoteData.qShippingLine1,
            "city": quoteData.qCity
        },
        "phone": quoteData.qPhone,
        "firstName": quoteData.qFirstName,
        "lastName": quoteData.qLastName
    };

    let lineItems = [];
    cartData.forEach(product => {
        let description = "";
        let options = product.options;
        options.forEach(selectedOption => {
            description = description + selectedOption.selection + " ";
        });
        let item = {
            "id": product.productId,
            "name": product.name,
            "description": description,
            "price": product.price,
            "quantity": product.quantity
        };
        lineItems.push(item);
    });

    let discount = {
        "value": 0,
        "type": "Fixed"
    };

    let paymentTerms = {
        "termData": "some term data",
        "termType": "DueOnReceipt"
    };

    let dates = {
        "issueDate": now,
        "validThroughDate": dueDate
    };

    let metadata = {
        "notes": quoteData.qNotes
    };
    try {
        let createPriceQuoteFields = {
            "title": quoteData.qLastName + " " + "Freight Quote",
            "customer": customer,
            "currency": "USD",
            "lineItems": lineItems,
            "discount": discount,
            "paymentTerms": paymentTerms,
            "dates": dates,
            "metadata": metadata
        };
        const name = user.contactDetails.firstName + " " + user.contactDetails.lastName;
        priceQuotes.createPriceQuote(createPriceQuoteFields)
            .then((result) => {
                let toInsert = {
                    "quoteId": result.id,
                    "email": user.loginEmail,
                    "title": name,
                    "subtotal": subtotal
                };
                wixData.insert("PendingCarts", toInsert)
                    .then(() => {
                        return true;
                    }).catch((err) => {
                        console.log("Error saving quote id in CMS: ", err);
                        return false;
                    });
            })
    } catch (error) {
        console.log("Backend error creating quote: ", error)
    }
}

export function findQuote(quoteId) {
    return priceQuotes.getPriceQuote(quoteId.id);      
}

Can you share the code that is calling findQuote()?

Sorry I initially misread what you were asking for. Here is the code that calls findQuote():

export function listContainer_click(event) {
    const data = $w("#pendCartListRepeater").data;
    let clickedItemData = data.find(item => item._id === event.context.itemId);
    if (pendingCarts.length == 1) {
        showCartData(pendingCarts[0])
    } else {
        findQuote(clickedItemData.quoteId.id)
            .then((result) => {
                showCartData(result);
            })
    }
}

I think the issue is here. The code is sending clickedItemData.quoteId.id to the findQuote(quoteId) function and then that function is trying to access the quoteId.id within it but that’s already been done in the initial call. So it’s kind of trying to access clickedItemData.quoteId.id.id between the calls which doesn’t exist.

Perhaps:

export function findQuote(id) {
    return priceQuotes.getPriceQuote(id);      
}

Good catch and I’m so grateful that you took the time to look at this. Unfortunately, after making that correction, it still doesn’t work.

Are you seeing a new error message? Can you share it if so?