Merge pull request #280 from sumitwebkul/gli-653
Wrong amount displayed in Order confirmation page in the payment gateways PaymentReturn Hook
This commit is contained in:
@@ -1913,18 +1913,22 @@ class OrderCore extends ObjectModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sum of total_paid_tax_incl of the orders with similar reference
|
||||
*
|
||||
* @since 1.5.0.1
|
||||
* Get the sum of total_paid_tax_incl/advance_paid_amount of the orders with similar reference
|
||||
* @param integer $getAdvancePaid (send 1 if want total advance paid amount)
|
||||
* @return float
|
||||
*/
|
||||
public function getOrdersTotalPaid()
|
||||
public function getOrdersTotalPaid($getAdvancePaid = 0)
|
||||
{
|
||||
return Db::getInstance()->getValue('
|
||||
SELECT SUM(total_paid_tax_incl)
|
||||
FROM `'._DB_PREFIX_.'orders`
|
||||
WHERE `reference` = \''.pSQL($this->reference).'\'
|
||||
AND `id_cart` = '.(int)$this->id_cart);
|
||||
$sql = 'SELECT';
|
||||
if ($getAdvancePaid) {
|
||||
$sql .= ' SUM(advance_paid_amount)';
|
||||
} else {
|
||||
$sql .= ' SUM(total_paid_tax_incl)';
|
||||
}
|
||||
$sql .= 'FROM `'._DB_PREFIX_.'orders` WHERE `reference` = \''.pSQL($this->reference).
|
||||
'\' AND `id_cart` = '.(int)$this->id_cart;
|
||||
|
||||
return Db::getInstance()->getValue($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -188,31 +188,37 @@ class bankwire extends PaymentModule
|
||||
if (!$this->active) {
|
||||
return;
|
||||
}
|
||||
|
||||
$objOrder = $params['objOrder'];
|
||||
$cart = new Cart($objOrder->id_cart);
|
||||
$state = $objOrder->getCurrentState();
|
||||
if (in_array($state, array(Configuration::get('PS_OS_BANKWIRE'), Configuration::get('PS_OS_OUTOFSTOCK'), Configuration::get('PS_OS_OUTOFSTOCK_UNPAID')))) {
|
||||
if ($objOrder->is_advance_payment) {
|
||||
$order_total = $objOrder->advance_paid_amount;
|
||||
$orderState = $objOrder->getCurrentState();
|
||||
$smartyVars = array();
|
||||
if (in_array(
|
||||
$orderState,
|
||||
array(
|
||||
Configuration::get('PS_OS_BANKWIRE'),
|
||||
Configuration::get('PS_OS_OUTOFSTOCK'),
|
||||
Configuration::get('PS_OS_OUTOFSTOCK_UNPAID')
|
||||
)
|
||||
)) {
|
||||
$objCart = new Cart($objOrder->id_cart);
|
||||
if ($objCart->is_advance_payment) {
|
||||
$cartTotal = $objOrder->getOrdersTotalPaid(1);
|
||||
} else {
|
||||
$order_total = $objOrder->total_paid;
|
||||
$cartTotal = $objOrder->getOrdersTotalPaid();
|
||||
}
|
||||
|
||||
$this->smarty->assign(array(
|
||||
'total_to_pay' => Tools::displayPrice($order_total, $params['currencyObj'], false),
|
||||
'bankwireDetails' => Tools::nl2br($this->details),
|
||||
'bankwireAddress' => Tools::nl2br($this->address),
|
||||
'bankwireOwner' => $this->owner,
|
||||
'status' => 'ok',
|
||||
'id_order' => $objOrder->id
|
||||
));
|
||||
if (isset($objOrder->reference) && !empty($objOrder->reference)) {
|
||||
$this->smarty->assign('reference', $objOrder->reference);
|
||||
}
|
||||
$smartyVars['total_to_pay'] = Tools::displayPrice($cartTotal, $params['currencyObj'], false);
|
||||
$smartyVars['bankwireDetails'] = Tools::nl2br($this->details);
|
||||
$smartyVars['bankwireAddress'] = Tools::nl2br($this->address);
|
||||
$smartyVars['bankwireOwner'] = $this->owner;
|
||||
$smartyVars['status'] = 'ok';
|
||||
$smartyVars['id_order'] = $objOrder->id;
|
||||
$smartyVars['reference'] = $objOrder->reference;
|
||||
} else {
|
||||
$this->smarty->assign('status', 'failed');
|
||||
$smartyVars['status'] = 'failed';
|
||||
}
|
||||
|
||||
$this->smarty->assign($smartyVars);
|
||||
return $this->display(__FILE__, 'payment_return.tpl');
|
||||
}
|
||||
|
||||
|
||||
@@ -173,28 +173,33 @@ class Cheque extends PaymentModule
|
||||
return;
|
||||
}
|
||||
$objOrder = $params['objOrder'];
|
||||
$cart = new Cart($objOrder->id_cart);
|
||||
$state = $objOrder->getCurrentState();
|
||||
if (in_array($state, array(Configuration::get('PS_OS_CHEQUE'), Configuration::get('PS_OS_OUTOFSTOCK'), Configuration::get('PS_OS_OUTOFSTOCK_UNPAID')))) {
|
||||
if ($objOrder->is_advance_payment) {
|
||||
$order_total = $objOrder->advance_paid_amount;
|
||||
$orderState = $objOrder->getCurrentState();
|
||||
if (in_array(
|
||||
$orderState,
|
||||
array(
|
||||
Configuration::get('PS_OS_CHEQUE'),
|
||||
Configuration::get('PS_OS_OUTOFSTOCK'),
|
||||
Configuration::get('PS_OS_OUTOFSTOCK_UNPAID')
|
||||
)
|
||||
)) {
|
||||
$objCart = new Cart($objOrder->id_cart);
|
||||
if ($objCart->is_advance_payment) {
|
||||
$cartTotal = $objOrder->getOrdersTotalPaid(1);
|
||||
} else {
|
||||
$order_total = $objOrder->total_paid;
|
||||
$cartTotal = $objOrder->getOrdersTotalPaid();
|
||||
}
|
||||
|
||||
$this->smarty->assign(array(
|
||||
'total_to_pay' => Tools::displayPrice($order_total, $params['currencyObj'], false),
|
||||
'chequeName' => $this->chequeName,
|
||||
'chequeAddress' => Tools::nl2br($this->address),
|
||||
'status' => 'ok',
|
||||
'id_order' => $objOrder->id
|
||||
));
|
||||
if (isset($objOrder->reference) && !empty($objOrder->reference))
|
||||
$this->smarty->assign('reference', $objOrder->reference);
|
||||
$smartyVars['total_to_pay'] = Tools::displayPrice($cartTotal, $params['currencyObj'], false);
|
||||
$smartyVars['chequeName'] = $this->chequeName;
|
||||
$smartyVars['chequeAddress'] = Tools::nl2br($this->address);
|
||||
$smartyVars['status'] = 'ok';
|
||||
$smartyVars['id_order'] = $objOrder->id;
|
||||
$smartyVars['reference'] = $objOrder->reference;
|
||||
} else {
|
||||
$this->smarty->assign('status', 'failed');
|
||||
$smartyVars['status'] = 'failed';
|
||||
}
|
||||
|
||||
$this->smarty->assign($smartyVars);
|
||||
return $this->display(__FILE__, 'payment_return.tpl');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user