Cart Transform Functions Not being applied

ZaniRexha
Shopify Partner
1 0 0

Hello everyone,

I have been having some issues with shopify functions. I am currently using the cart transform "purchase.cart-transform.run". 

I tested it in a dev store and my function gets triggered every time the cart is changed, but I installed it in my live store and the function is never getting triggered. I reverted all my code and put it in the simplest possible manner, so just applying a price of 100 to every item in the cart.

// @ts-check

/**
 * @typedef {import("../generated/api").RunInput} RunInput
 * @typedef {import("../generated/api").FunctionRunResult} FunctionRunResult
 */

/**
 * @type {FunctionRunResult}
 */
const NO_CHANGES = {
  operations: [],
};

/**
 * @param {RunInput} input
 * @returns {FunctionRunResult}
 */


export function run(input) {
  console.error("Running cart...");
  console.error(JSON.stringify(input));
  const updates = input.cart.lines.map((line) => {
      return {
        update: {
          cartLineId: line.id,
          title: "This was updated",
          price: {
            adjustment: {
              fixedPricePerUnit: {
                amount: 100
              }
            }
          }
        }
      }
  }).filter(value => value);


  return {
    operations: updates,
  };
}


I would like to know why this is not being triggered at all on one store, and always working on the other.

Replies 0 (0)