Skip to content

Commit

Permalink
Handling for decorative covers (DC- SKUS)
Browse files Browse the repository at this point in the history
  • Loading branch information
kgrinberg committed Oct 13, 2016
1 parent 83cdacb commit dbae23a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,18 @@ def webhook():
Lines = SubElement(Order, "Lines")
line_item_num = 0
wholesale_lines = 0
dc_lines = 0
for line in data['line_items']:
# if the SKU starts with "WS", then it's wholesale - exclude it from this order
if line['sku'].startswith("WS"):
wholesale_lines += 1
continue

# if the SKU starts with "DC", then it's a decorative cover, fulfilled by Tranquilo - exclude it from this order
if line['sku'].startswith("DC"):
dc_lines += 1
continue

line_item_num += 1
Line = SubElement(Lines, "Line", {'number': str(line_item_num).zfill(3)})

Expand All @@ -195,8 +201,11 @@ def webhook():
if wholesale_lines > 0:
app.logger.info(u"Ignoring {} wholesale lines in order #{} from Shopify.".format(str(wholesale_lines), str(data['order_number'])))

if dc_lines > 0:
app.logger.info(u"Ignoring {} decorative cover lines in order #{} from Shopify.".format(str(dc_lines), str(data['order_number'])))

if line_item_num == 0:
app.logger.info(u"Ignoring order #{} from Shopify - all wholesale.".format(str(data['order_number'])))
app.logger.info(u"Ignoring order #{} from Shopify - all wholesale or decorative covers.".format(str(data['order_number'])))
return "OK"

xml_string = tostring(root, method='xml', encoding='UTF-8')
Expand Down

0 comments on commit dbae23a

Please sign in to comment.