I have a installed module from prestashop module market called:
Promotions and discounts - (3x2, reductions, campaigns)
That have mod files in overrides folder:
PaymentModule.php
<?php abstract class PaymentModule extends PaymentModuleCore { /* * module: quantitydiscountpro * date: 2022-02-25 15:40:45 * version: 2.1.37 */ public function validateOrder($id_cart, $id_order_state, $amount_paid, $payment_method = 'Unknown', $message = null, $extra_vars = array(), $currency_special = null, $dont_touch_amount = false, $secure_key = false, Shop $shop = null) { if (Module::isEnabled('quantitydiscountpro')) { include_once(_PS_MODULE_DIR_.'quantitydiscountpro/quantitydiscountpro.php'); $qdpro = new QuantityDiscountRule(); $qdpro->createAndRemoveRules(); } return parent::validateOrder($id_cart, $id_order_state, $amount_paid, $payment_method, $message, $extra_vars, $currency_special, $dont_touch_amount, $secure_key, $shop); } }
CartController.php
<?php class CartController extends CartControllerCore { /* * module: quantitydiscountpro * date: 2022-02-25 15:40:43 * version: 2.1.37 */ protected function updateCart() { if (Module::isEnabled('quantitydiscountpro')) { include_once(_PS_MODULE_DIR_.'quantitydiscountpro/quantitydiscountpro.php'); if ($this->context->cookie->exists() && !$this->errors && !($this->context->customer->isLogged() && !$this->isTokenValid())) { if (Tools::getIsset('add') || Tools::getIsset('update')) { $this->processChangeProductInCart(); } elseif (Tools::getIsset('delete')) { $this->processDeleteProductInCart(); } elseif (CartRule::isFeatureActive()) { if (Tools::getIsset('addDiscount') || Tools::getIsset('searchcoupon')) { if (!($code = trim((Tools::getValue('discount_name') ? Tools::getValue('discount_name') : Tools::getValue('coupon'))))) { $this->errors[] = $this->trans('You must enter a voucher code.', array(), 'Shop.Notifications.Error'); } elseif (!Validate::isCleanHtml($code)) { $this->errors[] = $this->trans('The voucher code is invalid.', array(), 'Shop.Notifications.Error'); } else { $quantityDiscount = new QuantityDiscountRule(); if (($quantityDiscount = new quantityDiscountRule(QuantityDiscountRule::getQuantityDiscountRuleByCode($code))) && Validate::isLoadedObject($quantityDiscount)) { if ($quantityDiscount->createAndRemoveRules($code) !== true) { $this->errors[] = $this->trans('The voucher code is invalid.', array(), 'Shop.Notifications.Error'); } } elseif (($cartRule = new CartRule(CartRule::getIdByCode($code))) && Validate::isLoadedObject($cartRule)) { if ($quantityDiscount->cartRuleGeneratedByAQuantityDiscountRuleCode($code)) { $this->errors[] = $this->trans('The voucher code is invalid.', array(), 'Shop.Notifications.Error'); } elseif ($error = $cartRule->checkValidity($this->context, false, true)) { $this->errors[] = $error; } else { $this->context->cart->addCartRule($cartRule->id); } } else { $this->errors[] = $this->trans('This voucher does not exist.', array(), 'Shop.Notifications.Error'); } } } elseif (($id_cart_rule = (int)Tools::getValue('deleteDiscount')) && Validate::isUnsignedId($id_cart_rule)) { if (!QuantityDiscountRule::removeQuantityDiscountCartRule($id_cart_rule, (int)$this->context->cart->id)) { $this->context->cart->removeCartRule($id_cart_rule); } CartRule::autoAddToCart($this->context); } } } elseif (!$this->isTokenValid() && Tools::getValue('action') !== 'show' && !Tools::getValue('ajax')) { Tools::redirect('index.php'); } } else { parent::updateCart(); } } }
Module Product Bundle Pack|Add multiple products into the cart
have override file CartController.php
<?php /** * 2007-2022 PrestaShop * * NOTICE OF LICENSE * * This source file is subject to the Academic Free License (AFL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/afl-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 [email protected] so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. * * @author 2007-2022 Zh-Soft * @copyright Zh-Soft * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * */ class CartController extends CartControllerCore { protected function updateCart() { // Update the cart ONLY if $this->cookies are available, in order to avoid ghost carts created by bots if ($this->context->cookie->exists() && !$this->errors && !($this->context->customer->isLogged() && !$this->isTokenValid()) ) { if (Tools::getIsset('add') || Tools::getIsset('update')) { if (Tools::getIsset('zhproductpackgroup')) { $zh_product_pack_group = Tools::getValue('zhproductpackgroup'); foreach ($zh_product_pack_group as $id_product => $group) { $this->qty = abs( Tools::getValue('zhproductitemqty')[$id_product] * Tools::getValue('qty') ); $this->id_product = $_POST['id_product'] = $_GET['id_product'] = $id_product; $this->id_product_attribute = 0; if (!isset($group[0])) { $_POST['group'] = $_GET['group'] = $group; } else { $_POST['group'] = $_GET['group'] = null; } $this->processChangeProductInCart(); } return true; } } } parent::updateCart(); } }