What is origin_location and why does it not match a store location?

Highlighted
New Member
1 0 0

We currently have a Shopify online store and multiple retail locations using Shopify POS. I've attached an example of a purchase I made in our store using Shopify POS. I then returned the product to the same store via Shopify POS. Note: I've removed some unnecessary JSON attributes for brevity and privacy.

 

Problem: When a refund occurs, we need to determine the original purchase location and refund location within our ERP (Netsuite). For example, we need to know if a user bought something online but returned it to our store in person for accounting purposes. 

 

Constraint: When the refund occurs, only the refund object itself is passed to Netsuite. This means we do not have access to other oder level attributes outside of the refund (ex: order.location_id). Therefore we are constrained to using only the data within the refunds object below.

 

With the problem and constraint defined above, we have two objectives to complete:

 

1. Determine the refund location (success)

We can accomplish this by using the refund_line_item.location_id. 

 

2. Determine the original purchase location (failure)

We've noticed that the refund_line_item contains an object called origin_location. Unfortunately Shopify's documentation lacks any details/references to origin_location.  According to this post, the origin_location indicates where the order was placed. That's great news! However, the origin_location.location_id does not match the refund_line_item.location_id. In fact, it's not a location ID for any of our locations listed at /admin/settings/locations. How can this be? The refund was processed at the same POS store location minutes after purchasing it. This must mean that an origin_location.location_id is not equivalent to location_id.

 

This leaves me with a few questions:

 

1. Why is origin_location not included in the Shopify API documentation?

2. Why is refund_line_item.location_id different from origin_location.location_id?

3. Can I get a list of all of our origin_location.location_ids somewhere?

4. Can I count on an origin_location's location_id to never change? If so we can likely use it to solve our problem.

 

 

