E-commerce order quantity is zero

@Lukas
Hi Everyone? I am tracking e-commerce order, It is working exactly fine but it is not tracking products in the order.

Here is my code to add products in e-commerce order.

Any help would be appreciated why quantity is being tracked as zero? Thanks! 
var items={{ order.line_items | json}};
var i;
for (i = 0; i < items; ++i) {
_paq.push(['addEcommerceItem',
  items[i].sku, // (required) SKU: Product unique identifier
  items[i].product_title, // (optional) Product name
  "", // (optional) Product category. You can also specify an array of up to 5     categories eg. ["Books", "New releases", "Biography"]
  items[i].price, // (Recommended) Product Price
  1 // (Optional - Defaults to 1)
]);

You can’t compare a number with an object

Hi @Lukas ? Thank you so much for quick help. Sorry, it was my mistake in the code, I have updated it, but still showing quantity as zero instead of 1. There is also no logs for products.

var i;
for (i = 0; i < items.length; ++i) {
console.log(items[i].title);
console.log( items[i].price);
_paq.push(['addEcommerceItem',
  items[i].sku, // (required) SKU: Product unique identifier
  items[i].title, // (optional) Product name
  "", // Category
  items[i].price, // (Recommended) Product Price
  1 
]);

Let me also tell you that in my case the SKU is an empty string. Can you please guide me why products are not being tracked?

Hi,

I know really little about E-Commerce tracking, but are you calling trackEcommerceCartUpdate as explained in https://matomo.org/docs/ecommerce-analytics/?

Hi @Lukas , Thank you very much for your kind guidance. yes Product view snippet and Category view snippets were missing. The screenshot is attached.

Here is my final code.

//Tracking Product Views in Matomo
var items={{ order.line_items | json}};
console.log(items);
for (var i = 0; i < items.length; ++i) {
_paq.push([‘setEcommerceView’,
“”, // (Required) productSKU
items[i].title, // (Optional) productName
“Accessories”, // (Optional) categoryName
items[i].price // (Optional) price
]);
}
//Tracking Category Views in Matomo
_paq.push([‘setEcommerceView’,
false, // Product name is not applicable for a category view.
false, // Product SKU is not applicable for a category view.
“”,
]);

//Adding a Product to the order
var i;
for (i = 0; i < items.length; ++i) {
_paq.push([‘addEcommerceItem’,
“123456789”, // (required) SKU: Product unique identifier
items[i].title, // (optional) Product name
[" Accessories"],
items[i].price, // (Recommended) Product Price
1 // (Optional - Defaults to 1)
]);
}
//Tracking the Ecommerce Order
_paq.push([‘trackEcommerceOrder’,
{{order.order_number}} , // (Required) orderId
{{order.total_price}}, // (Required) grandTotal (revenue)
{{order.total_price}}, // (Optional) subTotal
‘’, // (optional) tax
‘’, // (optional) shipping
false // (optional) discount
]);
The screenshot of Matomo also attached.