通过zapier购买google-sheets以获取新的付费订单客户地址,电子邮件,电话和产品购买信息。问题是,当购买中有多个商品时,我只会检索到第一个商品。
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