Hello.
I have custom product where I by AJAX Cart API sent to cart properties:
_total_price: totalPrice,
_airFreightFee: airFreightFee,
GOAL - change custom product line item price and add shipping fee on checkout
I’ve created cart transform api extension app:
run.graphql
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,
};
}
When in cart we have only custom products with properties - all works good.
But when I add another default product - custom product prices are not changes.. and I have not errors )))
Case with custom product:
Input (STDIN)
{
"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"
}
}
}
]
}
}
Output (STDOUT)
{
"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"
}
}
}
}
}
]
}
Logs (STDERR)
Updating gid://shopify/CartLine/a1a82e84-86f1-4995-9517-c88d59877344 to 234.00 UAH
BUT if add new not custom product
(no errors)
Input (STDIN)
{
"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"
}
}
}
]
}
}
Output (STDOUT)
{
"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"
}
}
}
}
}
]
}
Logs (STDERR)
Updating gid://shopify/CartLine/a1a82e84-86f1-4995-9517-c88d59877344 to 234.00 UAH
BUT
I have not ideas what is wrong. Need help. Thank you.

