Updated: Payment_type update for Free order and back-office orders

This commit is contained in:
Rohit Jain
2025-02-19 15:21:04 +05:30
committed by GitHub
4 changed files with 45 additions and 20 deletions

View File

@@ -27,5 +27,7 @@ class BoOrder extends PaymentModule
{
$this->displayName = $this->l('Back office order');
$this->validateOrderAmount = false;
// Default payment type for backoffice order should be PAY_AT_HOTEL
$this->payment_type = OrderPayment::PAYMENT_TYPE_PAY_AT_HOTEL;
}
}

35
classes/FreeOrder.php Normal file
View File

@@ -0,0 +1,35 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3-0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*/
class FreeOrder extends PaymentModule
{
public $active = 1;
public $name = 'free_order';
public function __construct()
{
// Default payment type for Free order should be online
$this->displayName = $this->l('Free order');
$this->payment_type = OrderPayment::PAYMENT_TYPE_ONLINE;
}
}

View File

@@ -437,6 +437,7 @@ class AdminOrdersControllerCore extends AdminController
'langs' => Language::getLanguages(true, Context::getContext()->shop->id),
'payment_modules' => $payment_modules,
'payment_types' => $paymentTypes,
'PAYMENT_TYPE_PAY_AT_HOTEL' => OrderPayment::PAYMENT_TYPE_PAY_AT_HOTEL,
'currency' => new Currency((int)$cart->id_currency),
'max_child_in_room' => Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM'),
'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'),
@@ -1750,18 +1751,15 @@ class AdminOrdersControllerCore extends AdminController
// Set transaction ID
$extraVars = $paymentTransactionId ? array('transaction_id' => $paymentTransactionId) : array();
} else {
$objPaymentModule = new FreeOrder();
// Set order state
if ($objCart->is_advance_payment) {
if ($advancePaymentAmount <= $orderTotal) {
$idOrderState = Configuration::get('PS_OS_PARTIAL_PAYMENT_ACCEPTED');
} else {
$objPaymentModule->name = 'free_order';
$objPaymentModule->displayName = $this->l('Free order');
$idOrderState = Configuration::get('PS_OS_PAYMENT_ACCEPTED');
}
} else {
$objPaymentModule->name = 'free_order';
$objPaymentModule->displayName = $this->l('Free order');
$idOrderState = Configuration::get('PS_OS_PAYMENT_ACCEPTED');
}
@@ -6063,16 +6061,16 @@ class AdminOrdersControllerCore extends AdminController
protected function getPaymentsTypes()
{
return array(
OrderPayment::PAYMENT_TYPE_ONLINE => array(
'key' => 'PAYMENT_TYPE_ONLINE',
'value' => OrderPayment::PAYMENT_TYPE_ONLINE,
'name' => $this->l('Online')
),
OrderPayment::PAYMENT_TYPE_PAY_AT_HOTEL => array(
'key' => 'PAYMENT_TYPE_PAY_AT_HOTEL',
'value' => OrderPayment::PAYMENT_TYPE_PAY_AT_HOTEL,
'name' => $this->l('Pay at hotel')
),
OrderPayment::PAYMENT_TYPE_ONLINE => array(
'key' => 'PAYMENT_TYPE_ONLINE',
'value' => OrderPayment::PAYMENT_TYPE_ONLINE,
'name' => $this->l('Online')
),
OrderPayment::PAYMENT_TYPE_REMOTE_PAYMENT => array(
'key' => 'PAYMENT_TYPE_REMOTE_PAYMENT',
'value' => OrderPayment::PAYMENT_TYPE_REMOTE_PAYMENT,

View File

@@ -24,16 +24,6 @@
* International Registered Trademark & Property of PrestaShop SA
*/
/**
* Class FreeOrder to use PaymentModule (abstract class, cannot be instancied)
*/
class FreeOrder extends PaymentModule
{
public $active = 1;
public $name = 'free_order';
public $displayName = 'free_order';
}
class ParentOrderControllerCore extends FrontController
{
public $ssl = true;
@@ -187,7 +177,7 @@ class ParentOrderControllerCore extends FrontController
$orderStatus = Configuration::get('PS_OS_PAYMENT_ACCEPTED');
}
$order->validateOrder($this->context->cart->id, $orderStatus, 0, Tools::displayError('Free order', false), null, array(), null, false, $this->context->cart->secure_key);
$order->validateOrder($this->context->cart->id, $orderStatus, 0, $order->displayName, null, array(), null, false, $this->context->cart->secure_key);
return (int)Order::getOrderByCartId($this->context->cart->id);
}
return false;