customer Id not return in shopify cart webhook - shopify

The Shopify cart webhook is not returning customer id. so we can't able to identify which user added the product to cart.
How can we achieve this?

I think you can't get the customer id from that webhook and the point is that a cart can be created by a registered customer or an unregistered customer as well so in this last case Shopify doesn't know the customer id yet.
Also the example response included in the documentation doesn't include the customer id.
{
"id": "eeafa272cebfd4b22385bc4b645e762c",
"token": "eeafa272cebfd4b22385bc4b645e762c",
"line_items": [
{
"id": 1234567,
"properties": {
},
"quantity": 3,
"variant_id": 1234567,
"key": "1234567:f816dcc3b2e26822a28626a786eac953",
"title": "Example T-Shirt - ",
"price": "19.99",
"original_price": "19.99",
"discounted_price": "19.99",
"line_price": "59.97",
"original_line_price": "59.97",
"total_discount": "0.00",
"discounts": [
],
"sku": "example-shirt-s",
"grams": 200,
"vendor": "Acme",
"product_id": 327475578523353102,
"gift_card": false
}
]
}
You can probably get the customer id using the checkout webhook but without knowing your requirements I can't say this will work for you.
I recommend you to open another question and provide more information on your requirement.

Related

Shopify Order Updated Events Within The Same Timestamp

This question was originally asked in the shopify community, but without any response. So sorry for those of you reading this as duplicate.
We are trying to strengthen our Shopify webhook receiver and reconciliation jobs. The json object below show a list of events from an order we have processed. Examine the created_at timestamps show that 3 events was triggered within the same timestamp.
I assume that 3 webhooks are fired on topic orders/updated and the order updated_at timestamp is 2022-04-26T11:10:57+02:00 after the 3 events.
In the case where the first, of the 3, orders/updated hooks fails on our side, and retried by shopify. How can we make sure that we have the latest event, since comparing the order updated_at timestamp would properly be the same for all 3 events?
We are facing a similar issue with our reconciliation job, since we are comparing the order updated_at timestamp. as an example, if we received the first and second hooks from the example sequence below, the reconciliation job would compare updated_at timestamp and skip the rescue! How can we overcome this, without sync all orders in our reconciliation jobs?
We run the reconciliation jobs once a day and sync all orders by that job is not possible within the rate limit of 2 calls/sec for the REST API.
Thanks in advance
Mads
{
"events": [
{...},
{
"id": 90448362045627,
"subject_id": 1000,
"created_at": "2022-04-26T11:10:53+02:00",
"subject_type": "Order",
"verb": "fulfillment_success",
"arguments": [
],
"body": null,
"message": "CoolRunner fulfilled 1 item ",
"author": "CoolRunner",
"description": "CoolRunner fulfilled 1 item ",
"path": "/admin/orders/1000/fulfillments/3862202974395"
},
{
"id": 90448362275003,
"subject_id": 1000,
"created_at": "2022-04-26T11:10:54+02:00",
"subject_type": "Order",
"verb": "mail_sent",
"arguments": [
],
"body": null,
"message": "CoolRunner sent a shipping confirmation email ",
"author": "CoolRunner",
"description": "CoolRunner sent a shipping confirmation email",
"path": "/admin/orders/1000"
},
{
"id": 90448363258043,
"subject_id": 1000,
"created_at": "2022-04-26T11:10:57+02:00",
"subject_type": "Order",
"verb": "capture_success",
"arguments": [
],
"body": null,
"message": "CoolRunner captured €99.00 EUR using a Mastercard ",
"author": "CoolRunner",
"description": "CoolRunner captured €99.00 EUR using a Mastercard ",
"path": "/admin/orders/1000/transactions/5355897323707"
},
{
"id": 90448363389115,
"subject_id": 1000,
"created_at": "2022-04-26T11:10:57+02:00",
"subject_type": "Order",
"verb": "payments_charge",
"arguments": [
],
"body": null,
"message": "-",
"author": "CoolRunner",
"description": "-",
"path": "/admin/orders/1000"
},
{
"id": 90448363421883,
"subject_id": 1000,
"created_at": "2022-04-26T11:10:57+02:00",
"subject_type": "Order",
"verb": "closed",
"arguments": [],
"body": null,
"message": "This order was archived.",
"author": "Shopify",
"description": "This order was archived.",
"path": "/admin/orders/1000"
}
]
}
Not sure I understand your problem, but you have to understand, if you choose to function via handling webhooks, things like temporal ordering go out the window. You have to code for that. You will never have a guarantee that any one webhook will arrive in any kind of order. So you just process them and move on.
So if an order undergoes three updates, 1, 2, and 3, you might receive webhook notifications in the order 3,2,1 or 1,3,2, or 2,3,1 or 1,2,3 or 3,1,2 etc.
So you have exposed two problems. One, you are trusting Webhooks are a source of temporal truth and, two, you are painting yourself into a corner by not doing your API coding to respect API limits.
My advice to you is to accept webhooks when they arrive, process them, and improve your code so API limits are not holding you back.

