cristian71 Posted January 25, 2022 Share Posted January 25, 2022 Hi, when I pay an order with Klarna module I obtain always an exception on line 424 on the hookActionOrderHistoryAddAfter() in klarnapaymentsofficial.php. I use Prestashop 1.7.8.2 on php 7.4. In debug I see that on the hook hookActionOrderHistoryAddAfter() is fired too early, the following variables are nulls because the db table klarnapayments_orders are not updated yet: $sql = "SELECT `id_order_klarna`, `capture_id`, `refund_id` FROM " . _DB_PREFIX_ . "klarnapayments_orders WHERE id_order_presta = " . (int) $id_order; $klarnaOrder = Db::getInstance()->getRow($sql); $captureId = $klarnaOrder['capture_id']; //<<<----- EXCEPTION BECAUSE $klarnaOrder IS FALSE $refundId = $klarnaOrder['refund_id']; $id_order_klarna = $klarnaOrder['id_order_klarna']; The problem is that the klarna table is updated after module->ValidateOrder() is executed. But inside module->ValidateOrder() the hookActionOrderHistoryAddAfter() is fired (in the addwithemail()). How can I solve this problem? Is it a configuration problem? Thanks in advance Cristian Link to comment Share on other sites More sharing options...
idnovate.com Posted January 26, 2022 Share Posted January 26, 2022 Are you using the last module version? Have you contacted Klarna's support? Link to comment Share on other sites More sharing options...
cristian71 Posted February 1, 2022 Author Share Posted February 1, 2022 I downloaded the last version of klarna module. To solve the exception I had to add the following code on the hookActionOrderHistoryAddAfter() function in klarnapaymentsofficial.php: public function hookActionOrderHistoryAddAfter($params) { $orderHistory = $params['order_history']; $new_id_order_state = (int) $orderHistory->id_order_state; $id_order = $orderHistory->id_order; if ($id_order < 1) { return; } if (Validate::isLoadedObject($orderHistory) && (int) $new_id_order_state !== (int) Configuration::get('KP_CAPTURE_ERROR')) { $sql = "SELECT `id_order_klarna`, `capture_id`, `refund_id` FROM " . _DB_PREFIX_ . "klarnapayments_orders WHERE id_order_presta = " . (int) $id_order; $klarnaOrder = Db::getInstance()->getRow($sql); //------------------- // START FIX if (empty($klarnaOrder)){ return; } // END FIX //------------------- $captureId = $klarnaOrder['capture_id']; $refundId = $klarnaOrder['refund_id']; $id_order_klarna = $klarnaOrder['id_order_klarna']; ...... 1 Link to comment Share on other sites More sharing options...
idnovate.com Posted February 4, 2022 Share Posted February 4, 2022 But I suppose that $klarnaOrder should not be empty, so probably there's a previous error. I'd contact the module developers anyway. 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