Main site

Built-in Modules > Dropshipzone Class

Dropshipzone 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.

Overview

The Dropshipzone class enables the retrieval of real-time shipping rates for products from Dropshipzone.

Class Definition

class Dropshipzone {
  constructor(dropshipzone_email, dropshipzone_password, destination) {
    // Class constructor
  }

  async getRates(dropshipzoneProducts) {
    // Method to fetch rates
  }
}

Arguments

  • dropshipzone_email (String): The email address associated with your Dropshipzone API credential.
  • dropshipzone_password (String): The password for your Dropshipzone API credential.
  • destination (Object): The "destination" information from the DATA JSON object that's passed to the calculateShippingRates function.

Usage Example

const dropshipzone = new Dropshipzone(env.dropshipzone_email, env.dropshipzone_password, DATA.destination);
const dropshipzoneProducts = [
  { dropshipzone_product_sku: "OCHAIR-G-RING-2003-BK", quantity: 2 },
  { dropshipzone_product_sku: "V219-SPCAIRBMC13A", quantity: 1 },
  // ... additional products
];
const rates = await dropshipzone.getRates(dropshipzoneProducts);

This example illustrates how to instantiate the Dropshipzone class with the user's account credentials and destination information. The getRates method computes shipping rates for an array of Dropshipzone products, identified by their dropshipzone_product_sku and quantity. The format of the returned rates is consistent with the format of Shopify's shipping rates. For better security, your Dropshipzone credentials should be saved in the env object as encrypted secret variables in the JsRates Settings page.

The dropshipzone_email and dropshipzone_password are your Dropshipzone API credentials. They are not your Dropshipzone website login credentials. Please ask your account manager for access to API credentials.

Sample AI Prompt

I'd like a shipping rate calculator for items from Dropshipzone.
The items sku is the same as the Dropshipzone product sku.
The dropshipzone account email and password are saved in the environment variable.

Sample AI Output

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

export async function calculateShippingRates(DATA, env) {
  try {
    // Enrich items with additional details
    DATA = await enrichItemDetails(DATA);

    // Extract destination info
    const destination = DATA.destination;

    // Create Dropshipzone instance
    const dropshipzone = new Dropshipzone(
      env.dropshipzone_email,
      env.dropshipzone_password,
      destination
    );

    // Get Dropshipzone products
    const dropshipzoneProducts = DATA.items.map((item) => ({
      dropshipzone_product_sku: item.sku,
      quantity: item.quantity,
    }));

    // Get shipping rates from Dropshipzone
    const rates = await dropshipzone.getRates(dropshipzoneProducts);

    return { rates };
  } catch (error) {
    return {
      rates: [
        {
          service_name: "",
          service_code: "",
          total_price: null,
          description: "",
          currency: "",
          min_delivery_date: "",
          max_delivery_date: "",
        },
      ],
    };
  }
}