Account list doesn't return account id for "grouped" accounts

I'm using the Xero API to do some integration and I'm using the accounts get feature to return a list of accounts. I'd like to join this to some of the reports, for example the profit and loss report which would allow me to then group the accounts returned by type. All looks good, other than some accounts have an extra "groupID" attribute. When an account has this extra attribute, the "account" attribute that usually contains a GUID which I can link to reports now contains what could be a GUID, only without the dashes, and doesn't link to any other report.
For example, this is an account that all works correctly...
{
"RowType": "Row",
"Cells": [
{
"Value": "General Expenses",
"Attributes": [
{
"Value": "8d631f87-7304-401f-a7cd-d1d42c1b458a",
"Id": "account"
}
]
},
{
"Value": "179.07",
"Attributes": [
{
"Value": "8d631f87-7304-401f-a7cd-d1d42c1b458a",
"Id": "account"
}
]
}
]
},
This one doesn't, and the GUID isn't formatted as a GUID anymore...
{
"RowType": "Row",
"Cells": [
{
"Value": "Directors' Remuneration",
"Attributes": [
{
"Value": "a02584cbb64e4c109b4355b292da0de5",
"Id": "account"
},
{
"Value": "a02584cbb64e4c109b4355b292da0de5",
"Id": "groupID"
}
]
},
{
"Value": "55737.84",
"Attributes": [
{
"Value": "a02584cbb64e4c109b4355b292da0de5",
"Id": "account"
},
{
"Value": "a02584cbb64e4c109b4355b292da0de5",
"Id": "groupID"
}
]
}
]
},
Any idea what would cause that? Is there a way I can list "grouped" accounts?
Thanks in advance.
At the moment, there is no current way to get the accountIDs in the Reports endpoints for accounts that have been grouped together.
But, there are 2 ways you can get that in the response. In the API request, if you send 'standardLayout=true', then that'll give you back the accountIDs.
Or on the Web app, in P&L edit layout mode, if you uncheck the 'Show Summary Only' box for the group of those accounts, that'll also work the same way and you should be able to see the accountIDs in the API response.
Thanks
Keertika
I believe that is due to the org having multi-currency for that account.
However I don't see much other documentation related to how to lookup the account from that. I will update this answer If I can find anything else out internally.
Multi-Currency System Accounts - FXGROUPID
For organisations in most regions, the standard layout of the profit and loss report will group multi currency system accounts into a single line with a Value of FXGROUPID (instead of an AccountID).
This is not the case for US organisations and Australian demo companies. Multi-currency system accounts will be displayed seperately with their respective AccountIDs.
Multi currency support could be seen here: https://go.xero.com/Setup/CurrencyRates.aspx
I think you can also just query the currencies endpoint to find out if an org may support mutiple.

