Hi, I created a post purchase extension, and at the moment I have this problem, when I show the extension I always notice that after purchases the shipping cost is never applied for the purchased product, even though I applied it, can you help me?
setPurchaseOption((prevPurchaseOption) => ({
...prevPurchaseOption,
changes: [
{
...prevPurchaseOption.changes[0],
variantID: parseInt(selectVariant.replace('gid://shopify/ProductVariant/', '')),
discount: {
...prevPurchaseOption.changes[0].discount,
value: prevPurchaseOption.productDiscountType == '%' || prevPurchaseOption.productDiscountType == 'currency' ? parseFloat(prevPurchaseOption.productDiscount) : priceSelectVariant - parseFloat(prevPurchaseOption.productDiscount),
}
},
{
type: 'add_shipping_line',
price: offer.freeShipping ? 0 : parseFloat(offer.shippingCost)
}
]
}));
I apply the correct type to the changes object, and then send it to the sign-changeset API, as explained in the guide on shopify.dev
const signRes = await fetch(`${APP_URL}/api/sign-changeset`, {
method: "POST",
headers: {
Authorization: `Bearer ${inputData.token}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
referenceId: inputData.initialPurchase.referenceId,
changes: purchaseOption,
}),
});
const { token } = await signRes.json();
// Make a request to Shopify servers to apply the changeset.
let result = await applyChangeset(token);