Zapier run Python not getting all product line items names

189 views Asked by At

Shopify to google-sheets via zapier to get new paid order customer address, email, phone and product purchased information. The problem is, when there is more than one item in the purchase I only get the first product retrieved.

def combine_pairings(listing):
    out = []
    for index, val in enumerate(listing):
        if index % 2:
            continue
        out.append("{} {}".format(val, listing[index+1]))
    return out

def get_index(lst, index):
    try:
        return lst[index]
    except:
        return 'empty'

units = input['units'].split(',')
products = input['product'].split(',')
time = combine_pairings(input.get('time', '').split(','))

output = []

for index, product in enumerate(products):
    output.append({
        'units': get_index(units, index),
        'product': product,
        'phone': input['phone'],
        'customer_note': input.get('customer_note', ''),
        'address': input['address'],
        'status': input['status'],
        'customerlastname': input['customerlastname'],
        'customerfirstname': input['customerfirstname'],
        'email': input['email'],
        'time': get_index(time, index)
    })

return output

enter image description here

0

There are 0 answers