public
getPriceItemsPayment
(mixed $price, mixed $priceAdditional, mixed $calculationType, mixed $total, mixed $taxId, mixed $tax, mixed $taxCalculationType, mixed $taxTitle = '', mixed $freePayment = 0, mixed $round = 1, mixed $langPrefix = 'PAYMENT_')
public function getPriceItemsPayment($price, $priceAdditional, $calculationType, $total, $taxId, $tax, $taxCalculationType, $taxTitle = '', $freePayment = 0, $round = 1, $langPrefix = 'PAYMENT_')
{
// PERCENTAGE PRICE OF PAYMENT
// CALCULATED FROM TOTAL - PAYMENT (TOTAL BEFORE PAYMENT PRICE)
// $total[brutto] can be changed e.g. to netto, etc.
$priceO = array();
$priceO['costinfo'] = '';
$priceO['costinfoprice'] = '';
$priceO['costinfopriceadditional'] = '';
if ($calculationType == 1 && isset($total['brutto'])) {
$priceO['costinfo'] = $this->roundPrice($price) . ' %';
$price = $total['brutto'] * $price / 100;
$priceO['costinfoprice'] = $price;
} else {
$priceO['costinfoprice'] = $price;
}
if ($priceAdditional > 0) {
$price = $price + $priceAdditional;
$priceO['costinfo'] .= ' + ' . $this->getPriceFormat($priceAdditional);
$priceO['costinfopriceadditional'] = $priceAdditional;
}
$priceO['costinfo'] = $priceO['costinfo'] != '' ? '(' . $priceO['costinfo'] . ')' : '';
//$priceO['costinfo'] = $priceO['costinfo'] != '' ? '' . $priceO['costinfo'] . '' : '';
if ($round == 1) {
$price = $this->roundPrice($price, 'payment');
}
// Change TAX based on country or region
$taxChangedA = PhocacartTax::changeTaxBasedOnRule($taxId, $tax, $taxCalculationType, $taxTitle);
$tax = $this->roundPrice($taxChangedA['taxrate'], 'payment');
$taxTitle = $taxChangedA['taxtitle'];
//$taxTitle = JText::_($taxTitle);
//$app = JFactory::getApplication();
//$paramsC = PhocacartUtils::getComponentParameters();
$paramsC = PhocacartUtils::getComponentParameters();
$tax_calculation_payment = $paramsC->get('tax_calculation_payment', 0);
// Define - the function always return all variables so we don't need to check them
$priceO['nettoformat'] = '';
$priceO['taxformat'] = '';
$priceO['bruttoformat'] = '';
$priceO['bruttotxt'] = '';
$priceO['netto'] = 0;
$priceO['tax'] = 0;
$priceO['taxid'] = 0;
$priceO['taxkey'] = '';
$priceO['brutto'] = 0;
$priceO['nettotxt'] = Text::_('COM_PHOCACART_' . $langPrefix . 'PRICE_EXCL_TAX');
$priceO['taxtxt'] = '';
$priceO['bruttotxt'] = Text::_('COM_PHOCACART_' . $langPrefix . 'PRICE_INCL_TAX');
$priceO['zero'] = 0;
$priceO['freepayment'] = 0;
$priceO['taxtype'] = $taxCalculationType;
$priceO['taxrate'] = $tax;
$priceO['netto_title_lang'] = 'COM_PHOCACART_' . $langPrefix . 'PRICE_EXCL_TAX';
$priceO['netto_title'] = Text::_($priceO['netto_title_lang']);
$priceO['brutto_title_lang'] = 'COM_PHOCACART_' . $langPrefix . 'PRICE_INCL_TAX';
$priceO['brutto_title'] = Text::_($priceO['brutto_title_lang']);
// E.G. if coupon set the shipping costs to null - free shipping
if ($freePayment == 1) {
$priceO['netto'] = 0;
$priceO['nettotxt'] = Text::_('COM_PHOCACART_FREE_PAYMENT');
$priceO['tax'] = 0;
$priceO['taxid'] = 0;
$priceO['taxkey'] = '';
$priceO['brutto'] = 0;
$priceO['bruttotxt'] = Text::_('COM_PHOCACART_FREE_PAYMENT');
$priceO['bruttoformat'] = $this->getPriceFormat($priceO['brutto']);
$priceO['freepayment'] = 1;
$priceO['zero'] = 1;
$priceO['description'] = '';
$priceO['costinfo'] = '';
$priceO['title_lang'] = 'COM_PHOCACART_FREE_PAYMENT';
$priceO['title'] = Text::_($priceO['title_lang']);
$priceO['netto_title_lang'] = 'COM_PHOCACART_FREE_PAYMENT';
$priceO['netto_title'] = Text::_($priceO['netto_title_lang']);
$priceO['brutto_title_lang'] = 'COM_PHOCACART_FREE_PAYMENT';
$priceO['brutto_title'] = Text::_($priceO['brutto_title_lang']);
return $priceO;
}
$priceO['taxtxt'] = Text::_($taxTitle);
$priceO['tax_title_lang'] = $taxTitle;
$priceO['tax_title'] = Text::_($taxTitle);
$priceO['tax_title_suffix'] = '';
$priceO['tax_title_suffix2'] = '';
// NO TAX
if ($tax_calculation_payment == 0) {
$priceO['netto'] = $price;
$priceO['tax'] = 0;
$priceO['taxid'] = 0;
$priceO['taxkey'] = '';
$priceO['brutto'] = $price;
// EXCLUSIVE TAX
} else {
if ($tax_calculation_payment == 1) {
$priceO['netto'] = $price;
if ($taxCalculationType == 2) {
// FIX
$priceO['tax'] = $tax;
$priceO['brutto'] = $priceO['netto'] + $tax;
$priceO['taxtxt'] = Text::_('COM_PHOCACART_' . $langPrefix . 'PRICE') . ' ' . Text::_($taxTitle) . ' (' . $this->getPriceFormat($tax) . ')';
$priceO['tax_title_lang'] = 'COM_PHOCACART_' . $langPrefix . 'PRICE';
$priceO['tax_title'] = Text::_($priceO['tax_title_lang']);
$priceO['tax_title_suffix'] = $taxTitle;
$priceO['tax_title_suffix2'] = $this->getPriceFormat($tax);
} else {
// Percentage
$priceO['tax'] = $priceO['netto'] * ($tax / 100);
if ($round == 1) {
$priceO['tax'] = $this->roundPrice($priceO['tax'], 'payment');
}
$priceO['brutto'] = $priceO['netto'] + $priceO['tax'];
$priceO['taxtxt'] = Text::_('COM_PHOCACART_' . $langPrefix . 'PRICE') . ' ' . Text::_($taxTitle) . ' (' . $this->getTaxFormat($tax, $taxCalculationType, 0) . ')';
$priceO['tax_title_lang'] = 'COM_PHOCACART_' . $langPrefix . 'PRICE';
$priceO['tax_title'] = Text::_($priceO['tax_title_lang']);
$priceO['tax_title_suffix'] = $taxTitle;
$priceO['tax_title_suffix2'] = $this->getTaxFormat($tax, $taxCalculationType, 0);
}
$priceO['bruttotxt'] = Text::_('COM_PHOCACART_' . $langPrefix . 'PRICE_INCL_TAX');
$priceO['nettotxt'] = Text::_('COM_PHOCACART_' . $langPrefix . 'PRICE_EXCL_TAX');
$priceO['taxid'] = $taxId;
$priceO['taxkey'] = PhocacartTax::getTaxKey($taxId, $taxChangedA['taxcountryid'], $taxChangedA['taxregionid']);
$priceO['netto_title_lang'] = 'COM_PHOCACART_' . $langPrefix . 'PRICE_EXCL_TAX';
$priceO['netto_title'] = Text::_($priceO['netto_title_lang']);
$priceO['brutto_title_lang'] = 'COM_PHOCACART_' . $langPrefix . 'PRICE_INCL_TAX';
$priceO['brutto_title'] = Text::_($priceO['brutto_title_lang']);
// INCLUSIVE TAX
} else {
if ($tax_calculation_payment == 2) {
$priceO['brutto'] = $price;
if ($taxCalculationType == 2) {
// FIX
$priceO['tax'] = $tax;
$priceO['netto'] = $priceO['brutto'] - $tax;
$priceO['taxtxt'] = Text::_('COM_PHOCACART_' . $langPrefix . 'PRICE') . ' ' . Text::_($taxTitle) . ' (' . $this->getPriceFormat($tax) . ')';
$priceO['tax_title_lang'] = 'COM_PHOCACART_' . $langPrefix . 'PRICE';
$priceO['tax_title'] = Text::_($priceO['tax_title_lang']);
$priceO['tax_title_suffix'] = $taxTitle;
$priceO['tax_title_suffix2'] = $this->getPriceFormat($tax);
} else {
// Percentage
$priceO['tax'] = $priceO['brutto'] - $priceO['brutto'] / ($tax / 100 + 1);
if ($round == 1) {
$priceO['tax'] = $this->roundPrice($priceO['tax'], 'payment');
}
$priceO['netto'] = $priceO['brutto'] - $priceO['tax'];
$priceO['taxtxt'] = Text::_('COM_PHOCACART_' . $langPrefix . 'PRICE') . ' ' . Text::_($taxTitle) . ' (' . $this->getTaxFormat($tax, $taxCalculationType, 0) . ')';
$priceO['tax_title_lang'] = 'COM_PHOCACART_' . $langPrefix . 'PRICE';
$priceO['tax_title'] = Text::_($priceO['tax_title_lang']);
$priceO['tax_title_suffix'] = $taxTitle;
$priceO['tax_title_suffix2'] = $this->getTaxFormat($tax, $taxCalculationType, 0);
}
$priceO['bruttotxt'] = Text::_('COM_PHOCACART_' . $langPrefix . 'PRICE_INCL_TAX');
$priceO['nettotxt'] = Text::_('COM_PHOCACART_' . $langPrefix . 'PRICE_EXCL_TAX');
$priceO['taxid'] = $taxId;
$priceO['taxkey'] = PhocacartTax::getTaxKey($taxId, $taxChangedA['taxcountryid'], $taxChangedA['taxregionid']);
$priceO['netto_title_lang'] = 'COM_PHOCACART_' . $langPrefix . 'PRICE_EXCL_TAX';
$priceO['netto_title'] = Text::_($priceO['netto_title_lang']);
$priceO['brutto_title_lang'] = 'COM_PHOCACART_' . $langPrefix . 'PRICE_INCL_TAX';
$priceO['brutto_title'] = Text::_($priceO['brutto_title_lang']);
}
}
}
if ($priceO['netto'] == $priceO['brutto']) {
$priceO['netto'] = false;
$priceO['bruttotxt'] = Text::_('COM_PHOCACART_' . $langPrefix . 'PRICE');
$priceO['nettotxt'] = Text::_('COM_PHOCACART_' . $langPrefix . 'PRICE');
$priceO['netto_title_lang'] = 'COM_PHOCACART_' . $langPrefix . 'PRICE';
$priceO['netto_title'] = Text::_($priceO['netto_title_lang']);
$priceO['brutto_title_lang'] = 'COM_PHOCACART_' . $langPrefix . 'PRICE';
$priceO['brutto_title'] = Text::_($priceO['brutto_title_lang']);
}
//if ($tax_calculation_payment > 0) {
if ($priceO['netto']) {
$priceO['nettoformat'] = $this->getPriceFormat($priceO['netto']);
}
if ($priceO['tax']) {
$priceO['taxformat'] = $this->getPriceFormat($priceO['tax']);
}
//}
$priceO['bruttoformat'] = $this->getPriceFormat($priceO['brutto']);
if ($priceO['brutto'] == 0 && $priceO['netto'] == 0) {
$priceO['zero'] = 1;
}
if ($round == 1) {
$priceO['netto'] = $this->roundPrice($priceO['netto']);
$priceO['brutto'] = $this->roundPrice($priceO['brutto']);
$priceO['tax'] = $this->roundPrice($priceO['tax']);
}
return $priceO;
}