Jump to content

[Solved]OrderController not work in override, prestashop 1.6.1.20


Eusebio100

Recommended Posts

Hi, I have a problem with
OrderController.php in folder override.
If modifications are made in  controller/front/OrderController.php, everything is ok. If modifications are made in folder override/controller/front/OrderController.php, it does not work.

In class_index I have this:

'OrderController' => 
  array (
    'path' => 'override/controllers/front/OrderController.php',
    'type' => 'class',
    'override' => false,
  ),

I want to override and I appreciate any help.

Thank.

Edited by Eusebio100 (see edit history)
Link to comment
Share on other sites

21 hours ago, Eusebio100 said:

Hi, I have a problem with
OrderController.php in folder override.
If modifications are made in  controller/front/OrderController.php, everything is ok. If modifications are made in folder override/controller/front/OrderController.php, it does not work.

In class_index I have this:


'OrderController' => 
  array (
    'path' => 'override/controllers/front/OrderController.php',
    'type' => 'class',
    'override' => false,
  ),

I want to override and I appreciate any help.

Thank.

 

class_index  file is just the cache file & yes, you need to clear the cache from the backend for working of override (Otherwise override changes will not be reflected)

Apart from that, Kindly confirm the name of the class & extend class which you are using while overriding the controller.

 

 

 

Link to comment
Share on other sites

hace 1 hora, Knowband Plugins dijo:

 

class_index  file is just the cache file & yes, you need to clear the cache from the backend for working of override (Otherwise override changes will not be reflected)

Apart from that, Kindly confirm the name of the class & extend class which you are using while overriding the controller.

 

 

 

This is the override file:

<?php
class OrderController extends OrderControllerCore
{
    /**
     * Initialize order controller
     * @see FrontController::init()
     */
    public function init()
    {
        global $orderTotal;

        parent::init();

        $this->step = (int)Tools::getValue('step');
        if (!$this->nbProducts) {
            $this->step = -1;
        }

        $product = $this->context->cart->checkQuantities(true);

        if ((int)$id_product = $this->context->cart->checkProductsAccess()) {
            $this->step = 0;
            $this->errors[] = sprintf(Tools::displayError('An item in your cart is no longer available (%1s). You cannot proceed with your order.'), Product::getProductName((int)$id_product));
        }

        // If some products have disappear
        if (is_array($product)) {
            $this->step = 0;
            $this->errors[] = sprintf(Tools::displayError('An item (%1s) in your cart is no longer available in this quantity. You cannot proceed with your order until the quantity is adjusted.'), $product['name']);
        }

        // Check minimal amount
        $currency = Currency::getCurrency((int)$this->context->cart->id_currency);        
		$orderTotal = $this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS);
        $minimal_purchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
        if ($orderTotal < ($minimal_purchase-1) && $this->step > 0) {
            $_GET['step'] = $this->step = 1;
            $this->errors[] = sprintf(
                Tools::displayError('El importe minimo por pedido son %1s (envío no incluido). Le faltan %2s en su cesta para alcanzar el minimo.'),
				Tools::displayPrice($minimal_purchase, $currency), Tools::displayPrice(($minimal_purchase - $orderTotal), $currency)
            );
        }
        if (!$this->context->customer->isLogged(true) && in_array($this->step, array(1, 2, 3))) {
            $params = array();
            if ($this->step) {
                $params['step'] = (int)$this->step;
            }
            if ($multi = (int)Tools::getValue('multi-shipping')) {
                $params['multi-shipping'] = $multi;
            }

            $back_url = $this->context->link->getPageLink('order', true, (int)$this->context->language->id, $params);

            $params = array('back' => $back_url);
            if ($multi) {
                $params['multi-shipping'] = $multi;
            }
            if ($guest = (int)Configuration::get('PS_GUEST_CHECKOUT_ENABLED')) {
                $params['display_guest_checkout'] = $guest;
            }

            Tools::redirect($this->context->link->getPageLink('authentication', true, (int)$this->context->language->id, $params));
        }

        if (Tools::getValue('multi-shipping') == 1) {
            $this->context->smarty->assign('multi_shipping', true);
        } else {
            $this->context->smarty->assign('multi_shipping', false);
        }

        if ($this->context->customer->id) {
            $this->context->smarty->assign('address_list', $this->context->customer->getAddresses($this->context->language->id));
        } else {
            $this->context->smarty->assign('address_list', array());
        }
    }
}

Delete class_index and clear backend cache, I did both, but it still does not work. The same function is modified in OrderOpcController and override works ok.

Link to comment
Share on other sites

  • 2 months later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...