Schema.org PriceSpecification with a sale price

I'm currently building a Schema.org template for an ecommerce website, for the purposes of generating a Google Shopping Feed.
I'm struggling to understand the correct way to define a sale price - i.e. a product which has a temporary reduced price.
The options I've considered areL
a single "Offer" with multiple "PriceSpecification" items
multiple "Offer" items with a single "PriceSpecification"
or maybe something else completely?
Single "Offer" with multiple "PriceSpecification" items
"offers": {
"#type": "Offer",
"url": "https://kx.com/url",
"itemCondition": "http://schema.org/UsedCondition",
"availability": "http://schema.org/InStock",
"PriceSpecification": [
{
"#type": "PriceSpecification",
"price": 15.00,
"priceCurrency": "USD"
},
{
"#type": "PriceSpecification",
"price": 15.00,
"priceCurrency": "USD",
"validFrom": "2020-01-01",
"validThrough": "2020-02-01",
}
],
},
Multiple "Offer" items with a single "PriceSpecification"
"offers": [
{
"#type": "Offer",
"url": "https://kx.com/url",
"itemCondition": "http://schema.org/UsedCondition",
"availability": "http://schema.org/InStock",
"PriceSpecification": [
{
"#type": "PriceSpecification",
"price": 15.00,
"priceCurrency": "USD"
}
],
},
{
"#type": "Offer",
"url": "https://kx.com/url",
"itemCondition": "http://schema.org/UsedCondition",
"availability": "http://schema.org/InStock",
"PriceSpecification": [
{
"#type": "PriceSpecification",
"price": 15.00,
"priceCurrency": "USD",
"validFrom": "2020-01-01",
"validThrough": "2020-02-01",
}
],
}
]
},
Or is it something completely different? I'm struggling to find any conclusive documentation around this.
I'd note that Google strongly recommends the priceValidUntil value on Offer. I also usually use the rule of thumb that your Structured Data should match what's in your markup, so I think the starting point of the sale is likely unnecessary, especially for a Google shopping feed.
If I were approaching this, I feel the safe route would be updating your Product structured data along with the content on the day of the sale, using the priceValidUntil field to note when that sale ends, then removing the attribute and updating the price once that date hits. You'd end up with something like:
"offers": {
"#type": "Offer",
"url": "https://kx.com/url",
"itemCondition": "http://schema.org/UsedCondition",
"availability": "http://schema.org/InStock",
"price": 15.00,
"priceCurrency": "USD",
"priceValidUntil": "2/1/2020"
}
In this example, on 2/1/2020 the priceValidUntil attribute would be removed and the price attribute would update, along with the content on the page.
Your first example does validate in the Structured Data Testing Tool, but I don't think it will do you any good. I can see where you might want to advertise a sale ahead of time, but as far as I know a Google Shopping Feed/Carousel does not announce sales that are going to happen - just prices that are happening.
A final note that while priceSpecification does validate on the testing tool and is applicable to a product, details around it seem a bit vague and I'd be hesitant in expecting it to provide much value. priceSpecification on schema.org has no example of it being used in a product (although again, not to say that means it is wrong).

BigCommerce Orders API: unable to update

