Jump to content

Ayuda con override prestashop 1.6.1.20


Eusebio100

Recommended Posts

Hola, estoy intentando hacer unas modificaciones de la función init del archivo /controllers/front/OrderController.php y ponerlas en override, pero no lo consigo.

Si hago las modificaciones directamente en el archivo funciona perfecto, pero si lo paso a override no funciona, no coge los cambios. He visto que algunas veces aparece el override en class_index y otras no, pero en ningún caso coge los cambios.

Alguna idea de que puede ser?

Por si ayuda pongo el archivo que subo a override/controllers/front/OrderController.php

<?php

class OrderController extends OrderControllerCore
{
    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();
		$amount_cart = $this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS);
		$tax_purchase_cart = ($orderTotal - $amount_cart);
        $minimal_purchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
        if ($amount_cart < ($minimal_purchase - $tax_purchase_cart) && $this->step > 0) {
            $_GET['step'] = $this->step = 0;
            $this->errors[] = sprintf(
                Tools::displayError('El importe minimo por pedido son %1s Iva incluido. Le faltan %2s (iva incl.) en su cesta para alcanzar el minimo.'),
				Tools::displayPrice($minimal_purchase, $currency), Tools::displayPrice(($minimal_purchase - ($amount_cart+$tax_purchase_cart)), $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());
        }
    }
}

Gracias de antemano.

 

Link to comment
Share on other sites

hace 2 horas, Rolige dijo:

Hola,

Cuando cargues o elimines un override, antes de probar cambios debes eliminar el archivo: /cache/class_index.php

 

Saludos!

Hola, gracias por responder. 

Como dije antes unas veces aparece el override en el class_index y otras no, lo que quiere decir que lo he borrado cienes de veces, pero es igual, no coge los cambios.

Tengo varios overrides y nunca tuve problema, pero este no me lo coge; cualquier sugerencia será bien recibida.

 

Gracias nuevamente.

Link to comment
Share on other sites

  • 2 weeks later...

Hola de nuevo, subo esto a ver si alguien me alumbra un poco sobre el por que no puedo hacer override del archivo OrderController.php

El caso es que si aparece en el class_index pero hace caso omiso del override y no coge los cambios.

Esto tengo en el class_index:

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

Desde ya agradezco cualquier ayuda.

Link to comment
Share on other sites

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...