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
| Checkpoint | Hook | Behaviour |
|---|---|---|
| Add to Cart button / API | woocommerce_add_to_cart_validation | Block add; show error notice |
| Cart page load | woocommerce_check_cart_items | Remove restricted items; show notice per item |
| Checkout page load | woocommerce_check_cart_items | Remove restricted items; show notice per item |
| Order submission | woocommerce_checkout_process | Block 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.