Gift Voucher - Checkout Ends with Error: "Call to undefined method TablePhocacartCoupon::getErrorMsg()". Stack trace: #0

Phoca Cart - complex e-commerce extension
tschumla
Phoca Newbie
Phoca Newbie
Posts: 3
Joined: 09 Jan 2024, 08:24

Gift Voucher - Checkout Ends with Error: "Call to undefined method TablePhocacartCoupon::getErrorMsg()". Stack trace: #0

Post by tschumla »

Hi, my name is Michael from Germany.

I tried since a couple of days, to get the "Gift-Voucher" buying running.

I watched your Video for Setting Up a Product as a Gift-Voucher.

Everything works (Selecting the Voucher Amount, and put the Voucher in the Basket).

But if i try to checkout the Voucher i get an Error Message:

Call to undefined method TablePhocacartCoupon::getErrorMsg()

In the /administrator/logs/everything.php i found this Text:

2024-01-09T04:49:47+00:00 CRITICAL 84.149.132.26 error Uncaught Throwable of type Error thrown with message "Call to undefined method TablePhocacartCoupon::getErrorMsg()". Stack trace: #0 [ROOT]/administrator/components/com_phocacart/libraries/phocacart/order/order.php(672): PhocacartOrder->saveOrderGiftCoupons()
#1 [ROOT]/components/com_phocacart/controllers/checkout.php(943): PhocacartOrder->saveOrderMain()
#2 [ROOT]/libraries/src/MVC/Controller/BaseController.php(693): PhocaCartControllerCheckout->order()
#3 [ROOT]/components/com_phocacart/phocacart.php(18): Joomla\CMS\MVC\Controller\BaseController->execute()
#4 [ROOT]/libraries/src/Dispatcher/LegacyComponentDispatcher.php(71): require_once('...')
#5 [ROOT]/libraries/src/Dispatcher/LegacyComponentDispatcher.php(73): Joomla\CMS\Dispatcher\LegacyComponentDispatcher::Joomla\CMS\Dispatcher\{closure}()
#6 [ROOT]/libraries/src/Component/ComponentHelper.php(361): Joomla\CMS\Dispatcher\LegacyComponentDispatcher->dispatch()
#7 [ROOT]/libraries/src/Application/SiteApplication.php(208): Joomla\CMS\Component\ComponentHelper::renderComponent()
#8 [ROOT]/libraries/src/Application/SiteApplication.php(249): Joomla\CMS\Application\SiteApplication->dispatch()
#9 [ROOT]/libraries/src/Application/CMSApplication.php(293): Joomla\CMS\Application\SiteApplication->doExecute()
#10 [ROOT]/includes/app.php(61): Joomla\CMS\Application\CMSApplication->execute()
#11 [ROOT]/index.php(32): require_once('...')
#12 {main}

My Configuration is:

Datenbanktyp mysql
Datenbankversion 8.0.35-0ubuntu0.22.04.1
Datenbankzeichensatz utf8mb4_general_ci
Datenbankverbindungszeichensatz utf8mb4_0900_ai_ci
Datenbankverbindungsverschlüsselung Keine
Datenbankserver unterstützt Verbindungsverschlüsselung Ja
PHP-Version 8.2.14
Webserver Apache/2.4.52 (Ubuntu)
PHP-Interface für den Webserver apache2handler
Joomla-Version Joomla! 4.4.1 Stable [ Pamoja ] 28-November-2023 16:00 GMT

Where is the Error?

Should i reinstall the complete Joomla Site?

Please Help me...
tschumla
Phoca Newbie
Phoca Newbie
Posts: 3
Joined: 09 Jan 2024, 08:24

Solved: Gift Voucher - Checkout Ends with Error: "Call to undefined method TablePhocacartCoupon::getErrorMsg()". Stack t

Post by tschumla »

I have found the Error by debugging the Code:

the field valid_from in the table: #_phocacart_coupons must be pre-filled!!!

This code starts about line 2136 ( I have edited the file, so, it is not the exact line number now) in the File:

[your-domain]/administrator/components/com_phocacart/libraries/order/order.php

about line 2136 with fixed code:

Code: Select all

// Fill the field valid_from with the actual date
// because this field has no: allow null
// and no default value

$d['valid_from'] = date('Y-m-d H:i:s'); 
But there is a second Error, if this field is not prefilled.

The Exception (if the field is empty) calls ->getErrorMsg() (I think, this is deprecated in php 8.2)

Kind Regards

Michael
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Gift Voucher - Checkout Ends with Error: "Call to undefined method TablePhocacartCoupon::getErrorMsg()". Stack trace

Post by Jan »

Hi, which version of Phoca Cart do you run?

Jan
If you find Phoca extensions useful, please support the project
tschumla
Phoca Newbie
Phoca Newbie
Posts: 3
Joined: 09 Jan 2024, 08:24

Re: Gift Voucher - Checkout Ends with Error: "Call to undefined method TablePhocacartCoupon::getErrorMsg()". Stack trace

Post by tschumla »

Hi, Jan i use:

Version
4.0.10

Michael
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Gift Voucher - Checkout Ends with Error: "Call to undefined method TablePhocacartCoupon::getErrorMsg()". Stack trace

Post by Jan »

Hi, thank you for the info, I will fix it in next version. BTW if you are on test page, you can test the version 5 Beta (it should even work on Joomla 4)

If you are able, just change the: getErrorMsg to: getError. This will be even fixed in next version.

BTW instead of:

$d['valid_from'] = date('Y-m-d H:i:s');
try to use:

$d['valid_from'] = gmdate('Y-m-d H:i:s');

Thank you, Jan
If you find Phoca extensions useful, please support the project
klimajan
Phoca Member
Phoca Member
Posts: 11
Joined: 12 Dec 2023, 16:09

Re: Gift Voucher - Checkout Ends with Error: "Call to undefined method TablePhocacartCoupon::getErrorMsg()". Stack trace

Post by klimajan »

Hey, I would like to continue this conversation as the bug is still present. I am on 4.0.11 and in this file order.php - some parts still use getErrorMsg -> I replaced them with: getError and it works but there is another issue - when you complete the checkout - you get an error message:

Field 'valid_from' doesn't have a default value

But there is no more valid_from anywhere in the file (or other files). How to proceed here?
Post Reply