Shopify API 送料プロファイルに商品を追加する

備忘録

商品ごとに送料を変えたいときなどに使う送料プロファイル。
既存の送料プロファイルにAPIで商品・バリエーションを追加する方法。

GraphQLを使う。メソッドはdeliveryProfileUpdate。下記はサンプルクエリ

{
  "query":"mutation deliveryProfileUpdate($id: ID!, $profile: DeliveryProfileInput!) {  deliveryProfileUpdate(id: $id, profile: $profile) {    profile {      id    }    userErrors {      field      message    }  }}",
  "variables":{
     "id":"gid://shopify/DeliveryProfile/64987037858",
     "profile":{
        "variantsToAssociate":"gid://shopify/ProductVariant/31620852416564"
     }
  },
  "operationName":"deliveryProfileUpdate"
}

variantsToAssociateは配列でもOKだから、1度に多分100件ぐらいは行けると思う。

ただ、管理画面から追加する方が楽だから、実装するモチベーションが沸かない。。。

この記事が気に入ったらサポートをしてみませんか?