{
	"order": {
		"id": 2050951250029,
		"number": 573773,
		"note": null,
		"total_price": "32.48",
		"subtotal_price": "30.00",
		"total_tax": "2.48",
		"financial_status": "refunded",
		"location_id": 15126003821,
		"refunds": [{
			"id": 642011496557,
			"order_id": 2050951250029,
			"created_at": "2020-01-21T11:08:01-06:00",
			"note": null,
			"user_id": 26754908269,
			"processed_at": "2020-01-21T11:08:01-06:00",
			"restock": true,
			"refund_line_items": [{
				"id": 148309442669,
				"quantity": 1,
				"line_item_id": 4591537487981,
				"location_id": 15126003821,
				"restock_type": "return",
				"subtotal": 30.0,
				"total_tax": 2.48,
				"subtotal_set": {
					"shop_money": {
						"amount": "30.00",
						"currency_code": "USD"
					},
					"presentment_money": {
						"amount": "30.00",
						"currency_code": "USD"
					}
				},
				"total_tax_set": {
					"shop_money": {
						"amount": "2.48",
						"currency_code": "USD"
					},
					"presentment_money": {
						"amount": "2.48",
						"currency_code": "USD"
					}
				},
				"line_item": {
					"id": 4591537487981,
					"variant_id": 13783308730477,
					"title": "Bottle Opener",
					"quantity": 1,
					"sku": "TCVSBTLOPEN2H18",
					"variant_title": "Cast Iron",
					"vendor": "Big Bird",
					"fulfillment_service": "manual",
					"product_id": 1482452500589,
					"requires_shipping": true,
					"taxable": true,
					"gift_card": false,
					"tax_code": "PE090700",
					"name": "Bottle Opener - Cast Iron",
					"variant_inventory_management": "shopify",
					"properties": [],
					"product_exists": true,
					"fulfillable_quantity": 0,
					"grams": 227,
					"price": "30.00",
					"total_discount": "0.00",
					"fulfillment_status": "fulfilled",
					"pre_tax_price": "30.00",
					"price_set": {
						"shop_money": {
							"amount": "30.00",
							"currency_code": "USD"
						},
						"presentment_money": {
							"amount": "30.00",
							"currency_code": "USD"
						}
					},
					"pre_tax_price_set": {
						"shop_money": {
							"amount": "30.00",
							"currency_code": "USD"
						},
						"presentment_money": {
							"amount": "30.00",
							"currency_code": "USD"
						}
					},
					"total_discount_set": {
						"shop_money": {
							"amount": "0.00",
							"currency_code": "USD"
						},
						"presentment_money": {
							"amount": "0.00",
							"currency_code": "USD"
						}
					},
					"discount_allocations": [],
					"tax_lines": [{
						"title": "TX STATE TAX",
						"price": "1.88",
						"rate": 0.0625,
						"price_set": {
							"shop_money": {
								"amount": "1.88",
								"currency_code": "USD"
							},
							"presentment_money": {
								"amount": "1.88",
								"currency_code": "USD"
							}
						}
					}, {
						"title": "TX SPECIAL TAX",
						"price": "0.30",
						"rate": 0.01,
						"price_set": {
							"shop_money": {
								"amount": "0.30",
								"currency_code": "USD"
							},
							"presentment_money": {
								"amount": "0.30",
								"currency_code": "USD"
							}
						}
					}, {
						"title": "TX CITY TAX",
						"price": "0.30",
						"rate": 0.01,
						"price_set": {
							"shop_money": {
								"amount": "0.30",
								"currency_code": "USD"
							},
							"presentment_money": {
								"amount": "0.30",
								"currency_code": "USD"
							}
						}
					}],
					"origin_location": {
						"id": 1337178718317,
						"country_code": "US",
						"province_code": "TX",
						"name": "001 - Sesame Street Retail Store",
						"address1": "123 Sesame Street",
						"address2": "",
						"city": "Austin",
						"zip": "78704"
					}
				}
			}],
			"transactions": [{
				"id": 2616509399149,
				"order_id": 2050951250029,
				"kind": "refund",
				"gateway": "shopify_payments",
				"status": "success",
				"message": "Transaction approved",
				"created_at": "2020-01-21T11:07:58-06:00",
				"test": false,
				"authorization": "re_xxxxxxxxxxxxxxxxxx",
				"location_id": 15126003821,
				"user_id": 26754908269,
				"parent_id": 2616509005933,
				"processed_at": "2020-01-21T11:07:58-06:00",
				"device_id": 832962669,
				"receipt": {
					"id": "re_xxxxxxxxxxxxxx",
					"amount": 3248,
					"balance_transaction": {
						"id": "txn_xxxxxxxxxxxxxxxxxx",
						"object": "balance_transaction",
						"exchange_rate": null
					},
					"charge": {
						"id": "ch_xxxxxxxxxxxxxxxx",
						"object": "charge",
						"amount": 3248,
						"application_fee": "fee_xxxxxxxxxxx",
						"balance_transaction": {
							"id": "txn_xxxxxxxxxxxxxx",
							"object": "balance_transaction",
							"exchange_rate": null
						},
						"captured": true,
						"created": 1579626460,
						"currency": "usd",
						"failure_code": null,
						"failure_message": null,
						"fraud_details": {},
						"livemode": true,
						"metadata": {
							"shop_id": "123456",
							"shop_name": "Big Bird's Store",
							"transaction_fee_total_amount": "100",
							"transaction_fee_tax_amount": "0",
							"payments_charge_id": "0123456789",
							"order_transaction_id": "0123456789",
							"manual_entry": "true",
							"email": "bigbird@sesamestreet.com",
							"order_id": "c0123456789.1"
						},
						"outcome": {
							"network_status": "approved_by_network",
							"reason": null,
							"risk_level": "normal",
							"seller_message": "Payment complete.",
							"type": "authorized"
						},
						"paid": true,
						"payment_intent": null,
						"payment_method": "card_xxxxxxxxxxxxxx",
						"payment_method_details": {
							"card": {
								"brand": "visa",
								"checks": {
									"address_line1_check": null,
									"address_postal_code_check": "pass",
									"cvc_check": "pass"
								},
								"country": "US",
								"exp_month": 1,
								"exp_year": 2345,
								"fingerprint": "xxxxxxxxxxxxxxx",
								"funding": "credit",
								"installments": null,
								"last4": "1234",
								"moto": null,
								"network": "visa",
								"three_d_secure": null,
								"wallet": null
							},
							"type": "card"
						},
						"refunded": true,
						"source": {
							"id": "card_xxxxxxxxxxxxxx",
							"object": "card",
							"brand": "Visa",
							"country": "US",
							"cvc_check": "pass",
							"dynamic_last4": null,
							"exp_month": 1,
							"exp_year": 2345,
							"fingerprint": "p7PQSGlafxw8fSjr",
							"funding": "credit",
							"last4": "1234",
							"name": null,
							"tokenization_method": null
						},
						"status": "succeeded"
					},
					"object": "refund",
					"reason": null,
					"status": "succeeded",
					"created": 1579626479,
					"currency": "usd",
					"metadata": {
						"transaction_fee_total_amount": "100",
						"transaction_fee_tax_amount": "0",
						"order_transaction_id": "1234567890",
						"payments_refund_id": "1234567890"
					}
				},
				"error_code": null,
				"source_name": "pos",
				"amount": "32.48",
				"currency": "USD"
			}],
			"order_adjustments": []
		}]
	}
}

 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
587 72 130

Hey @stephentecovas,

 

I'm currently looking to get clarification on the origin_location you're seeing in the response. I can see this id references some tables used internally to maintain the relationship between line_items and locations, but it's not clear whether this field is supposed to be exposed on the API.

 

In the meantime, I can suggest a workaround that doesn't rely on the origin_location id. In the origin_location object, I can confirm that the location name match the name you'll see when querying a shop's location. In your example, the name is  001 - Sesame Street Retail Store. You can reference this name to determine where the original order was processed.

 

As mentioned I'm still looking to get clarification on the origin_location_id in the response, and I'll post back here as soon as I have an update on that.

JB | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes
Highlighted
Shopify Partner
2 0 0

I'm running into the same problem so that sucks.  Taking _JB's advice, you can also get the "origin_location" object from the physicalLocation object if you query the order via graphql.

{
    order (id) {
           physicalLocation {
                 name
                 address {
                      ...sub-fields
                 }
           }
    }
}
0 Likes