Tax Calculation module
Learn about the Tax Calculation module.
The TaxCalculation
module handles calculating taxes on the Shop, Product, and Cart pages and shows the final tax. This module shows taxes based on the WooCommerce backend settings.
Specifications
This module handles the tax calculation for single product and shop products. It hides the tax class (Standard, Reduce Rate, and Zero Rate) settings in WooCommerce Tax Settings.
The tax calculation is handled via the Digital River platform.
Use the customer's shipping address for rendering tax rates for products on the Shop and Single Product page.
Hide the tax row from the Cart page to finalize the tax rate review on the Checkout page.
After all the details are on the Checkout page, click Review Order on the Drop-in UI.
Tax exclusive or inclusive from price depends on Admin tax settings. Use those settings to display the tax is inclusive or exclusive from the product price on the Single product page and Shop page.
Tax Calculation Methods
Tax Calculation class
This class is the module's entry point.
Method | Args, Returns, and Descriptions |
__construct | Arg: Return: string Description: Constructs the object by passing its dependencies |
name | Arg: - Return: string Description: Returns the name of the module |
init | Arg: - Return: void Description: Initializes the module, registers necessary hooks, and initializes |
calculate_tax | Arg: - Return: bool Description: Returns a boolean value representing if tax needs to be calculated for the current page |
Tax Calculation Container class
This class acts as a Dependency Injection container for providing dependencies to classes in the OrderManagement
module.
Method | Args, Returns, and Descriptions |
__construct | Arg: Return: void Description: Accepts a Dependency Injection container as an argument and assigns it to a container attribute |
define_services | Arg: - Return: void Description: Defines all the classes present within the module |
Product class
This class relates to various products and adds a custom class to the product container and product price element.
Method | Args, Returns, and Descriptions |
__construct | Arg: Return: void Description: Accepts |
init | Arg: - Return: void Description: Registers necessary hooks |
assets | Arg: - Return: void Description: Enqueues necessary scripts and stylesheets |
product_classes | Arg: array $classes Return: array Description: Adds custom class to the product container |
price_html | Arg: string $html, Return: string Description: Filters the price HTML markup |
maybe_calculate_tax | Arg: bool $calculate_tax Return: bool Description: If the customer is from a different country than the store, calculate taxes and return the default value for |
Cart Tax Calculation class
This class handles calculating taxes on the Cart page, shows the final tax, and shows taxes based on the WooCommerce backend settings.
Method | Args, Returns, and Descriptions |
init | Arg: - Return: void Description: Initializes the module and register necessary hooks |
assets | Arg: - Return: void Description: Enqueues necessary scripts and stylesheets |
woocommerce_cart_subtotal | Arg: float $subtotal, $compound, $cart Return: book Descripton: - |
woocommerce_cart_contents_total | Arg: float $total Return: float Description: - |
woocommerce_widget_cart_is_hidden | Arg: bool $is_hidden Return: bool Description: Creates checkout, stores it in the WooCommerce session, and returns the |
woocommerce_cart_collaterals | Arg: - Return: void Description: Loads the custom template for the cart section |
wc_get_template | Arg: - Return: void Description: Loads the custom template for the cart section if the template name is |
woocommerce_cart_shipping_method_full_label | Arg: String $label, Return: String Description: Loads the custom template for the cart section if the template name is |
woocommerce_cart_item_price | Arg: String $price, array $cart_item Return: String Description: Alters the price HTML on the |
woocommerce_cart_item_subtotal | Arg: String $subtotal, array $cart_item Return: String Description: Alters the price HTML on the |
prepare_cart_checkout_request | Arg: - Return: array Description: Prepares request data for checkout |
process_cart | Arg: - Return: Checkout Description: Processes the |
Traits\Tax Calculation Utility trait
The TaxCalculation
class uses Utility methods.
Method | Args, Returns, and Descriptions |
compare_purchase_location | Arg: Return: bool Description: Compares two purchase location data and returns |
compare_ship_from_addresses | Arg: Return: bool Description: Compares two |
Endpoints\Product Price class
This class creates a new REST API Endpoint to fetch the product price.
Method | Args, Returns, and Descriptions |
__construct | Arg: Return: void Description: Accepts |
init | Arg: - Return: void Description: Registers necessary hooks |
add_price_filters | Arg: - Return: void Description: Registers filters related to the price |
remove_price_filters | Arg: - Return: void Description: Removes registered filters |
register | Arg: - Return: void Description: Registers REST API route |
set_request | Arg: mixed $result, Return: void Description: Sets request property |
fetch_price | Arg: Return: Description: Callback to handle API Endpoint |
dr_price | Arg: String $price, Return: mixed Description: Filters the price |
dr_variation_prices | Arg: array $prices_array, Return: array Description: Filters variation prices by calculating prices via Digital River |
add_shipping_choices | Arg: array $data, Return: array Description: Adds shipping choice element to data |
add_purchase_location | Arg: array $data Return: array Description: Adds purchase location to tax estimate data |
item | Arg: Return: Description: Prepares a product to send in checkout request |
Last updated