Main site

Built-in Modules > Idropship Class

Idropship Class

Important: This plugin relies on third-party resources. The resources might change or be discontinued without notice. Ensure you test the plugin extensively before production use, implement error handling with a try-catch block, have a backup shipping rate ready, and reach out to our support with detailed descriptions of any unexpected issues.


The Idropship class is specifically designed to retrieve real-time shipping rates for "Idropship" products.

Class Definition

class Idropship {
  constructor(destination) {
    // Class constructor

  async getRates(idropshipProducts) {
    // Method to fetch rates


  • destination (Object): This is the "destination" component of the DATA JSON object passed to the calculateShippingRates function.

Usage Example

const idropship = new Idropship(DATA.destination);
const idropshipProducts = [
  { idropship_shipping_class: "SC2", quantity: 1 },
  { idropship_shipping_class: "SC5", quantity: 1 },
  // ... other products
const rates = await idropship.getRates(idropshipProducts);

In the provided example, the Idropship class is instantiated with the shipping destination from your data. Then, the getRates method computes the shipping rates for an assortment of Idropship products, each with their idropship_shipping_class and quantity. The format for the returned rates will be the same as that used by Shopify for shipping rates.

Sample AI Prompt

I'd like a shipping rate calculator for items from Idropship.
Enrich the data with metafield namespace "market" with size 10.
The Idropship product shipping class for each items is saved in the items metafield "market" with key "idropship_shipping_class".

Sample AI Output

import { enrichItemDetails } from "./modules.js";
import { Idropship } from "./modules.js";

export async function calculateShippingRates(DATA, env) {
  try {
    // Enrich the data with metafield namespace "market" with size 10.
    DATA = await enrichItemDetails(DATA, [{ namespace: "market", size: 10 }]);

    // Get the Idropship product shipping class for each item.
    const idropshipProducts = => {
      const idropshipShippingClass =;
      return { idropship_shipping_class: idropshipShippingClass, quantity: item.quantity };

    // Create an instance of the Idropship class.
    const idropship = new Idropship(DATA.destination);

    // Get the shipping rates.
    const rates = await idropship.getRates(idropshipProducts);

    // Return the shipping rates.
    return { rates };
  } catch (error) {
    // Return a rate with price equals to null, and other rate fields set to empty string.
    return {
      rates: [
          service_name: "",
          service_code: "",
          total_price: null,
          description: "",
          currency: "",
          min_delivery_date: "",
          max_delivery_date: "",