Edits history of script submission #4435 for ' Deletes an inventory level from a location (shopify)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Shopify = {
      token: string;
      store_name: string;
    };
    /**
     * Deletes an inventory level from a location
     * Deletes an inventory level of an inventory item at a location. Deleting an inventory level for an inventory item removes that item from the specified location. Every inventory item must have at least one inventory level. To move inventory to another location, first connect the inventory item to another location, and then delete the previous inventory level.
     */
    export async function main(auth: Shopify, api_version: string = "2023-10") {
      const url = new URL(
        `https://${auth.store_name}.myshopify.com/admin/api/${api_version}/inventory_levels.json`
      );
    
      const response = await fetch(url, {
        method: "DELETE",
        headers: {
          "X-Shopify-Access-Token": auth.token,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 396 days ago

  • nativets
    type Shopify = {
      token: string;
      store_name: string;
    };
    /**
     * Deletes an inventory level from a location
     * Deletes an inventory level of an inventory item at a location. Deleting an inventory level for an inventory item removes that item from the specified location. Every inventory item must have at least one inventory level. To move inventory to another location, first connect the inventory item to another location, and then delete the previous inventory level.
     */
    export async function main(auth: Shopify, api_version: string = "2023-10") {
      const url = new URL(
        `https://${auth.store_name}.myshopify.com/admin/api/${api_version}/inventory_levels.json`
      );
    
      const response = await fetch(url, {
        method: "DELETE",
        headers: {
          "X-Shopify-Access-Token": auth.token,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 942 days ago