Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Getting cost of a variant from webhook

Getting cost of a variant from webhook

mthnsynctr
Visitor
1 0 0

Is there anyway to get the variant cost from any webhook topic?

 

product/create and product/update does not contain the cost of variant. 

Replies 2 (2)

lizk
Shopify Staff
246 58 79

Hi there! 

The price of the variant should be able to be found in the product/create and product/update webhooks. 

It should be found in product.variants[0].price
In the documentation you should be able to see an example response from those webhooks.
https://shopify.dev/api/admin-rest/2022-04/resources/webhook#top

{
    "id": 788032119674292922,
    "title": "Example T-Shirt",
    "body_html": null,
    "vendor": "Acme",
    "product_type": "Shirts",
    "created_at": null,
    "handle": "example-t-shirt",
    "updated_at": "2022-04-06T08:09:04-04:00",
    "published_at": "2022-04-06T08:09:04-04:00",
    "template_suffix": null,
    "status": "active",
    "published_scope": "web",
    "tags": "example, mens, t-shirt",
    "admin_graphql_api_id": "gid:\/\/shopify\/Product\/788032119674292922",
    "variants": [
      {
        "id": 642667041472713922,
        "product_id": 788032119674292922,
        "title": "",
        "price": "19.99",
        "sku": "example-shirt-s",
        "position": 0,
        "inventory_policy": "deny",
        "compare_at_price": "24.99",
        "fulfillment_service": "manual",
        "inventory_management": "shopify",
        "option1": "Small",
        "option2": null,
        "option3": null,
        "created_at": null,
        "updated_at": null,
        "taxable": true,
        "barcode": null,
        "grams": 200,
        "image_id": null,
        "weight": 200.0,
        "weight_unit": "g",
        "inventory_item_id": null,
        "inventory_quantity": 75,
        "old_inventory_quantity": 75,
        "requires_shipping": true,
        "admin_graphql_api_id": "gid:\/\/shopify\/ProductVariant\/642667041472713922"
      }
    ],
    "images": [
      {
        "id": 539438707724640965,
        "product_id": 788032119674292922,
        "position": 0,
        "created_at": null,
        "updated_at": null,
        "alt": null,
        "width": 323,
        "height": 434,
        "src": "\/\/cdn.shopify.com\/shopifycloud\/shopify\/assets\/shopify_shirt-39bb555874ecaeed0a1170417d58bbcf792f7ceb56acfe758384f788710ba635.png",
        "variant_ids": [
  
        ],
        "admin_graphql_api_id": "gid:\/\/shopify\/ProductImage\/539438707724640965"
      }
    ],
    "image": null
  }

To learn more visit the Shopify Help Center or the Community Blog.

mauliksts
Shopify Partner
1 0 1

Hi there! 

how can i get  Cost per item  price  value through webhook