What's your biggest current challenge? Have your say in Community Polls along the right column.

Update This is a physical product

Solved

Update This is a physical product

gary07
Excursionist
65 0 11

Hi

 

I want to tick This is a physical product as soon as the product changes the status from draft to active using Admin API if possible

 

gary07_0-1731503082026.png

 

Accepted Solution (1)

RPiii
Shopify Staff
94 16 34

This is an accepted solution.

HI @gary07 👋 I'm not entirely sure how to do this but let's figure it out together! Note that the requiresShipping field applies specifically to inventoryItems on variants. My best guess is that you'll want to:

  1. Use a Product status updated trigger to start the workflow when the status is updated.
  2. Define a condition to ensure that product.status is set to ACTIVE and at least one of the product variants has a variants_item.inventoryItem.requiresShipping set to FALSE. This condition will ensure the workflow only proceeds when a product is active and at least one of the variants doesn't have this desired value checked. (screenshot)
  3. Use a For each action to loop through each of the product.variants individually.
  4. Define a condition to ensure that variantsForeachitem.inventoryItem.requiresShipping is FALSE so that the workflow only proceeds to update the relevant variants.
  5. Use a Send Admin API request action to use the inventoryItemUpdate mutation to update the requiresShipping value to TRUE. (screenshot)

I haven't tested any of this and am not entirely sure it'll work so let me know how it goes!

View solution in original post

Replies 4 (4)

Fortes-IT
Shopify Partner
3 1 0

Hi there,
You can use Admin API to check product status first.
Use the GET request to fetch product details and check the current status and requires_shipping field:

GET /admin/api/2023-10/products/{product_id}.json

 

Update Product: If the product’s status is "draft," you can change it to "active" and set requires_shipping to true in one PUT request:

PUT /admin/api/2023-10/products/{product_id}.json
{
  "product": {
    "id": {product_id},
    "status": "active",
    "requires_shipping": true
  }
}

 

Automate on Status Change: You could run this script regularly or use a webhook that triggers when a product is updated to automate the process.


Hope this helps.
Best,
Daniel

gary07
Excursionist
65 0 11

I want to use Flow to do it and the option you have mention I can not see on Send Admin API request option

 

gary07_0-1731577799103.png

 

RPiii
Shopify Staff
94 16 34

This is an accepted solution.

HI @gary07 👋 I'm not entirely sure how to do this but let's figure it out together! Note that the requiresShipping field applies specifically to inventoryItems on variants. My best guess is that you'll want to:

  1. Use a Product status updated trigger to start the workflow when the status is updated.
  2. Define a condition to ensure that product.status is set to ACTIVE and at least one of the product variants has a variants_item.inventoryItem.requiresShipping set to FALSE. This condition will ensure the workflow only proceeds when a product is active and at least one of the variants doesn't have this desired value checked. (screenshot)
  3. Use a For each action to loop through each of the product.variants individually.
  4. Define a condition to ensure that variantsForeachitem.inventoryItem.requiresShipping is FALSE so that the workflow only proceeds to update the relevant variants.
  5. Use a Send Admin API request action to use the inventoryItemUpdate mutation to update the requiresShipping value to TRUE. (screenshot)

I haven't tested any of this and am not entirely sure it'll work so let me know how it goes!

gary07
Excursionist
65 0 11

Hi

 

inventoryitemUpdate mutation was giving errors so I have tried 

productVariantUpdate and that worked 

 

gary07_3-1731606147923.png