Process Flow: Add to Cart & Shipping

This document explains the process that occurs when a user adds items to their cart, with a focus on how shipping is calculated.

Trigger: A user adds a product to their shopping cart.

sequenceDiagram
    participant User
    participant Cart
    participant EdgePlugin as "EDGE Store Plugin"
    participant WBS_Plugin as "Weight-Based Shipping Plugin"

    User->>Cart: Adds product(s)
    EdgePlugin->>Cart: Checks if cart contains print products
    alt Cart contains print products
        Cart->>WBS_Plugin: Calculates total weight of all items
        WBS_Plugin->>WBS_Plugin: Looks up weight in its rate table
        WBS_Plugin-->>Cart: Returns shipping cost
    else Cart contains only digital products
        Cart-->>User: No shipping cost applied
    end
    Cart-->>User: Displays subtotal + shipping

Step-by-Step Breakdown

  1. Add to Cart: A user adds one or more products to their shopping cart.
  2. Content Analysis: The EDGE Store plugin checks the contents of the cart using the ZohoHelper::cartHasPrint() function. This function iterates through each item in the cart and uses the SKU decoding logic to determine if any of them are physical (“print”) products.
  3. Shipping Calculation:
    • If the cart contains at least one print product: The system calculates the total weight of all items in the cart. This weight is then passed to a third-party Weight-Based Shipping (WBS) plugin.
    • Rate Lookup: The WBS plugin looks up the total weight in its internal rate table. This table is pre-configured with the shipping costs provided by ColourTech.
    • Cost Returned: The WBS plugin returns the appropriate shipping cost for that weight bracket.
    • If the cart contains only digital products: No shipping calculation is performed, and the shipping cost is zero.
  4. Role-Based Shipping Methods: The available shipping methods (e.g., “Overnight”, “Economy”) are filtered based on the user’s role. For example, a specific corporate client might only have the “Overnight” option available to them. This is configured in the role settings.
  5. Free Shipping: Certain user roles can be configured to have free shipping. If a user with a “free shipping” role is logged in, the shipping cost will be zero, regardless of the cart’s weight.

Key Insight: The shipping cost is not calculated via a live API call to ColourTech at the moment of checkout. It is a rate lookup based on a pre-defined table, which simplifies the process and improves performance.


Next: 05 - Order Fulfillment & Accounting Flow