Querying taxes

This topic contains the following:

  • Querying a single tax
  • Querying taxes by country
  • Querying all taxes

Querying a single tax

To query a single tax, you must perform the following:

  1. Get an instance of the orders manager.
    Get an instance of the OrdersManager object.
  2. Get the specified tax.
    To get the specified tax, you must either call the GetTax method of the manager and pass the ID of the tax as an argument, or call the GetTaxes method and filter the collection by one of the properties of the tax (e.g. title).

Here are examples of querying a single tax by ID and by title:

Querying tax by ID

public static Tax GetTaxById(Guid taxId)
{
    OrdersManager ordersManager = OrdersManager.GetManager();
 
    Tax tax = ordersManager.GetTax(taxId);
 
    return tax;
}

Querying tax by title

public static Tax GetTaxByTitle(string title)
{
    OrdersManager ordersManager = OrdersManager.GetManager();
 
    Tax tax = ordersManager.GetTaxes().Where(t => t.Title == title).SingleOrDefault();
 
    return tax;
}

Querying taxes by country

To query taxes by a specified country, you must perform the following:

  1. Get an instance of the orders manager.
    Get an instance of the OrdersManager object.
  2. Get the taxes.
    To get the taxes, you must call the GetTaxes method and filter the collection by the Country property of the Tax object.

Here is a code example:

public static List<Tax> GetTaxesByCountry(string country)
{
    OrdersManager ordersManager = OrdersManager.GetManager();
 
    List<Tax> taxes = ordersManager.GetTaxes().Where(t => t.Country == country).ToList();
 
    return taxes;
}

Querying all taxes

To query all taxes, you must perform the following:

  1. Get an instance of the orders manager.
    Get an instance of the OrdersManager object.
  2. Get the taxes.
    To get the taxes, you must call the GetTaxes method.

Here is a code example:

public static List<Tax> GetTaxes()
{
    OrdersManager ordersManager = OrdersManager.GetManager();
 
    List<Tax> taxes = ordersManager.GetTaxes().ToList();
 
    return taxes;
}

Next steps

+1-888-365-2779
sales@sitefinity.com

Related topics:

Feedback

How useful is this article?

Tell us more

Submit
Your message was successfully sent.

We appreciate your feedback.

Your message could not be sent.

OK