> For the complete documentation index, see [llms.txt](https://developer.esw.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.esw.com/adobe-commerce-magento/integration/retrieve-calculated-prices-programmatically.md).

# Retrieve Calculated Prices Programmatically

Some custom modules run below the standard Adobe Commerce pricing flow.

In those cases, the normal ESW pricing interceptors may not run automatically.

If that happens, call the ESW pricing service directly to get the calculated price for the target market.

### When to use this approach

Use direct price calculation when:

* your custom module bypasses native Adobe Commerce price rendering
* ESW pricing plugins are not triggered in the request flow
* you still need market-specific converted and rounded prices

For general pricing setup, see [Pricing Model](/adobe-commerce-magento/adobe-commerce-extension-integration/getting-started/pricing-model.md).

### Example

This example calculates a shopper price for a product with a base price of `59.00` in `USD` and returns the calculated price for `CA` in `CAD`.

{% code expandable="true" %}

```php
<?php

namespace Vendor\Module\Example;

use EShopWorld\Checkout\Pricing\TaxManager;

class ExampleClass
{
    /**
     * @var TaxManager
     */
    private $taxManager;

    public function __construct(TaxManager $taxManager)
    {
        $this->taxManager = $taxManager;
    }

    public function getCalculatedPrice()
    {
        $basePrice = 59.00;
        $currencyCodeFrom = 'USD';
        $currencyCodeTo = 'CAD';
        $countryCodeTo = 'CA';

        return round(
            $this->taxManager->applyRoundingModel(
                $this->taxManager->applyRetailerTaxes(
                    $this->taxManager->convertCurrency(
                        $basePrice,
                        $currencyCodeFrom,
                        $currencyCodeTo
                    ),
                    null,
                    $countryCodeTo
                )
            ),
            $this->taxManager->getCurrencyExponent()
        );
    }
}
```

{% endcode %}

### What this example does

The calculation applies these steps:

1. converts the base price from the source currency to the shopper currency
2. applies ESW retailer tax logic for the target country
3. applies the ESW rounding model
4. rounds the final amount using the currency exponent

### Expected result

When this integration is used correctly:

* custom modules can return ESW-calculated prices outside the default pricing flow
* converted prices stay aligned with ESW pricing logic
* country-specific tax and rounding behavior is preserved


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developer.esw.com/adobe-commerce-magento/integration/retrieve-calculated-prices-programmatically.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
