App reviews, troubleshooting, and recommendations
Hello.
I have custom product where I by AJAX Cart API sent to cart properties:
query RunInput { cart { lines { id quantity cost { amountPerQuantity { amount currencyCode } } customId: attribute(key: "_customId") { value } airFreightFee: attribute(key: "_airFreightFee") { value } totalPrice: attribute(key: "_total_price") { value } merchandise { ... on ProductVariant { id product { title } } } } } }run.ts
// src/run.ts import type { RunInput, FunctionRunResult, CartOperation, } from "../generated/api"; export function run(input: RunInput): FunctionRunResult { const operations: CartOperation[] = []; for (const line of input.cart.lines) { const totalPriceStr = line.totalPrice?.value; const airFreightFeeStr = line.airFreightFee?.value; if (!totalPriceStr) continue; const basePrice = parseFloat(totalPriceStr); if (isNaN(basePrice)) continue; const airFreightFee = parseFloat(airFreightFeeStr || "0"); const freightTotal = !isNaN(airFreightFee) ? airFreightFee * line.quantity : 0; const finalPrice = (basePrice + freightTotal) / 100; const title = airFreightFee ? `${line.merchandise.product.title} (Air Freight Fee: ${(freightTotal / 100).toFixed(2)} UAH)` : line.merchandise.product.title; operations.push({ update: { cartLineId: line.id, title, price: { adjustment: { fixedPricePerUnit: { amount: finalPrice.toFixed(2), }, }, }, }, }); console.log(` Updating ${line.id} to ${finalPrice.toFixed(2)} UAH`); } return { operations, }; }
{ "cart": { "lines": [ { "id": "gid://shopify/CartLine/a1a82e84-86f1-4995-9517-c88d59877344", "quantity": 1, "cost": { "amountPerQuantity": { "amount": "109.0", "currencyCode": "UAH" } }, "customId": { "value": "custom-conf-1746618826593" }, "airFreightFee": { "value": "10000" }, "totalPrice": { "value": "13400" }, "merchandise": { "id": "gid://shopify/ProductVariant/50898623037604", "product": { "title": "IP65 Mini Linear Actuator" } } } ] } }
{ "operations": [ { "update": { "cartLineId": "gid://shopify/CartLine/a1a82e84-86f1-4995-9517-c88d59877344", "title": "IP65 Mini Linear Actuator (Air Freight Fee: 100.00 UAH)", "price": { "adjustment": { "fixedPricePerUnit": { "amount": "234.00" } } } } } ] }
Updating gid://shopify/CartLine/a1a82e84-86f1-4995-9517-c88d59877344 to 234.00 UAH
BUT if add new not custom product
(no errors)
{ "cart": { "lines": [ { "id": "gid://shopify/CartLine/a7fe1afd-c796-4c7e-b603-512df30aa115", "quantity": 1, "cost": { "amountPerQuantity": { "amount": "50.0", "currencyCode": "UAH" } }, "customId": null, "airFreightFee": null, "totalPrice": null, "merchandise": { "id": "gid://shopify/ProductVariant/46289428709540", "product": { "title": "Gift Card" } } }, { "id": "gid://shopify/CartLine/a1a82e84-86f1-4995-9517-c88d59877344", "quantity": 1, "cost": { "amountPerQuantity": { "amount": "109.0", "currencyCode": "UAH" } }, "customId": { "value": "custom-conf-1746618826593" }, "airFreightFee": { "value": "10000" }, "totalPrice": { "value": "13400" }, "merchandise": { "id": "gid://shopify/ProductVariant/50898623037604", "product": { "title": "IP65 Mini Linear Actuator" } } } ] } }
{ "operations": [ { "update": { "cartLineId": "gid://shopify/CartLine/a1a82e84-86f1-4995-9517-c88d59877344", "title": "IP65 Mini Linear Actuator (Air Freight Fee: 100.00 UAH)", "price": { "adjustment": { "fixedPricePerUnit": { "amount": "234.00" } } } } } ] }
Updating gid://shopify/CartLine/a1a82e84-86f1-4995-9517-c88d59877344 to 234.00 UAH
I have not ideas what is wrong. Need help. Thank you.
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025