Jump to content

orders override doesnt seem working


karxix

Recommended Posts

Hello

I added in /public_html/override/controllers/front  the file OrderController.php

with the below code to be able to redirect user to cart on re-order (instead of checkout page),
but it does not seem to be working, it only works when I edit the core file (I tried clearing cache from the var folder and from backoffice)
What could be the issue?

<?php
 

// I tried  "class OrderController" as well
class OrderControllerOverride extends OrderControllerCore
{
    /*
    * roy: to redirect to cart on reorder
    */
    
    
    public function postProcess()
    {
        die("A");
        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('cart?action=show'); // redirect to cart instead of order page
            }
        }
        
        $this->bootstrap();
    }
 
}

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