From dbae23ac66141abe076ac1125f75f6beb6f96fb1 Mon Sep 17 00:00:00 2001 From: Kevin Grinberg Date: Wed, 12 Oct 2016 23:31:39 -0400 Subject: [PATCH] Handling for decorative covers (DC- SKUS) --- app.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 6f689ec..9b9c9f2 100755 --- a/app.py +++ b/app.py @@ -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)}) @@ -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')