diff --git a/admin/themes/default/template/controllers/orders/_select_payment.tpl b/admin/themes/default/template/controllers/orders/_select_payment.tpl index 6c60b080c..701966abf 100644 --- a/admin/themes/default/template/controllers/orders/_select_payment.tpl +++ b/admin/themes/default/template/controllers/orders/_select_payment.tpl @@ -22,7 +22,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA *} - {if !$PS_CATALOG_MODE} {foreach from=$payment_modules item='module'} diff --git a/admin/themes/default/template/controllers/orders/form.tpl b/admin/themes/default/template/controllers/orders/form.tpl index 99b5ab612..e3413ce9b 100644 --- a/admin/themes/default/template/controllers/orders/form.tpl +++ b/admin/themes/default/template/controllers/orders/form.tpl @@ -1186,6 +1186,7 @@ $('#go_order_process').hide(); } $('#order_message').val(jsonSummary.order_message); + $('#payment_amount').siblings('.input-group-addon').html(currency_sign); resetBind(); } @@ -2081,9 +2082,9 @@ {/if}
- +
- {if !$PS_CATALOG_MODE} {foreach from=$payment_modules item='module'} @@ -2094,10 +2095,20 @@
+
+ +
+
+ {$currency->sign} + +
+ +
+
- {foreach from=$order_states item='order_state'} {/foreach} diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 3e89319f2..8063b971e 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -430,6 +430,7 @@ abstract class PaymentModuleCore extends Module if ($order_status->logable && number_format($cart_total_paid, _PS_PRICE_COMPUTE_PRECISION_) != number_format($amount_paid, _PS_PRICE_COMPUTE_PRECISION_) && $this->name != 'wsorder' + && !(isset($this->hasPartialPayment) && $this->hasPartialPayment) ) { // if customer is paying full payment amount $id_order_state = Configuration::get('PS_OS_ERROR'); @@ -478,7 +479,7 @@ abstract class PaymentModuleCore extends Module } // Register Payment only if the order status validate the order - if ($order_status->logable) { + if ($order_status->logable || (isset($this->hasPartialPayment) && $this->hasPartialPayment && $amount_paid)) { // $order is the last order loop in the foreach // The method addOrderPayment of the class Order make a create a paymentOrder // linked to the order reference and not to the order id diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 63a271ecd..743e23aa5 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -950,48 +950,65 @@ class AdminOrdersControllerCore extends AdminController ($module_name = Tools::getValue('payment_module_name')) && ($id_order_state = Tools::getValue('id_order_state')) && Validate::isModuleName($module_name)) { if ($this->tabAccess['edit'] === '1') { - if (!Configuration::get('PS_CATALOG_MODE')) { - $payment_module = Module::getInstanceByName($module_name); - } else { - $payment_module = new BoOrder(); + $paymentAmount = Tools::getValue('payment_amount'); + if ($paymentAmount && !Validate::isPrice($paymentAmount)) { // $paymentAmount = '' means no payment + $this->errors[] = Tools::displayError('Payment amount is invalid. Please enter correct amount.'); } - $cart = new Cart((int)$id_cart); - Context::getContext()->currency = new Currency((int)$cart->id_currency); - Context::getContext()->customer = new Customer((int)$cart->id_customer); - - $bad_delivery = false; - if (($bad_delivery = (bool)!Address::isCountryActiveById((int)$cart->id_address_delivery)) - || !Address::isCountryActiveById((int)$cart->id_address_invoice)) { - if ($bad_delivery) { - $this->errors[] = Tools::displayError('This booking address country is not active.'); + if (!count($this->errors)) { + if (!Configuration::get('PS_CATALOG_MODE')) { + $payment_module = Module::getInstanceByName($module_name); } else { - $this->errors[] = Tools::displayError('This invoice address country is not active.'); - } - } else { - $employee = new Employee((int)Context::getContext()->cookie->id_employee); - $payment_module->validateOrder( - (int)$cart->id, - (int)$id_order_state, - $cart->getOrderTotal(true, Cart::BOTH), - $payment_module->displayName, - $this->l('Manual order -- Employee:').' '. - substr($employee->firstname, 0, 1).'. '.$employee->lastname, - array(), - null, - false, - $cart->secure_key - ); - - if (isset($this->context->cookie->id_cart)) { - unset($this->context->cookie->id_cart); - } - if (isset($this->context->cookie->id_guest)) { - unset($this->context->cookie->id_guest); + $payment_module = new BoOrder(); } - if ($payment_module->currentOrder) { - Tools::redirectAdmin(self::$currentIndex.'&id_order='.$payment_module->currentOrder.'&vieworder'.'&token='.$this->token.'&conf=3'); + $cart = new Cart((int)$id_cart); + Context::getContext()->currency = new Currency((int)$cart->id_currency); + Context::getContext()->customer = new Customer((int)$cart->id_customer); + + $bad_delivery = false; + if (($bad_delivery = (bool)!Address::isCountryActiveById((int)$cart->id_address_delivery)) + || !Address::isCountryActiveById((int)$cart->id_address_invoice)) { + if ($bad_delivery) { + $this->errors[] = Tools::displayError('This booking address country is not active.'); + } else { + $this->errors[] = Tools::displayError('This invoice address country is not active.'); + } + } else { + $amountPaid = $cart->getOrderTotal(true, Cart::BOTH); + if (((float) $paymentAmount != 0) && Validate::isPrice($paymentAmount)) { // $paymentAmount != {'', '0', '0.00'} + $objOrderState = new OrderState($id_order_state); + if (!$objOrderState->is_logable && !$objOrderState->paid) { + $amountPaid = Tools::ps_round($paymentAmount, 6); + $payment_module->hasPartialPayment = true; + $payment_module->payment_type = OrderPayment::PAYMENT_TYPE_PAY_AT_HOTEL; + } + } + + $employee = new Employee((int)Context::getContext()->cookie->id_employee); + $payment_module->validateOrder( + (int)$cart->id, + (int)$id_order_state, + $amountPaid, + $payment_module->displayName, + $this->l('Manual order -- Employee:').' '. + substr($employee->firstname, 0, 1).'. '.$employee->lastname, + array(), + null, + false, + $cart->secure_key + ); + + if (isset($this->context->cookie->id_cart)) { + unset($this->context->cookie->id_cart); + } + if (isset($this->context->cookie->id_guest)) { + unset($this->context->cookie->id_guest); + } + + if ($payment_module->currentOrder) { + Tools::redirectAdmin(self::$currentIndex.'&id_order='.$payment_module->currentOrder.'&vieworder'.'&token='.$this->token.'&conf=3'); + } } } } else {