Note: This mod' requires you to have setup your store as follows:
- AdminCP > Tax Settings:
- Show Prices on Product Listings: Including and excluding tax
- Show Prices on Product Pages: Including and excluding tax
- Edit the currency streams accordingly (This mod assumes EU/UK are VAT inclusive, everything else exclusive)
- Obviously to have tax setup properly for the appropriate country zones using the appropriate currencies
Open: /lib/pricing.php
Find:
Code: Select all
require_once(ISC_BASE_PATH."/lib/currency.php");
Code: Select all
/*
* MOD set flag for Price format based on the currency being displayed
* eg: If VAT set for EU/UK countries it will show inclusive for GBP/EURO
* and exclusive for any non-VAT currencies
*/
function formatPriceDependentOnCurrency($options=array(), $currencyId=false) {
if(!key_exists('CurrentCurrency', $GLOBALS) && !$currencyId) {
return $options;
}
$toCurrencyId = $currencyId ? $currencyId : $GLOBALS['CurrentCurrency'];
$toCurrency = GetCurrencyById($toCurrencyId);
if(!in_array($toCurrency['currencycode'], array('GBP', 'EUR'))) {
$options['displayFormat'] = TAX_PRICES_DISPLAY_EXCLUSIVE;
$options['dropLabel'] = true;
$currency2Country = array(
'USD' => 'US',
'CAD' => 'CA',
'AUD' => 'AU'
);
if(key_exists($toCurrency['currencycode'], $currency2Country)) {
$options['countryID'] = GetCountryIdByISO2($currency2Country[$toCurrency['currencycode']]);
/* $GLOBALS['ISC_CLASS_LOG']->LogSystemDebug('php', "CountryISO {$currency2Country[$toCurrency['currencycode']]} CountryID : {$options['countryID']}" ,
"New Country set based on currency : {$toCurrency['currencycode']}");
*/
}
}
else {
$options['displayFormat'] = TAX_PRICES_DISPLAY_INCLUSIVE;
// Default back to UK to ensure pricing updates back to tax inclusive
$options['countryID'] = GetCountryIdByISO2('GB');
}
return $options;
}
// MOD END
Code: Select all
function formatProductCatalogPrice($product, array $options = array())
{
$displayFormat = getConfig('taxDefaultTaxDisplayCatalog');
$options['displayInclusive'] = $displayFormat;
if($displayFormat != TAX_PRICES_DISPLAY_BOTH) {
return formatProductPrice($product, $product['prodcalculatedprice'], $options);
}
$options['displayInclusive'] = TAX_PRICES_DISPLAY_INCLUSIVE;
$priceIncTax = formatProductPrice($product, $product['prodcalculatedprice'], $options);
$options['displayInclusive'] = TAX_PRICES_DISPLAY_EXCLUSIVE;
$priceExTax = formatProductPrice($product, $product['prodcalculatedprice'], $options);
$output = '<span class="CatalogPriceIncTax">';
$output .= $priceIncTax;
$output .= getLang('CatalogPriceIncTaxLabel', array(
'label' => getConfig('taxLabel')
));
$output .= '</span> ';
$output .= '<span class="CatalogPriceExTax">';
$output .= $priceExTax;
$output .= getLang('CatalogPriceExTaxLabel', array(
'label' => getConfig('taxLabel')
));
$output .= '</span>';
return $output;
}
Code: Select all
function formatProductCatalogPrice($product, array $options = array())
{
$displayFormat = getConfig('taxDefaultTaxDisplayCatalog');
$options['displayInclusive'] = $displayFormat;
//MOD override tax display format
if(key_exists('displayFormat', $options)) {
$option_format = $options['displayFormat'];
}
//MOD END
if($displayFormat != TAX_PRICES_DISPLAY_BOTH) {
return formatProductPrice($product, $product['prodcalculatedprice'], $options);
}
$options['displayInclusive'] = TAX_PRICES_DISPLAY_INCLUSIVE;
$priceIncTax = formatProductPrice($product, $product['prodcalculatedprice'], $options);
$options['displayInclusive'] = TAX_PRICES_DISPLAY_EXCLUSIVE;
$priceExTax = formatProductPrice($product, $product['prodcalculatedprice'], $options);
// MOD override tax display format
if($priceIncTax == $priceExTax) {
return $priceIncTax;
}
$output = '';
if(!isset($option_format) || $option_format == TAX_PRICES_DISPLAY_INCLUSIVE) {
$output = '<span class="CatalogPriceIncTax">';
$output .= $priceIncTax;
$output .= getLang('CatalogPriceIncTaxLabel', array(
'label' => getConfig('taxLabel')
));
$output .= '</span> ';
}
if(!isset($option_format) || $option_format == TAX_PRICES_DISPLAY_EXCLUSIVE) {
$output .= '<span class="CatalogPriceExTax">';
$output .= $priceExTax;
if(!key_exists('dropLabel', $options)) {
$output .= getLang('CatalogPriceExTaxLabel', array(
'label' => getConfig('taxLabel')
));
}
$output .= '</span>';
}
//MOD END
return $output;
}
Code: Select all
function formatProductDetailsPrice($product, array $options = array())
{
$displayFormat = getConfig('taxDefaultTaxDisplayProducts');
$options['displayInclusive'] = $displayFormat;
if($displayFormat != TAX_PRICES_DISPLAY_BOTH) {
return formatProductPrice($product, $product['prodcalculatedprice'], $options);
}
$options['displayInclusive'] = TAX_PRICES_DISPLAY_INCLUSIVE;
$priceIncTax = formatProductPrice($product, $product['prodcalculatedprice'], $options);
$options['displayInclusive'] = TAX_PRICES_DISPLAY_EXCLUSIVE;
$priceExTax = formatProductPrice($product, $product['prodcalculatedprice'], $options);
$output = '<span class="ProductDetailsPriceIncTax">';
$output .= $priceIncTax;
$output .= getLang('ProductDetailsPriceIncTaxLabel', array(
'label' => getConfig('taxLabel')
));
$output .= '</span> ';
$output .= '<span class="ProductDetailsPriceExTax">';
$output .= $priceExTax;
$output .= getLang('ProductDetailsPriceExTaxLabel', array(
'label' => getConfig('taxLabel')
));
$output .= '</span>';
return $output;
}
Code: Select all
function formatProductDetailsPrice($product, array $options = array())
{
$displayFormat = getConfig('taxDefaultTaxDisplayProducts');
$options['displayInclusive'] = $displayFormat;
//MOD override tax display format
if(key_exists('displayFormat', $options)) {
$option_format = $options['displayFormat'];
}
//MOD END
if($displayFormat != TAX_PRICES_DISPLAY_BOTH) {
return formatProductPrice($product, $product['prodcalculatedprice'], $options);
}
$options['displayInclusive'] = TAX_PRICES_DISPLAY_INCLUSIVE;
$priceIncTax = formatProductPrice($product, $product['prodcalculatedprice'], $options);
$options['displayInclusive'] = TAX_PRICES_DISPLAY_EXCLUSIVE;
$priceExTax = formatProductPrice($product, $product['prodcalculatedprice'], $options);
// MOD override tax display format
if($priceIncTax == $priceExTax) {
return $priceIncTax;
}
$output = '';
if(!isset($option_format) || $option_format == TAX_PRICES_DISPLAY_INCLUSIVE) {
$output = '<span class="ProductDetailsPriceIncTax">';
$output .= $priceIncTax;
$output .= getLang('ProductDetailsPriceIncTaxLabel', array(
'label' => getConfig('taxLabel')
));
$output .= '</span> ';
}
if(!isset($option_format) || $option_format == TAX_PRICES_DISPLAY_EXCLUSIVE) {
$output .= '<span class="ProductDetailsPriceExTax">';
$output .= $priceExTax;
if(!key_exists('dropLabel', $options)) {
$output .= getLang('CatalogPriceExTaxLabel', array(
'label' => getConfig('taxLabel')
));
}
$output .= '</span>';
}
//MOD END
return $output;
}
Open: /includes/display/ProductDetails.php
Find:
Code: Select all
$GLOBALS['ProductPrice'] = formatProductDetailsPrice($product, $options);
Code: Select all
//MOD do not show tax when currency is outside the UK/EU
$options = formatPriceDependentOnCurrency($options);
//MOD End
Code: Select all
$displayFormat = getConfig('taxDefaultTaxDisplayProducts');
Code: Select all
//MOD do not show tax when currency is outside the UK/EU
$displayFormat = (is_array($options) && key_exists('displayFormat', $options)) ? $options['displayFormat'] : getConfig('taxDefaultTaxDisplayProducts');
//MOD End
Open: /lib/templates/product_panel.php
Find:
Code: Select all
$GLOBALS['ProductPrice'] = formatProductCatalogPrice($row);
Code: Select all
//MOD do not show tax when currency is outside the UK/EU
$options = formatPriceDependentOnCurrency();
// $GLOBALS['ProductPrice'] = formatProductCatalogPrice($row);
$GLOBALS['ProductPrice'] = formatProductCatalogPrice($row, $options);
//MOD End