# Configuration

All settings are stored in WooCommerce's integration option key `woocommerce_globale_pro_settings` (an array). They are accessed exclusively through static methods on `GCBWC\Globale\Pro\Config`. The admin UI is the WooCommerce **Settings → Integrations → Global-e Cross-Border Integration** page.

---

## Global-e API section

| Constant | Option key | Type | Default | Description |
|---|---|---|---|---|
| `ENABLE_GEM_INCLUDE` | `api_enabled` | checkbox | — | Master switch: enables JS/CSS injection and activates all integration features. |
| `MERCHANT_ID` | `api_merchant_id` | text | — | Merchant ID used to load GEM/PRO assets from GEPI. |
| `MERCHANT_GUID` | `api_merchant_guid` | text | — | GUID validated on every inbound order webhook. |
| `API_BASE_URL` | `api_path` | text | `//stglite.bglobale.com/` | Base URL for GEM/PRO JavaScript and CSS assets (GEPI). |
| `API_URL` | `api_base_url` | text | `https://connect.bglobale.com/` | Base URL for back-end API calls (e.g. SaveProductList). |
| `INCLUDE_MODE` | `include_mode` | select | `pro` | `pro` or `gem` — controls which JS/CSS bundle is loaded. |
| `COOKIE_NAME_GLOBALE_DATA_KEY` | `cookie_name_globale_data_key` | text | `GlobalE_Data` | Name of the cookie Global-e sets with country/currency data. Customise only if the default conflicts with another plugin. |

---

## Products section

| Constant | Option key | Type | Default | Description |
|---|---|---|---|---|
| `EXTRA_ATTR_LIST` | `products_extra_attributes` | text | — | Comma-separated WooCommerce attribute slugs to include in the cart product payload (e.g. `attr1,attr2`). |
| `META_DATA_ATTR_LIST` | `products_meta_data_attributes` | text | — | Comma-separated product meta keys to include in the cart product payload. |
| `ENG_PRODUCT_ATTR_LIST` | `products_eng_attributes_list` | text | — | Attribute slugs whose values should be returned in English regardless of store locale. |
| `ATTRIBUTE_MAP` | `products_attributes_map` | text (JSON) | — | JSON map of WooCommerce attribute slugs to Global-e attribute keys, e.g. `{"attribute_pa_size":"size"}`. |
| `PRODUCT_BRAND_ATTR` | `products_brand_attr` | text | — | Attribute slug used as the product Brand. |
| `PRODUCT_CLASS_ATTR` | `products_class_attr` | text | — | Attribute slug used as the product class code. |
| `PRODUCT_COUNTRY_OF_ORIGIN_ATTR` | `products_country_of_origin_attr` | text | — | Attribute slug for country of origin. |
| `PRODUCT_DESCRIPTION_ATTR` | `products_description_attr` | text | — | Extra attribute slug appended to the product description. |
| `PRODUCT_HS_CODE_ATTR` | `products_hs_code_attr` | text | — | Attribute slug for the HS (Harmonised System) tariff code. |
| `PRODUCT_WEIGHT_ATTR` | `products_weight_attr` | text | — | Extra attribute slug for product weight. |
| `ENABLE_SAVE_PRODUCT_LIST` | `products_enable_save_product_list` | checkbox | `yes` | When enabled, triggers a SaveProductList API push to Global-e on every product save event. |
| `VARIATION_INHERIT_PARENT_ATTRIBUTES` | `variation_inherit_parent_attributes` | checkbox | `no` | When enabled, a variation returns the parent product's attribute value when the attribute is not set on the variation itself. |

---

## Order section

| Constant | Option key | Type | Default | Description |
|---|---|---|---|---|
| `PRODUCT_IDENTIFIER` | `product_identifier` | select | `sku` | `sku` or `productId` — controls which WooCommerce field is sent as the product identifier to Global-e. |
| `SKIP_CART_HASH_VALIDATION` | `order_skip_cart_hash_validation` | checkbox | `no` | Bypasses cart hash validation on order creation. Use only if cart hash mismatches are occurring in a supported multi-store scenario. |
| `SHIPPING_MAPPING` | `shipping_mapping` | select | `plugin` | `none`, `plugin`, or `globale` — selects how WooCommerce shipping method IDs are mapped to Global-e shipping codes. |
| `SAVE_COUNTRY_NAME_AS` | `save_country_name_as` | select | `name` | `name` or `code` — controls whether the buyer country is saved to the order as a full name or ISO 2-letter code. |
| `EXTRA_META_TO_ORDER_ITEM` | `extra_meta_to_product_item` | text (JSON) | — | JSON map of extra meta key→value pairs to attach to every order line item, e.g. `{"internationalOrder":"YES"}`. |
| `RECONCILIATION_VAT` | `reconciliation_vat` | select | `default` | `default` or `deduct` — deduct mode subtracts VAT from order totals during reconciliation. |
| `RESTOCK_REFUNDED_PRODUCTS` | `restock_refunded_products` | checkbox | `yes` | Restores product inventory when a Global-e refund is processed. |
| `IS_LOGGER_ENABLED` | `is_logger_enabled` | checkbox | `yes` | Enables WooCommerce logger output (`source: globale_pro`). |
| `ADD_SHIPPING_TO_TOTALS` | `ADD_SHIPPING_TO_TOTALS` | checkbox | `no` | Adds shipping cost to product total cost in order payloads. |
| `ALLOW_ORDER_CURRENCY_FROM_REQUEST` | `ALLOW_ORDER_CURRENCY_FROM_REQUEST` | checkbox | `no` | Allows the order currency to differ from the store default when supplied by the order creation request. |
| `APPEND_GE_ORDER_NUMBER_TO_SEQ` | `append_ge_order_number_to_seq` | checkbox | `yes` | Appends the Global-e order number in brackets to the sequential order number (requires Sequential Order Numbers plugin). |

