How can I send the product IDs for an item array back to Pinterest?

I’m attempting to create a Checkout event to send to Pinterest Ads. I’m using custom javascript to transform my data, in particular I need to sum the item totals and total cart value since these are not being passed through the data layer.

I’ve been able to write the custom javascript for majority of all needed parameters for Pinterest except the product ID. The system is not picking it up in the array. I’ve tried seeing if I could get either the product name or product id to pass through. I initially tried id: items[i].id and the system wasn’t picking it up, so i’ve since tried product_id: items[i].id, and still no luck.

function() {
  var items = {{dlv - olo - all products}};
  var numItems = 0;
  var totalValue = 0;
  var transformedItems = [];

  for (var i = 0; i < items.length; i++) {
    transformedItems.push({
      product_id: items[i].id,
      product_name: items[i].name,
      product_category: 'product',
      quantity: items[i].quantity,
      price: items[i].price
    });
    numItems += items[i].quantity;
    totalValue += items[i].price
  }
  
  return {
    value: totalValue,
    currency: 'USD',
    line_items: transformedItems,
    order_quantity:  numItems,
    order_id: {{dlv - olo - transaction ID}}
  };
}

Here is the GTM custom HTML tag that I’m using to pull in the cjs:

<!-- Pinterest Pixel Code -->
<script>  
  pintrk('track', 'checkout', {{cjs - Pinterest Data For Purchases}})
</script>
<!-- End Pinterest Pixel Code -->

Here is the data layer push:

{
    event: "begin_checkout",
    ecommerce: {
        items: [
            {
                item_id: "42353541",
                item_name: "Avocado Hummus",
                currency: "USD",
                price: 8,
                quantity: 1
            },
            {
                item_id: "41371457",
                item_name: "Avocado Caesar Salad",
                currency: "USD",
                price: 10.95,
                quantity: 1
            }
        ]
    }
}