I'm trying to update an existing order in the store using PUT requests to the V2 orders API:
https://api.bigcommerce.com/stores/{$$.env.store_hash}/v2/orders/{id}
According to the docs, I should be able to update the following:
customer_id, status_id, Add a new product, Add a custom product, billing_address
The only thing I have success changing is the status_id. I can use the example body provided at the bottom of the documentation page:
{
"status_id": 1,
"billing_address": {
"first_name": "Trisha",
"last_name": "McLaughlin",
"company": "",
"street_1": "123 Main Street",
"street_2": "",
"city": "Anywhere",
"state": "Some State",
"zip": "12345",
"country": "United States",
"country_iso2": "US",
"phone": "",
"email": "elsie#example.com"
}
}
I get a 200 OK response with no body. But in the store only the status changes. If I intentionally misspell a field, then I get an error response, which suggests to me that the body is correctly formatted, but ignored.
Can anyone provide an example of a body that updates billing address or adds a new product which the API will act on?
I'm generating the PUT requests with Postman currently, but will move to PHP later.
Thanks.
Edit:
This is an example of a request I tried for adding an existing product, also accepted but doesn't work.
{
"products": [{
"product_id": 111,
"quantity": 5
}]
}
Edit 2: To provide more context, the orders I'm trying to update already have existing products and have been 'paid for' (the products are free). I've tried adding products that are already in the order as well as new ones. I've tried this on orders with various status as well. Also, the orders are processed by guest accounts, so the customer_id field is 0. I have not tried doing this with a registered account order. Could any of these things be causing the issue?
Edit 3: For anyone else wandering by, this appears to be a bug that is associated with downloadable products. Please see the comment chain under the accepted answer for details.
Add a new product:
{
"products": [{
"name": "Poster",
"quantity": 5,
"price_inc_tax": 12.45,
"price_ex_tax": 10.12
}]
}
Add an existing product: Make sure to update the product_id to one that is in the store.
{
"products": [{
"product_id": 187,
"quantity": 5,
"price_inc_tax": 12.45,
"price_ex_tax": 10.12
}]
}
It will return a 200. Then query the Order Products to see a list of products on the order.
To update a billing address this structure works:
{
"billing_address": {
"first_name": "Jane",
"last_name": "Doe",
"company": "",
"street_1": "455 Main Street",
"street_2": "",
"city": "Austin",
"state": "Texas",
"zip": "78751",
"country": "United States",
"country_iso2": "US",
"phone": "",
"email": "rick#sanchez.com"
}
}
Customer id needs to match a customer id that exists in the store. To get a list of customers use the customers endpoint.
{
"customer_id": 20
}
According to this page:
https://developer.bigcommerce.com/api-reference/b3A6MzU5MDQ3MzE-update-an-order
it states:
"The status will include one of the (string, options) - values defined under Order Statuses. This value is read-only. Do not attempt to modify or set this value in a POST or PUT operation."
It appears you cannot update the order status from the api...

HERE Places API: not all items have PVID

