Skip to content
Advertisement

How to send specific line item data to third party script

I’m trying to send price, name and id of each item in the order, plus an extra static value to a single js variable formatted in this way,

items = eventID::price::name|eventID::price::name|eventID::price::name

I was trying to do it this way, but I’m getting an error on the last line which I mean to add a pipe if there is more than one product.

JavaScript

That hasn’t worked so far, so I thought maybe I should create a custom object that contains the variables instead:

JavaScript

and then call the items in a list later like

JavaScript

I had also tried using JSON to encode the data but the third party told me that is not going to work for their needs.

Edit: Code is now doing everything I need it to, but it’s only pulling one item from the list instead of a string of all of them.

Here’s what it looks like now based on the help I got here:

JavaScript

Advertisement

Answer

I think this all can be simplified to just use array’s implode() method. Below are what I would do in your situation:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement