ValterV Posted May 28, 2021 Share Posted May 28, 2021 Unknown error na linha 422 do ficheiro /home/hg22ow4m/public_html/override/classes/Cart.php [2048] Declaration of Cart::checkQuantities() should be compatible with CartCore::checkQuantities($return_product = false) Any one knows how to fix that? Link to comment Share on other sites More sharing options...
Razi Posted May 28, 2021 Share Posted May 28, 2021 simply edit this file /public_html/override/classes/cart.php line 422 and add peram $return_product = false in checkQuantities method example: CartCore::checkQuantities($return_product = false) Thanks Link to comment Share on other sites More sharing options...
ValterV Posted May 28, 2021 Author Share Posted May 28, 2021 line 422 is the end. Only have to put checkQuantities($return_product = false) on 422 line ? <?php class Cart extends CartCore { /* * module: bvkpaymentfees * date: 2021-02-01 10:53:52 * version: 4.3.6 */ public function isVirtualCart($strict = false) { $virtual = parent::isVirtualCart($strict); if ($virtual) { if (!isset($this->feeamount)) { $fee = Module::getInstanceByName('bvkpaymentfees')->getFee(); $this->feeamount = $fee['feeamount']; $this->method = $fee['feemethod']; $this->feeamount_tax_excl = $fee['feeamount_tax_excl']; } if ($this->feeamount > 0 && $this->method == 1) { return false; } } return $virtual; } /* * module: bvkpaymentfees * date: 2021-02-01 10:53:52 * version: 4.3.6 */ public function checkDiscountValidity($discountObj, $discounts, $order_total, $products, $checkCartDiscount = false) { if ($discountObj->apd) { return false; } $newdiscounts = array(); foreach ($discounts as $discount) { if ($discount['id_discount'] != 'bvkpfd') { $newdiscounts[] = $discount; } } $discounts = $newdiscounts; return parent::checkDiscountValidity($discountObj, $discounts, $order_total, $products, $checkCartDiscount); } /* * module: bvkpaymentfees * date: 2021-02-01 10:53:52 * version: 4.3.6 */ public function getDiscounts($lite = false, $refresh = false) { $discounts = parent::getDiscounts($lite, $refresh); if (!isset($this->feeamount)) { $fee = Module::getInstanceByName('bvkpaymentfees')->getFee(); $this->feeamount = $fee['feeamount']; $this->method = $fee['feemethod']; $this->feeamount_tax_excl = $fee['feeamount_tax_excl']; } if ($this->feeamount < 0 && $this->method > 0) { $discount = array(); $discount['obj'] = new CartRule(Configuration::get("BVKPAYMENTFEES_CRULE")); $discount['obj']->id = Configuration::get("BVKPAYMENTFEES_CRULE"); $discount['obj']->value = abs($this->feeamount); $discount['obj']->value_tax_excl = abs($this->feeamount_tax_excl); $discount['obj']->value_real = abs($this->feeamount); $discount['obj']->value_real_tax_excl = abs($this->feeamount_tax_excl); $discount['id_discount'] = 'bvkpfd'; $discount['id_cart_rule'] = Configuration::get("BVKPAYMENTFEES_CRULE"); $discount['free_shipping'] = 0; $discount['gift_product'] = 0; $discount['name'] = Module::getInstanceByName('bvkpaymentfees')->getDiscountLabel(); $discount['description'] = Module::getInstanceByName('bvkpaymentfees')->getDiscountLabel(); $discount['value_real'] = abs($this->feeamount); $discount['value_real_tax_excl'] = abs($this->feeamount_tax_excl); $discounts[] = $discount; } return $discounts; } /* * module: bvkpaymentfees * date: 2021-02-01 10:53:52 * version: 4.3.6 */ public function getCartRules($filter = CartRule::FILTER_ACTION_ALL, $autoAdd = true) { if (Module::getInstanceByName('bvkpaymentfees')->checkIgnore()) { return parent::getCartRules($filter, $autoAdd); } Module::getInstanceByName('bvkpaymentfees')->setIgnore(true); $discounts = parent::getCartRules($filter, $autoAdd); Module::getInstanceByName('bvkpaymentfees')->setIgnore(false); if ($filter != CartRule::FILTER_ACTION_ALL) { return $discounts; } if (!isset($this->feeamount)) { $fee = Module::getInstanceByName('bvkpaymentfees')->getFee(); $this->feeamount = $fee['feeamount']; $this->method = $fee['feemethod']; $this->feeamount_tax_excl = $fee['feeamount_tax_excl']; } if ($this->feeamount < 0 && $this->method > 0) { $discount = array(); $discount['obj'] = new CartRule(Configuration::get("BVKPAYMENTFEES_CRULE")); $discount['obj']->id = Configuration::get("BVKPAYMENTFEES_CRULE"); $discount['obj']->value = abs($this->feeamount); $discount['obj']->value_tax_excl = abs($this->feeamount_tax_excl); $discount['obj']->value_real = abs($this->feeamount); $discount['obj']->value_real_tax_excl = abs($this->feeamount_tax_excl); $discount['id_discount'] = 'bvkpfd'; $discount['id_cart_rule'] = Configuration::get("BVKPAYMENTFEES_CRULE"); $discount['free_shipping'] = 0; $discount['gift_product'] = 0; $discount['name'] = Module::getInstanceByName('bvkpaymentfees')->getDiscountLabel(); $discount['description'] = Module::getInstanceByName('bvkpaymentfees')->getDiscountLabel(); $discount['value_real'] = abs($this->feeamount); $discount['value_real_tax_excl'] = abs($this->feeamount_tax_excl); $discounts[] = $discount; } return $discounts; } /* * module: bvkpaymentfees * date: 2021-02-01 10:53:52 * version: 4.3.6 */ public function getOrderShippingCost( $id_carrier = null, $use_tax = true, Country $default_country = null, $product_list = null ) { if ((Module::getInstanceByName('bvkpaymentfees')->checkIgnore())) { return parent::getOrderShippingCost($id_carrier, $use_tax, $default_country, $product_list); } if (!isset($this->feeamount)) { $fee = Module::getInstanceByName('bvkpaymentfees')->getFee(); $this->feeamount = $fee['feeamount']; $this->method = $fee['feemethod']; $this->feeamount_tax_excl = $fee['feeamount_tax_excl']; } Module::getInstanceByName('bvkpaymentfees')->setIgnore(true); $shipping = parent::getOrderShippingCost($id_carrier, $use_tax, $default_country, $product_list); Module::getInstanceByName('bvkpaymentfees')->setIgnore(false); if ($this->feeamount > 0 && $this->method == 1) { if ($use_tax) { $shipping += $this->feeamount; } else { $shipping += $this->feeamount_tax_excl; } } return $shipping; } /* * module: bvkpaymentfees * date: 2021-02-01 10:53:52 * version: 4.3.6 */ public function getPackageShippingCost( $id_carrier = null, $use_tax = true, Country $default_country = null, $product_list = null, $id_zone = null ) { if ((Module::getInstanceByName('bvkpaymentfees')->checkIgnore())) { return parent::getPackageShippingCost($id_carrier, $use_tax, $default_country, $product_list, $id_zone); } if (!isset($this->feeamount)) { $fee = Module::getInstanceByName('bvkpaymentfees')->getFee(); $this->feeamount = $fee['feeamount']; $this->method = $fee['feemethod']; $this->feeamount_tax_excl = $fee['feeamount_tax_excl']; } Module::getInstanceByName('bvkpaymentfees')->setIgnore(true); $shipping = parent::getPackageShippingCost($id_carrier, $use_tax, $default_country, $product_list, $id_zone); Module::getInstanceByName('bvkpaymentfees')->setIgnore(false); if ($this->feeamount > 0 && $this->method == 1) { if ($use_tax) { $shipping += $this->feeamount; } else { $shipping += $this->feeamount_tax_excl; } } return $shipping; } /* * module: bvkpaymentfees * date: 2021-02-01 10:53:52 * version: 4.3.6 */ public function getTotalShippingCost( $delivery_option = null, $use_tax = true, Country $default_country = null ) { if ((Module::getInstanceByName('bvkpaymentfees')->checkIgnore())) { return parent::getTotalShippingCost($delivery_option, $use_tax, $default_country); } if (!isset($this->feeamount)) { $fee = Module::getInstanceByName('bvkpaymentfees')->getFee(); $this->feeamount = $fee['feeamount']; $this->method = $fee['feemethod']; $this->feeamount_tax_excl = $fee['feeamount_tax_excl']; } Module::getInstanceByName('bvkpaymentfees')->setIgnore(true); $shipping = parent::getTotalShippingCost($delivery_option, $use_tax, $default_country); Module::getInstanceByName('bvkpaymentfees')->setIgnore(false); if ($this->feeamount > 0 && $this->method == 1) { if ($use_tax) { $shipping += $this->feeamount; } else { $shipping += $this->feeamount_tax_excl; } } return $shipping; } /* * module: bvkpaymentfees * date: 2021-02-01 10:53:52 * version: 4.3.6 */ public function getOrderTotal( $withTaxes = true, $type = self::BOTH, $products = null, $id_carrier = null, $use_cache = true ) { if ((Module::getInstanceByName('bvkpaymentfees')->checkIgnore())) { return parent::getOrderTotal($withTaxes, $type, $products, $id_carrier, $use_cache); } if ($type == self::BOTH) { $fee = Module::getInstanceByName('bvkpaymentfees')->getFee(); $this->feeamount = $fee['feeamount']; $this->method = $fee['feemethod']; $this->feeamount_tax_excl = $fee['feeamount_tax_excl']; if ($this->feeamount && ($this->method == 0)) { return parent::getOrderTotal($withTaxes, $type, $products, $id_carrier, $use_cache) + ($withTaxes ? $this->feeamount : $this->feeamount_tax_excl); } } return parent::getOrderTotal($withTaxes, $type, $products, $id_carrier, $use_cache); } /* * module: belvg_preorderproducts * date: 2021-04-23 14:19:45 * version: 3.1.0 */ public function checkQuantities() { require_once(_PS_MODULE_DIR_ . "belvg_preorderproducts/classes/ProductPreorder.php"); if (Configuration::get('PS_CATALOG_MODE')) { return false; } foreach ($this->getProducts() as $product) { if (!$product['active'] || ( !$product['allow_oosp'] && $product['stock_quantity'] < $product['cart_quantity'] AND ($product['cart_quantity'] > ProductPreorder::getAvailablePreorderQty($product['id_product'], $product['id_product_attribute'])) ) || !$product['available_for_order']) { return false; } } return true; } /* * module: belvg_preorderproducts * date: 2021-04-23 14:19:45 * version: 3.1.0 */ public function updateQty($quantity, $id_product, $id_product_attribute = NULL, $id_customization = false, $operator = 'up', $id_address_delivery = 0, Shop $shop = NULL, $auto_add_cart_rule = true) { require_once(_PS_MODULE_DIR_ . "belvg_preorderproducts/classes/ProductPreorder.php"); if (!$shop) { $shop = Context::getContext()->shop; } if (Context::getContext()->customer->id) { if ($id_address_delivery == 0 && (int) $this->id_address_delivery) { $id_address_delivery = $this->id_address_delivery; } elseif ($id_address_delivery == 0) { $id_address_delivery = (int) Address::getFirstCustomerAddressId((int) Context::getContext()->customer->id); } elseif (!Customer::customerHasAddress(Context::getContext()->customer->id, $id_address_delivery)) { $id_address_delivery = 0; } } $quantity = (int) $quantity; $id_product = (int) $id_product; $id_product_attribute = (int) $id_product_attribute; $product = new Product($id_product, false, Configuration::get('PS_LANG_DEFAULT'), $shop->id); if ($id_product_attribute) { $combination = new Combination((int) $id_product_attribute); if ($combination->id_product != $id_product) { return false; } } if (!empty($id_product_attribute)) { $minimal_quantity = (int) Attribute::getAttributeMinimalQty($id_product_attribute); } else { $minimal_quantity = (int) $product->minimal_quantity; } if (!Validate::isLoadedObject($product)) { die(Tools::displayError()); } if (isset(self::$_nbProducts[$this->id])) { unset(self::$_nbProducts[$this->id]); } if (isset(self::$_totalWeight[$this->id])) { unset(self::$_totalWeight[$this->id]); } if ((int) $quantity <= 0) { return $this->deleteProduct($id_product, $id_product_attribute, (int) $id_customization); } elseif (!$product->available_for_order || Configuration::get('PS_CATALOG_MODE')) { return false; } else { $result = $this->containsProduct($id_product, $id_product_attribute, (int) $id_customization, (int) $id_address_delivery); if ($result) { if ($operator == 'up') { $sql = 'SELECT stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity FROM ' . _DB_PREFIX_ . 'product p ' . Product::sqlStock('p', $id_product_attribute, TRUE, $shop) . ' WHERE p.id_product = ' . $id_product; $result2 = Db::getInstance()->getRow($sql); $product_qty = (int) $result2['quantity']; if (Pack::isPack($id_product)) { $product_qty = Pack::getQuantity($id_product, $id_product_attribute); } $new_qty = (int) $result['quantity'] + (int) $quantity; $qty = '+ ' . (int) $quantity; if (!Product::isAvailableWhenOutOfStock((int) $result2['out_of_stock']) AND ($new_qty > ProductPreorder::getAvailablePreorderQty($id_product, $id_product_attribute))) { if ($new_qty > $product_qty) { return false; } } } elseif ($operator == 'down') { $qty = '- ' . (int) $quantity; $new_qty = (int) $result['quantity'] - (int) $quantity; if ($new_qty < $minimal_quantity && $minimal_quantity > 1) { return -1; } } else { return false; } if ($new_qty <= 0) { return $this->deleteProduct((int) $id_product, (int) $id_product_attribute, (int) $id_customization); } else if ($new_qty < $minimal_quantity) { return -1; } else { Db::getInstance()->execute(' UPDATE `' . _DB_PREFIX_ . 'cart_product` SET `quantity` = `quantity` ' . $qty . ', `date_add` = NOW() WHERE `id_product` = ' . (int) $id_product . (!empty($id_product_attribute) ? ' AND `id_product_attribute` = ' . (int) $id_product_attribute : '') . ' AND `id_cart` = ' . (int) $this->id . (Configuration::get('PS_ALLOW_MULTISHIPPING') && $this->isMultiAddressDelivery() ? ' AND `id_address_delivery` = ' . (int) $id_address_delivery : '') . ' LIMIT 1' ); } } elseif ($operator == 'up') { $sql = 'SELECT stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity FROM ' . _DB_PREFIX_ . 'product p ' . Product::sqlStock('p', $id_product_attribute, true, $shop) . ' WHERE p.id_product = ' . $id_product; $result2 = Db::getInstance()->getRow($sql); if (Pack::isPack($id_product)) { $result2['quantity'] = Pack::getQuantity($id_product, $id_product_attribute); } if (!Product::isAvailableWhenOutOfStock((int) $result2['out_of_stock']) AND ($quantity > ProductPreorder::getAvailablePreorderQty($id_product, $id_product_attribute))) { if ((int) $quantity > $result2['quantity']) { return false; } } if ((int) $quantity < $minimal_quantity) { return -1; } $result_add = Db::getInstance()->insert('cart_product', array( 'id_product' => (int) $id_product, 'id_product_attribute' => (int) $id_product_attribute, 'id_cart' => (int) $this->id, 'id_address_delivery' => (int) $id_address_delivery, 'id_shop' => $shop->id, 'quantity' => (int) $quantity, 'date_add' => date('Y-m-d H:i:s') )); if (!$result_add) { return false; } } } $this->_products = $this->getProducts(true); $this->update(true); $context = Context::getContext()->cloneContext(); $context->cart = $this; if ($auto_add_cart_rule) { CartRule::autoAddToCart($context); } if ($product->customizable) { return $this->_updateCustomizationQuantity((int) $quantity, (int) $id_customization, (int) $id_product, (int) $id_product_attribute, (int) $id_address_delivery, $operator); } else { return true; } } } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now