I'm using HERE Places API.
Firstly I'm doing a search.
For Example this query :
https://places.cit.api.here.com/places/v1/discover/search?q=Test&at=35.6111,-97.5467&r=500&size=1&app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg&show_refs=pvid&pretty
According to this documentation (Link) If I add show_refs=pvid to query string, in result I will get external id which I can use to query lookup endpoint.
But in result I get next response :
{
"results": {
"next": "https://places.cit.api.here.com/places/v1/discover/search;context=Zmxvdy1pZD1hY2ExNzk3NC0zYzg3LTU5NzQtYmZkMC04YjAzMDZlYWIzMWJfMTUwNjA3NjMzMTYyMl83NDY3XzM4NTAmb2Zmc2V0PTEmc2l6ZT0x?at=35.6111%2C-97.5467&q=Test&app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg",
"items": [
{
"position": [
35.60369,
-97.51761
],
"distance": 2756,
"title": "Southwest Test & Balance",
"averageRating": 0,
"category": {
"id": "business-services",
"title": "Business & Services",
"href": "https://places.cit.api.here.com/places/v1/categories/places/business-services?app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg",
"type": "urn:nlp-types:category",
"system": "places"
},
"icon": "https://download.vcdn.cit.data.here.com/p/d/places2_stg/icons/categories/02.icon",
"vicinity": "200 NW 132nd St<br/>Oklahoma City, OK 73114",
"having": [],
"type": "urn:nlp-types:place",
"href": "https://places.cit.api.here.com/places/v1/places/8403fv6k-d1b2fde0616e0326e321a54b88cd9f53;context=Zmxvdy1pZD1hY2ExNzk3NC0zYzg3LTU5NzQtYmZkMC04YjAzMDZlYWIzMWJfMTUwNjA3NjMzMTYyMl83NDY3XzM4NTAmcmFuaz0w?app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg",
"id": "8403fv6k-d1b2fde0616e0326e321a54b88cd9f53",
"authoritative": true
}
]
},
"search": {
"context": {
"location": {
"position": [
35.6111,
-97.5467
],
"address": {
"text": "Oklahoma City, OK 73134<br/>USA",
"postalCode": "73134",
"city": "Oklahoma City",
"county": "Oklahoma",
"stateCode": "OK",
"country": "United States",
"countryCode": "USA"
}
},
"type": "urn:nlp-types:place",
"href": "https://places.cit.api.here.com/places/v1/places/loc-dmVyc2lvbj0xO3RpdGxlPU9rbGFob21hK0NpdHk7bGF0PTM1LjYxMTE7bG9uPS05Ny41NDY3O2NpdHk9T2tsYWhvbWErQ2l0eTtwb3N0YWxDb2RlPTczMTM0O2NvdW50cnk9VVNBO3N0YXRlQ29kZT1PSztjb3VudHk9T2tsYWhvbWE7Y2F0ZWdvcnlJZD1jaXR5LXRvd24tdmlsbGFnZTtzb3VyY2VTeXN0ZW09aW50ZXJuYWw;context=c2VhcmNoQ29udGV4dD0x?app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg"
}
}
}
In response no object references
Is it a bug or not every place has this external id?
I am responding as member of the team around HERE Places API.
Yes, not every place has a pvid. That is why I would suggest using the Sharing Id instead. I realize that the documentation should be improved to clarify that.
The Sharing Ids can be obtained by adding show_refs=sharing to either your search query or a place details request. It can be found in the field references. Once you have the sharing id you can you the lookup endpoint as you intended.
Take a look at:
https://places.cit.api.here.com/places/v1/places/8403fv6k-d1b2fde0616e0326e321a54b88cd9f53;context=Zmxvdy1pZD00YWU2ZWZjNi01ZjgzLTUwYTQtOTI4OS0xZjliMGMwNWY3NjBfMTUwNzA0NDE0OTc3NV84MTI5XzU1NDcmcmFuaz0w?app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg&show_refs=pvid
and
https://places.cit.api.here.com/places/v1/places/8409q8yy-6af3c3e50bcb4f859686797b2be5773d;context=Zmxvdy1pZD00YWU2ZWZjNi01ZjgzLTUwYTQtOTI4OS0xZjliMGMwNWY3NjBfMTUwNzA0NDE0OTc3NV84MTI5XzU1NDcmcmFuaz0w?app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg&show_refs=pvid
On those two examples, the only difference is the placeId.
In the docs, there's not a single reference saying that the external identifier is required or existant for every place.
Since it represents an external identifier, I believe we could assume that it's not required.
And it's what we just saw with your place (8403fv6k-d1b2fde0616e0326e321a54b88cd9f53): this one don't have any external identifier.
Based on your comments, what you need is the information about a place.
So, after you run your first query, you should get something like:
{
title: "Southwest Test & Balance",
position: [],
id: "8403fv6k-d1b2fde0616e0326e321a54b88cd9f53",
href: "https://[...]"
}
With this ID, you could access it:
places.cit.api.here.com/places/v1/places/8403fv6k-d1b2fde0616e0326e321a54b88cd9f53;context=Zmxvdy1pZD0zYTFlZjg5ZS02ZTY5LTUxYmEtYWFkYS1kY2UwZWMyNDdkMDBfMTUwNzEzNjUxNjI5N182NjExXzc2OTgmcmFuaz0w?app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg
Or directly using the href information.
This response already is giving you the ID and URL to access all the info of a single place.
You don't need any other external ID or reference.