---

## Checkout section

| Constant | Option key | Type | Default | Description |
|---|---|---|---|---|
| `ENABLE_JS_CODE_ON_CHECKOUT_PAGE` | `enable_js_code_on_checkout_page` | checkbox | `yes` | Enables the legacy custom JS code field on checkout (deprecated in favour of the Analytics section). |
| `CHECKOUT_JS_CODE_ON_CHECKOUT_PAGE` | `checkout_js_code_on_checkout_page` | textarea | (see `Config::getDefaultJsCodeOnCheckoutPage()`) | Raw JS injected inline on the checkout page. Stored and loaded unescaped. |
| `CHECKOUT_REMOVE_COUPONS_ON_SWITCH_COUNTRY` | `checkout_remove_coupons_on_switch_country` | checkbox | `no` | Removes all coupons from the cart when the shopper switches from the domestic country to any other country. |
| `CHECKOUT_STORE_CODE` | `checkout_store_code` | text | — | Sets `StoreCode` in the `GlobalE_Gem_Data` cookie. Falls back to `"default"` when empty. |

---

## Analytics section

Each analytics provider has an enable toggle and a textarea for the raw JS snippet. Snippets are injected inside a `glegem('OnCheckoutStepLoaded', …)` callback at checkout.

| Constant pair | Steps | Default snippet |
|---|---|---|
| `ENABLE_GA4_ON_CHECKOUT_LOADED` / `GA4_ON_CHECKOUT_LOADED` | `LOADED` | GA4 `begin_checkout` event with product array |
| `ENABLE_GA4_ON_CHECKOUT_CONFIRMATION` / `GA4_ON_CHECKOUT_CONFIRMATION` | `CONFIRMATION` (IsSuccess) | GA4 `purchase` event |
| `ENABLE_FACEBOOK_PIXEL_ON_CHECKOUT_CONFIRMATION` / `FACEBOOK_PIXEL_ON_CHECKOUT_CONFIRMATION` | `CONFIRMATION` (IsSuccess) | `fbq('track', 'Purchase', …)` |
| `ENABLE_TIKTOK_PIXEL_ON_CHECKOUT_CONFIRMATION` / `TIKTOK_PIXEL_ON_CHECKOUT_CONFIRMATION` | `CONFIRMATION` (IsSuccess) | `ttq.track('CompletePayment', …)` |

See [analytics-integration.md](analytics-integration.md) for the full `OnCheckoutStepLoaded` wrapper structure.

---

## System / internal constants

These are not user-configurable; they are set programmatically by `Config::initFromOptions()`.

| Constant | Value | Description |
|---|---|---|
| `API_CACHE_FOLDER` | `{plugin_dir}cache/` | Filesystem path for API response cache. |
| `API_CACHE_ENABLED` | `true` | Enables API response caching. |
| `COOKIE_NAME_GEM_DATA` | `GlobalE_Gem_Data` | Fixed name of the GEM cookie. |
| `COOKIE_NAME_DEFAULT_GLOBALE_DATA` | `GlobalE_Data` | Default name of the Global-e data cookie. |

---

## Accessing config values

```php
// After Config::initFromOptions() has been called (inside WC integration init):
$merchantId  = \GCBWC\Globale\Pro\Config::getMerchantId();
$isGemMode   = \GCBWC\Globale\Pro\Config::isGemMode();
$identifier  = \GCBWC\Globale\Pro\Config::getProductIdentifier(); // 'sku' | 'productId'
```

`Config::initFromOptions()` is called from `GlobaleProIntegration::init_integration()` with the full WooCommerce settings array. It also sets `GCBWC::$logger_enabled` based on `IS_LOGGER_ENABLED`.
