Main site

Built-in Modules > Chicme Class

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

Class Definition

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

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


  • destination (Object): The "destination" field from the input DATA JSON object used by the calculateShippingRates function.
  • currency (String): The currency code in ISO format for which you need the shipping rates.

Usage Example

import { Chicme } from "./modules.js"
const chicme = new Chicme(DATA.destination, DATA.currency);
const chicmeProducts = [
  { chicme_variant_id: "1366613z9r8C8d5t3R3W402w35", quantity: 1 },
  { chicme_variant_id: "1M6Z7l3v4K0l4C6y6K2U8u4K0G", quantity: 1 },
  // ... additional products
const rates = await chicme.getRates(chicmeProducts);

In the given example, the Chicme class is instantiated with destination details and currency code. The getRates method then fetches shipping rates for a list of Chicme product variants, each identified by a chicme_variant_id and quantity. The structure of the returned rates is consistent with the format of Shopify's shipping rates.

Ask Chicme to include the items variant id in their data feed to get chicme_variant_id.

Sample AI Prompt

I'd like a shipping rate calculator for items from Chicme.
Enrich the data with metafield namespace "shop" with size 10.
The variant id for each Chicme items is saved in the data items metafield object "shop" namespace with key named "chicme_variant_id". In case of multiple rates option, return only the option with the minimum total price.

Sample AI Output

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

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

    // Get Chicme products
    const chicmeProducts = => {
      const chicmeVariantId = item.metafields?.shop?.find(
        (metafield) => metafield.key === "chicme_variant_id"
      return { chicme_variant_id: chicmeVariantId, quantity: item.quantity };

    // Get shipping rates from Chicme
    const chicme = new Chicme(DATA.destination, DATA.currency);
    const rates = await chicme.getRates(chicmeProducts);

    // Return only the option with the minimum total price
    const minPriceRate = rates.reduce((acc, rate) => {
      if (!acc || rate.total_price < acc.total_price) {
        return rate;
      return acc;
    }, null);

    return { rates: [minPriceRate] };
  } 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: "",