What is the difference between .js and .js.liquid in shopify?

In the "Resources" section there are files with the names .jsand .js.liquid.

What is the difference between 2 that I should use if I want to include a js file in a theme?

This is in the .js.liquid file right now. I would like to build a string consisting of a liquid variable. when I add this line inside the DOM element, it does not seem to appear.

var someString = '';
  {%for line in order.line_items%}
  someString += 'q='+{{line.quantity}}+'&p='+{{line.product.id}}+'&pp='+{{line.price}}+'&w='+{{line.grams}}+'&i='+{{line.product.featured_image|product_img_url|url_param_escape}}+'&n='+{{line.product.title|url_param_escape}}+'&';
  {%endfor%}

$('body').append(someString);
+4
source share
1 answer

You can use liquid in files .js.liquid, but .jsfiles only have javascript.

If you include a regular js file, use the extension .js. If you have fluid in the file, you need to use .js.liquid.

EDIT:

, order .js.liquid. :

, " " , , " ".

. Shopify:

.

: , .css.liquid .js.liquid , .css .js, . - ...

, Shopify ( ) .

+4

All Articles