prestashopprestashop-1.6checkoutcarrier

Prestashop one step checkout programatically change carrier


I'm dealing with an issue, I've been working in a module that does pretty much the same as a cart rule if you have certan type of products and a certain amount in your cart, the module sets a free shipping carrier for you, this can be achieved with discount codes I know that, but the requierement was specific, Do that ... without using discount codes, So, the site has enabled the one step checkout, the module does it well in the 5 step checkout, but the hook DisplayBeforePayment does not work, I know that maybe it isn't working because of ajax call, To keep it simple, What can I do to get my module working with the One step checkout? (order-opc Controller). Thanks in advance!


Solution

  • I think you need to use a different hook. Please have a look at this page. If you search for "DisplayBeforePayment", you see it's only used in /controllers/front/OrderController.php. The 5 step checkout uses this controller.

    The one step checkout uses a different controller: /controllers/front/OrderOpcController.php.

    The hook DisplayBeforePayment is not present in that controller, so that's why i think your module doesn't work on the one page checkout.