User not getting updated in python API call any more

Highlighted
New Member
1 0 0

I am posting fulfillment update the same way we were doing before but it broke some time around April. Here is the code snipped and we are using version 4.0, python 2.7. Now the tracking is still being update but even though 'notify_customer': True it is not notifying customers, and we are having to do it manually by "editing" and "saving" that tracking, since on the web it has "notify customer" checkbox. And the same thing worked perfectly until some time in early spring 2019. 

 

Can someone please help!!

 

 

 


shopify_orders = self.order_connection.find(ids=shopify_order_id, status="any")
if len(shopify_orders) > 1:
raise LSAIShoppingException("Could not update shopify order: {} for sku: {}, as multiple matches "
"found in Shopify source".format(shopify_order_id, mcf_sku))
if len(shopify_orders) == 0:
raise LSAIShoppingException("Could not update shopify order: {} for sku: {}, "
"order not found in shopify!".format(shopify_order_id, mcf_sku))

shopify_order = shopify_orders[0]

shopify_sku = self.source["reverse_sku_mapping"][mcf_sku]
# now find the line item in the order that has this sku
for line_item in shopify_order.line_items:
if shopify_sku == line_item.sku:
matching_line_items = [line_item]
fulfillment_info = {
'order_id': shopify_order_id,
'line_items': matching_line_items,
'location_id': self.location_id,
'notify_customer': True
}

matched_fulfillment = None
# check to see if tracking exists if it does update it else create a new one
if len(shopify_order.fulfillments) > 0:
for fulfillment in shopify_order.fulfillments:
for f_line_item in fulfillment.line_items:
if f_line_item == line_item:
matched_fulfillment = fulfillment

# new fulfillment is true if it was just created OR a shipment update is asked for by the caller
# else we don't need to update shopify!
new_fulfillment = False
if matched_fulfillment is None:
print("Creating new fulfillment for order: {}, line_item: {}, shopify_sku: {}...".format(mcf_order_id, line_item, shopify_sku))
# create a new fulfillment if not found for sku and don't worry about setting shipment
matched_fulfillment = shopify.Fulfillment(fulfillment_info)
new_fulfillment = True

new_shipment = False
# not add shipment information if passed in
if mcf_shipment is not None:
new_shipment = True
matching_tracking_numbers = [mcf_shipment["TrackingNumber"]]
# now update the tracking info on the matched fulfillment
matched_fulfillment.tracking_company = mcf_shipment["CarrierCode"]
matched_fulfillment.tracking_numbers = matching_tracking_numbers
new_fulfillment = True

if new_fulfillment:
matched_fulfillment.save()
shopify_order.save()
print(
"Updating shopify with fulfillment for order: {}, line_item: {}, shopify_sku: {}, new shipment: {}".format(
mcf_order_id, line_item, shopify_sku, new_shipment))
else:
print("Skipping updating fulfillment for order: {}, line_item: {}, shopify_sku: {}, no "
"new information to update...".format(mcf_order_id, line_item, shopify_sku))

 

0 Likes