Skip to main content

Do not send if all products in a cart have a value of 0

Learn to check that at least one product in a cart has a valid price before sending.

Updated over 3 weeks ago

Use this Trigger script to check that at least one product in a cart has a valid price before sending. Add the following code snippet to the Script that controls whether this trigger program is run field of a trigger program.

result.proceed = true;
var prods = helpers.getProducts();
var zeroPrice = helpers.productsMatch(prods, 'uv', [0]);

console.log("Zero Prices - " + zeroPrice);
console.log("Total Products - " + prods.length);
console.log("Are they the same? " + (prods.length == zeroPrice).toString());

if (prods.length == zeroPrice) {
result.proceed = false;
}

Did this answer your question?