diff --git a/config.xml b/config.xml index 41b8013ae8..5e344a4eae 100755 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ ps_cashondelivery - + 0 diff --git a/controllers/front/validation.php b/controllers/front/validation.php index b17570d251..49c666e531 100755 --- a/controllers/front/validation.php +++ b/controllers/front/validation.php @@ -66,7 +66,7 @@ public function postProcess() (int) $this->context->cart->id, (int) Configuration::getGlobalValue(Ps_Cashondelivery::CONFIG_OS_CASH_ON_DELIVERY), (float) $this->context->cart->getOrderTotal(true, Cart::BOTH), - $this->trans('Cash on delivery', [], 'Modules.Cashondelivery.Shop'), + $this->module->displayName, null, [], (int) $this->context->currency->id, diff --git a/ps_cashondelivery.php b/ps_cashondelivery.php index a25ddb6076..d77b8c9685 100755 --- a/ps_cashondelivery.php +++ b/ps_cashondelivery.php @@ -17,14 +17,16 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -require_once __DIR__ . '/vendor/autoload.php'; - -use PrestaShop\PrestaShop\Core\Payment\PaymentOption; - if (!defined('_PS_VERSION_')) { exit; } +if (file_exists(__DIR__ . '/vendor/autoload.php')) { + require_once __DIR__ . '/vendor/autoload.php'; +} + +use PrestaShop\PrestaShop\Core\Payment\PaymentOption; + class Ps_Cashondelivery extends PaymentModule { const HOOKS = [ @@ -42,7 +44,7 @@ public function __construct() $this->name = 'ps_cashondelivery'; $this->tab = 'payments_gateways'; $this->author = 'PrestaShop'; - $this->version = '2.0.0'; + $this->version = '2.0.1'; $this->need_instance = 1; $this->ps_versions_compliancy = ['min' => '1.7.6.0', 'max' => _PS_VERSION_]; $this->controllers = ['validation']; @@ -98,13 +100,13 @@ public function hookPaymentOptions(array $params) */ public function hookDisplayOrderConfirmation(array $params) { - if (empty($params['order'])) { - return ''; - } - /** @var Order $order */ $order = (isset($params['objOrder'])) ? $params['objOrder'] : $params['order']; + if (!Validate::isLoadedObject($order) || $order->module !== $this->name) { + return ''; + } + $this->context->smarty->assign([ 'shop_name' => $this->context->shop->name, 'total' => $this->context->getCurrentLocale()->formatPrice($params['order']->getOrdersTotalPaid(), (new Currency($params['order']->id_currency))->iso_code), diff --git a/upgrade/upgrade-1.0.7.php b/upgrade/upgrade-1.0.7.php index a868ef7bce..bdbed471cc 100644 --- a/upgrade/upgrade-1.0.7.php +++ b/upgrade/upgrade-1.0.7.php @@ -5,7 +5,7 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Academic Free License 3.0 (AFL-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/licenses/AFL-3.0 @@ -13,18 +13,28 @@ * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * - * @author PrestaShop SA and Contributors + * @author PrestaShop SA * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) */ + +use PrestaShop\PrestaShop\Core\Module\WidgetInterface; + if (!defined('_PS_VERSION_')) { exit; } +/** + * @param Ps_Cashondelivery $module + * + * @return bool + */ function upgrade_module_1_0_7($module) { $module->unregisterHook('paymentReturn'); - $module->registerHook('displayPaymentReturn'); + if (method_exists($module, 'hookDisplayPaymentReturn') || $module instanceof WidgetInterface) { + $module->registerHook('displayPaymentReturn'); + } return true; }