Documentation
GeoBlock
Cart & Checkout

Cart & Checkout

GeoBlock enforces restrictions at every point in the purchase flow, not just on the product page. This prevents customers from bypassing restrictions through direct cart manipulation, API calls, or AJAX quick-add buttons.

Protection Checkpoints

CheckpointHookBehaviour
Add to Cart button / APIwoocommerce_add_to_cart_validationBlock add; show error notice
Cart page loadwoocommerce_check_cart_itemsRemove restricted items; show notice per item
Checkout page loadwoocommerce_check_cart_itemsRemove restricted items; show notice per item
Order submissionwoocommerce_checkout_processBlock order if cart still contains restricted items

Add to Cart Validation

When a restricted product is added to the cart - regardless of the method (button click, AJAX, REST API, or direct POST) - GeoBlock intercepts the request via woocommerce_add_to_cart_validation and returns an error notice:

Sorry, this product is not available in your country.

The product is never added to the cart.


Cart Item Scan

On the cart page and checkout page, GeoBlock scans all existing cart items and removes any that are restricted for the current visitor. A notice is shown for each removed item:

"[Product name]" has been removed from your cart as it is not available in your country.

This handles edge cases such as:

  • Customer added the product before a restriction was applied.
  • Store owner changed restriction settings after the customer began their session.
  • Customer changed countries mid-session (e.g. connected via VPN).

Checkout Process Block

As a final safety net, GeoBlock checks all cart items again during woocommerce_checkout_process (when the customer submits the order). If a restricted product is found, the order is blocked and an error is displayed:

Your cart contains a product that is not available in your country. Please remove it before placing your order.

This catches scenarios where the cart scan was bypassed - for example, express checkout flows or REST API order creation.