Using Liquid variable inside a JavaScript snippet

Topic summary

Problema técnico en Shopify checkout: se intenta usar la variable de Liquid line_item.final_line_price dentro de un snippet de JavaScript que recorre Shopify.checkout.line_items para sumar importes de productos en oferta y a precio completo.

  • El código actual usa Shopify.checkout.line_items[i].line_price, y eso sí funciona.
  • La duda central es cómo sustituirlo por line_item.final_line_price y por qué ese valor no está disponible en el mismo contexto.
  • “Liquid” se refiere al lenguaje de plantillas de Shopify, mientras que el snippet mostrado trabaja sobre datos JavaScript del objeto Shopify.checkout.

El fragmento de código es clave para entender la consulta. En el texto no aparece ninguna respuesta, decisión ni solución confirmada, por lo que la pregunta queda abierta.

Summarized with AI on March 7. AI used: gpt-5.4.

Hi All,

Here I have a snippet of JavaScript on the checkout of my Shopify store.

I would like to use the liquid variable:

line_item.final_line_price

instead of line_price

for (var i = 0; i < Shopify.checkout.line_items.length; i++) {
if (Shopify.checkout.line_items[i].compare_at_price != null) {
amountSale += parseFloat(Shopify.checkout.line_items[i].line_price);
} else {
amountFull += parseFloat(Shopify.checkout.line_items[i].line_price);
}
}

How would I go about achieving this? Why is line_price working but line_item.final_line_price isn’t?

Any assistance is much appreciated!