Skip to main content

Documentation Portal

Checkout - Stock Validation, Block

Stock Validation during Checkout

This feature lets you validate your stock when an order is placed.

During checkout, when a customer clicks the Pay and Place Order button, Global-e sends a request to your stock validation endpoint.

If a product is out of stock, a pop-up informs the customer that the items are no longer available, as shown in the following example.

image-20231003-170834.png

When clicking OK, the customer is redirected to the cart page where they can modify quantities.

To set up stock validation:

Implement either of the following Stock Validation endpoints:

  • GetCheckoutCartInfo add a parameter validateStock=true - OR -

  • Create a new API endpoint that returns the same response as the GetCheckoutCartInfo (see examples below). In this case, notify us so that we can configure it on the Global-e side.

When Global-e calls your Stock Validation endpoint:

  • If all products are in stock, the API returns the same line items displayed in the original GetCheckoutCartInfo response. See examples 1 and 2 below.

  • If a product is out of stock, check your inventory and update the product availability for the line item(s) for which there is not enough stock. See example 3 below.

    This is the stage when the pop-up appears, prompting the shopper to modify their ordered quantity.

Sample Response

Example 1: Original getCheckoutCartInfo response used to initiate the checkout. The OrderedQuantity = 5 units.

{
    "productsList": [{
            "ProductCode": "SKU or product identifier 1",
            "CartItemId": "lineID1",
            "NameEnglish": "My First Product",
            "Name": "Product name",
            "DescriptionEnglish": "Product description",
            "Description": "Product description",
            "URL": "https:/domain/page.html",
            "ImageURL": "https://domain/image.jpg",
            "ImageWidth": 100,
            "ImageHeight": 100,
            "OriginalListPrice": 100,
            "OriginalSalePrice": 100,
            "OrderedQuantity": 5,
            "IsBlockedForGlobalE": false,
            "Weight": 11
        }
    ]
}

Example 2: Stock validation response without changes in stock levels. The OrderedQuantity = 5, which is the same quantity as in the previous example.

{
    "productsList": [{
            "ProductCode": "SKU or product identifier 1",
            "CartItemId": "lineID1",
            "NameEnglish": "My First Product",
            "Name": "Product name",
            "DescriptionEnglish": "Product description",
            "Description": "Product description",
            "URL": "https:/domain/page.html",
            "ImageURL": "https://domain/image.jpg",
            "ImageWidth": 100,
            "ImageHeight": 100,
            "OriginalListPrice": 100,
            "OriginalSalePrice": 100,
            "OrderedQuantity": 5,
            "IsBlockedForGlobalE": false,
            "Weight": 11
        }
    ]
}

Example 3: Stock validation response with changes in stock levels. The OrderedQuantity = 3, a stock reduction from 5 to 3 units. This is when the pop-up is displayed, prompting the shopper to adjust their ordered quantity.

{
    "productsList": [{
            "ProductCode": "SKU or product identifier 1",
            "CartItemId": "lineID1",
            "NameEnglish": "My First Product",
            "Name": "Product name",
            "DescriptionEnglish": "Product description",
            "Description": "Product description",
            "URL": "https:/domain/page.html",
            "ImageURL": "https://domain/image.jpg",
            "ImageWidth": 100,
            "ImageHeight": 100,
            "OriginalListPrice": 100,
            "OriginalSalePrice": 100,
            "OrderedQuantity": 3,
            "IsBlockedForGlobalE": false,
            "Weight": 11
        }
    ]
}
Block Int'l Orders from the Domestic Checkout

To prevent accidental international orders on your domestic checkout page, consider removing Global-e-operated countries from the country dropdown list; no action is needed if your checkout does not have a country dropdown.

Alternatively, you can redirect your international shoppers to the international checkout after they make their country selection, as detailed below.

Guest Shoppers

  1. Add a country dropdown list to your checkout page if one is not already present. Ensure that each option's value is a two-letter country code.

  2. Share the dropdown element ID with Global-e so that we can enable the feature for you.

Upon activation, if a shopper chooses a Global-e-operated country from your dropdown list, a popup prompts them to confirm the shipping destination for the order. The shopper is then redirected to the cart page, where their country is pre-selected.

Example:

<select id="country">         
<option value=""> </option>         
<option data-title="Italy" value="IT">Italy</option>         
<option data-title="Japan" value="JP">Japan</option>         
<option data-title="Singapore" value="SG">Singapore</option>         
<option data-title="South Africa" value="ZA">South Africa</option>         
<option data-title="United Kingdom" value="GB">United Kingdom</option>
</select>

Logged in Users

For shoppers with accounts containing saved addresses, Global-e must retrieve the two-letter country code from their selected shipping address.

Specify the source—Cookie, LocalStorage, SessionStorage, Global, or DOM element—from which we should retrieve this value, and we will configure it accordingly.

When clicking the checkout button, a popup prompts the shopper to confirm their shipping country. The shopper is then redirected to the cart page, where their country is pre-selected.