jaimesks Posted March 14, 2019 Share Posted March 14, 2019 (edited) ¿Can someone explain to me what these methods do? public function postProcess() { parent::postProcess(); if (Tools::isSubmit('submitReorder') && $id_order = (int) Tools::getValue('id_order')) { $oldCart = new Cart(Order::getCartIdStatic($id_order, $this->context->customer->id)); $duplication = $oldCart->duplicate(); if (!$duplication || !Validate::isLoadedObject($duplication['cart'])) { $this->errors[] = $this->trans('Sorry. We cannot renew your order.', array(), 'Shop.Notifications.Error'); } elseif (!$duplication['success']) { $this->errors[] = $this->trans( 'Some items are no longer available, and we are unable to renew your order.', array(), 'Shop.Notifications.Error' ); } else { $this->context->cookie->id_cart = $duplication['cart']->id; $context = $this->context; $context->cart = $duplication['cart']; CartRule::autoAddToCart($context); $this->context->cookie->write(); Tools::redirect('https://www.graficosta.com/carrito?action=show'); } } $this->bootstrap(); } AND public function hookActionCartSave() { $this->calculator->emptyCache(); if (Tools::getIsset('submitReorder') && $this->duplicate_order) { $id_order_old = Tools::getValue('id_order'); $cookie = new Cookie('reorder'); $cookie->setExpire(time() + 20 * 60); $cookie->id_order_old = $id_order_old; $cookie->write(); $this->duplicate_order = false; } if (! Validate::isLoadedObject($this->context->cart)) { return; } $id_cart = (int)$this->context->cart->id; $id_special = $this->handler->getSpecialProduct(); if ($id_special) { $id_lang = $this->context->language->id; $id_shop = $this->context->shop->id; $product_special = new Product($id_special, false, $id_lang, $id_shop, $this->context); $quantity = $this->context->cart->containsProduct($id_special); $quantity = isset($quantity['quantity']) ? (int)$quantity['quantity'] : 0; if ($product_special->active && DynamicInput::cartHasCustomization($id_cart)) { if (!$quantity) { $this->context->cart->updateQty(1, $id_special); } elseif ($quantity > 1) { $this->context->cart->updateQty($quantity - 1, $id_special, null, false, 'down'); } } elseif ($quantity) { $this->context->cart->deleteProduct($id_special); } } $where = ''; $id_guest = (int)$this->context->cookie->id_guest; $id_customer = (int)$this->context->cookie->id_customer; if ($id_customer && $id_guest) { $where = 'AND (id_customer = '.(int)$id_customer.' OR id_guest = '.(int)$id_guest.')'; } elseif ($id_customer) { $where = 'AND id_customer = '.(int)$id_customer; } elseif ($id_guest) { $where = 'AND id_guest = '.(int)$id_guest; } if (! empty($where)) { $sql = 'UPDATE `'._DB_PREFIX_.$this->name.'_input` SET `id_cart` = '.(int)$id_cart.' WHERE `id_cart` = 0 '.pSQL($where); Db::getInstance()->execute($sql); } } OrderController.php dynamicproduct.php Edited March 14, 2019 by jaimesks (see edit history) 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