ClassesBigCommerceFormsSwitch Currency Handler

Switch_Currency_Handler

Handles the logic for switching currencies in the BigCommerce cart and triggers success/error actions.

This class interacts with the currency management system and the cart API to update the currency and recreate the cart if needed, ensuring the correct display and pricing in the switched currency.

Constants

ConstantVisibilityTypeValue
ACTIONpublicstring’switch-currency’

Methods

__construct

Switch_Currency_Handler constructor.

public __construct(\BigCommerce\Currency\Currency $currency, \BigCommerce\Api\v3\Api\CartApi $cart_api): mixed

Initializes the handler with the required dependencies: the currency management object and the cart API client.

Parameters:

ParameterTypeDescription
$currency\BigCommerce\Currency\CurrencyThe currency management object.
$cart_api\BigCommerce\Api\v3\Api\CartApiThe API client for managing carts.

handle_request

Handles the form submission for switching currency.

public handle_request(array $submission): void

Validates the form submission, switches the currency, and recreates the cart if necessary. If the submission is valid, it triggers the relevant success action or error handling hooks.

Parameters:

ParameterTypeDescription
$submissionarrayThe submitted form data.


Automatically generated on 2025-01-21