Hoppa till innehåll
Testa gratis i 14 dagar
Svenska
Öppna i Claude Ställ frågor om den här sidanÖppna i ChatGPT Ställ frågor om den här sidan

Uppdatera/redigera Wholesale Pricing med API:er

Uppdatera en befintlig Wholesale Pricing-regel via det publika API:et, med fullständig referens för request body.

Det här dokumentet förklarar hur du uppdaterar en befintlig Wholesale Pricing-regel med det publika API:et.


Använd följande endpoint för att uppdatera en befintlig Wholesale Pricing-post:

PUT https://wholesale.samita.io/api/v1/wholesale-pricings/{id}
  • {id} är ID:t för Wholesale Pricing-posten
  • ID:t finns i appens gränssnitt (utan tecknet ”#”)
  • Exempel:

PUT https://wholesale.samita.io/api/v1/wholesale-pricings/1

Alla API-anrop måste innehålla följande obligatoriska headers:

Header Beskrivning Obligatorisk
X-SAMITA-API-KEY API-nyckel från Wholesale-appen Ja
X-SAMITA-SHOP-URL Shopify-butikens domän i formatet xxx.myshopify.com Ja
CONTENT-TYPE Måste vara application/json Ja

Om en obligatorisk header saknas avvisas anropet.


_ Data för att uppdatera Wholesale Pricing måste skickas i JSON-format. Ett exempel på JSON-struktur finns i slutet av det här dokumentet.

_ Endast de fält som ska uppdateras behöver skickas i anropet. Det är inte obligatoriskt att skicka alla fält, som i Create-API-metoden.

_ Fält som inte anges förblir oförändrade

Exempel på request-JSON:

{
"title": "New Wholesale Pricing",
"status": true,
"apply_customer": {
"type": "all",
"tags": []
},
"exclude_customer": {
"type": "none",
"tags": []
},
"apply_product": {
"type": "all",
"product_ids": [],
"product_tags": [],
"collection_ids": [],
"apply_for_variants": false
},
"exclude_product": {
"type": "none",
"product_ids": [],
"collection_ids": []
},
"discount_for_variants": [
{
"id": 8516448190631,
"variant_pricing": true,
"variants": [
{
"id": 46747346763943,
"discount_groups": [
{
"name": "all",
"type": "percent",
"value": "10"
}
]
}
]
}
],
"apply_market": {
"type": "all",
"handle": []
},
"discount_group": {
"type": "percent",
"value": "10"
},
"active_date": {
"types": ["start_date", "end_date"],
"start_at": "2026-01-15 10:00:00",
"end_at": "2026-01-15 10:00:00"
}
}

  • Namnet som identifierar Wholesale Pricing-posten
  • Valfritt i Update-API:et
  • Måste vara en sträng
  • Maximal längd: 255 tecken

  • Anger om posten är aktiv eller inte
  • Valfritt i Update-API:et
  • Accepterar endast följande värden:
Värde Beskrivning
true Prissättningsregeln är aktiv
false Prissättningsregeln är inaktiv

Anger vilka kunder som omfattas av prissättningsregeln.

Struktur:

"apply_customer": {
"type": "all",
"tags": []
}

type

Accepterade värden:

  • all
  • logged
  • non-logged
  • customer-tags

tags

  • Krävs endast när type == customer-tags
  • Måste vara en array med kommaseparerade värden
  • Exempel: ["wholesale","b2b"]

Används för att utesluta vissa kunder från prissättningsregeln.

Struktur:

"exclude_customer": {
"type": "none",
"tags": []
}

type

  • Standardvärde: none
  • Accepterade värden:
Värde Beskrivning
none Uteslut inga kunder
customer-tags Uteslut kunder utifrån taggar

tags

  • Krävs endast när type == customer-tags
  • Exempel: ["vip","wholesale"]

Anger vilka produkter prissättningsregeln tillämpas på.

Struktur:

"apply_product": {
"type": "all",
"product_ids": [],
"product_tags": [],
"collection_ids": [],
"apply_for_variants": false
}

type

Accepterade värden:

  • all
  • products
  • collections
  • product-tags

Övriga fält krävs beroende på vald typ:

  • product_ids → krävs om type == products
  • product_tags → krävs om type == product-tags
  • collection_ids → krävs om type == collections

apply_for_variants

  • Accepterade värden: true eller false
  • Standardvärde: false

Anger produkter som ska uteslutas från regeln.

Struktur:

"exclude_product": {
"type": "none",
"product_ids": [],
"collection_ids": []
}

Accepterade typer:

  • none
  • products
  • collections

Används när rabatter ställs in per variant.

  • Måste vara tom om apply_product.apply_for_variants == false
  • Krävs när apply_product.apply_for_variants == true

Exempelstruktur:

"discount_for_variants": [
  {
    "id": 8516448190631,
    "variant_pricing": true,
    "variants": [
      {
        "id": 46747346763943,
        "discount_groups": [
          {
            "name": "all",
            "type": "percent",
            "value": "10"
          }
        ]
      }
    ]
  }
]

Struktur:

  • Array med produkter
  • Varje produkt innehåller:
    • id – produkt-ID
    • variant_pricing – måste vara true
    • variants – array med varianter

Varje variant innehåller:

  • id – variant-ID
  • discount_groups – array med rabattkonfigurationer

Regler för discount_groups

  • Om apply_customer.type är all, logged eller non-logged
    → Endast ett objekt tillåts
  • Om apply_customer.type == customer-tags
    → Flera rabattgrupper kan anges

Fält i discount_groups:

Fält Beskrivning
name Måste matcha kundtyp eller kundtagg
type Rabattyp
value Rabattvärde

Accepterade rabattyper:

  • percent
  • amount
  • fixed-amount

Regler för värdet:

  • Måste vara ett tal större än 0
  • Om typen är percent måste värdet vara lägre än 100

Anger vilka Shopify-marknader regeln gäller för.

Struktur:

"apply_market": {
"type": "all",
"handle": []
}

type

Accepterade värden:

  • all
  • specific-market

handle

  • Krävs endast när type == specific-market
  • Kommaseparerad lista med marknadshandles
  • Exempel: ["japan","us"]

Används när rabatten inte ställs in per variant.

Krävs när:

  • apply_product.type inte är products, ELLER
  • apply_product.type == products OCH varianter inte tillämpas

Struktur:

"discount_group": {
"type": "percent",
"value": "10"
}

Regler:

  • type måste vara något av:
    • percent
    • amount
    • fixed-amount
  • value
    • Måste vara större än 0
    • Om typen är percent måste värdet vara lägre än 100

Används för att ställa in start- och sluttid för prissättningsregeln.

Struktur:

"active_date": {
"types": ["start_date", "end_date"],
"start_at": "2026-01-15T10:00:00",
"end_at": "2026-01-15T10:00:00"
}

types

  • Valfritt
  • Accepterade värden: start_date, end_date
  • Exempel: ["start_date","end_date"]

start_at

  • Krävs om types innehåller start_date
  • Format: YYYY-MM-DD HH:MM:SS

end_at

  • Krävs om types innehåller end_date
  • Format: YYYY-MM-DD HH:MM:SS

401 – Unauthorized

Möjliga orsaker:

  • Butikens URL saknas
  • API-nyckel saknas
  • Ogiltig butiks-URL
  • Ogiltig API-nyckel
  • API-nyckeln matchar inte butiken

403 – This action is unauthorized

  • API-nyckeln saknar behörigheten Update
  • Varje API-nyckel kan ha behörigheterna View, Create, Update och Delete
  • Det här API:et kräver behörigheten Update
  • Returneras även när det angivna ID:t inte finns

429 – Too Many Requests

Gränsen för antal anrop har överskridits:

  • Högst 1 anrop per 5 minuter
  • Högst 50 anrop per dag

200 – API Success

  • Wholesale Pricing-posten uppdaterades
  • Svaret returneras i JSON-format

Exempel på svars-JSON:

{
"id": 1,
"title": "New Wholesale Pricing",
"status": true,
"apply_customer": {
"type": "all",
"tags": []
},
"exclude_customer": {
"type": "none",
"tags": []
},
"apply_product": {
"type": "all",
"product_ids": [],
"product_tags": [],
"collection_ids": [],
"apply_for_variants": false
},
"exclude_product": {
"type": "none",
"product_ids": [],
"collection_ids": []
},
"discount_for_variants": [
{
"id": 8516448190631,
"variant_pricing": true,
"variants": [
{
"id": 46747346763943,
"discount_groups": [
{
"name": "all",
"type": "percent",
"value": "10"
}
]
}
]
}
],
"apply_market": {
"type": "all",
"handle": []
},
"discount_group": {
"type": "percent",
"value": "10"
},
"active_date": {
"types": [],
"start_at": "",
"end_at": ""
},
"created_at": "2026-01-15T10:00:00",
"updated_at": "2026-01-15T10:00:00"
}

Var det här till hjälp?