Main site

Built-in Modules > AliExpress Class

AliExpress 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 AliExpress class is designed to obtain real-time shipping rates for products available on AliExpress.

Class Definition

class AliExpress {
  constructor(destination, currency) {
    // Class constructor

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


  • destination (Object): This is the "destination" field from the input DATA JSON object that is passed to the calculateShippingRates function.
  • currency (String): The desired currency ISO code for which shipping rates will be fetched.

Usage Example

import { AliExpress } from "./modules.js"
const aliexpress = new AliExpress(DATA.destination, DATA.currency);
const aliexpressProducts = [
  { aliexpress_product_id: "2251832577512145", quantity: 1 },
  { aliexpress_product_id: "1005004816502519", quantity: 2 },
  // ... more products
const rates = await aliexpress.getRates(aliexpressProducts);

In this example, aliexpressProducts is an array that contains item's AliExpress product id identified by aliexpress_product_id and their respective quantity. The getRates method will fetch the shipping rates, which are structured in the same format as Shopify's rates.

The aliexpress_product_id is the last pathname of the AliExpress product page url. For example,, the product id is 1005005871752711.

The output rates has similar format as the Shopify rates array:

rates = [
        "service_name": "String",
        "service_code": "String",
        "total_price": "String",
        "description": "String",
        "currency": "String",
        "min_delivery_date": "String (Date format)",
        "max_delivery_date": "String (Date format)"
    //...might have more rates option

Sample AI Prompt

I'd like a shipping rate calculator for items from AliExpress products.
The AliExpress product id is contained as part of the items sku separated with a hyphen. Split the sku and take the first part as AliExpress product id.

Sample AI Output

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

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

    // Extract AliExpress product ids from item skus
    const aliexpressProducts = => {
      const [aliexpressProductId] = item.sku.split("-");
      return { aliexpress_product_id: aliexpressProductId, quantity: item.quantity };

    // Initialize AliExpress instance with destination and currency
    const aliexpress = new AliExpress(DATA.destination, DATA.currency);

    // Get shipping rates from AliExpress
    const rates = await aliexpress.getRates(aliexpressProducts);

    // Return shipping rates in Shopify format
    return { rates };
  } catch (error) {
    // Return error rate
    return {
      rates: [
          service_name: "Error",
          service_code: "error",
          total_price: null,
          description: error.message,
          currency: DATA.currency,
          min_delivery_date: "",
          max_delivery_date: "",