Zen Cart Logo
Forums / All Other Contributions/Addons / zx_pos plugin: PHP Fatal error: Uncaught Error: Call to protected method

zx_pos plugin: PHP Fatal error: Uncaught Error: Call to protected method

Views: 617

Results 1 to 7 of 7
21 Jan 2025, 3:03 AM
#1
jimmie avatar

jimmie

Totally Zenned

Join Date:
Jan 2013
Location:
New Port Richey, Florida
Posts:
970
Plugin Contributions:
0

zx_pos plugin: PHP Fatal error: Uncaught Error: Call to protected method

VERSION 210 PHP 8.3
getting this error, how do i fix this Please?

[21-Jan-2025 03:01:21 UTC] Request URI: /ajax_process.php, IP address: 35.139.236.145
--> PHP Fatal error: Uncaught Error: Call to protected method Zencart\LanguageLoader\ArraysLanguageLoader::loadDefinesFromArrayFile() from scope Zencart\LanguageLoader\LanguageLoader in /includes/classes/ResourceLoaders/LanguageLoader.php:47
Stack trace:
#0 /ajax_process.php(927): Zencart\LanguageLoader\LanguageLoader->loadDefinesFromFile()
#1 {main}
thrown in /includes/classes/ResourceLoaders/LanguageLoader.php on line 47.

[21-Jan-2025 03:01:21 UTC] Request URI: /ajax_process.php, IP address: 35.139.236.145
--> PHP Fatal error: Uncaught Error: Call to protected method Zencart\LanguageLoader\ArraysLanguageLoader::loadDefinesFromArrayFile() from scope Zencart\LanguageLoader\LanguageLoader in /includes/classes/ResourceLoaders/LanguageLoader.php:47
Stack trace:
#0 /ajax_process.php(927): Zencart\LanguageLoader\LanguageLoader->loadDefinesFromFile()
#1 {main}
thrown in /includes/classes/ResourceLoaders/LanguageLoader.php on line 47.

here is lines from file

case 'customer_details':
                global $languageLoader;
 line 927=>  $languageLoader->loadDefinesFromFile('', $_SESSION['language'], 'account.php');
                $current_page = 'account';
                require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
                ob_start();
                require_once($template->get_template_dir('/tpl_customer_details.php', DIR_WS_TEMPLATE, $current_page_base, 'templates/zxpos') . '/tpl_customer_details.php');
                $content = ob_get_contents();
                ob_end_clean();
                $result['result_content'] = array('modalBody' => $content,
                    'modalTitle' => TEXT_MODAL_CUSTOMER_DETAILS);
                $result['result_success'] = true;
                break;
21 Jan 2025, 3:36 AM
#2
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: zx_pos plugin: PHP Fatal error: Uncaught Error: Call to protected method

Is this in regards to a plugin, if so which one?

21 Jan 2025, 4:09 AM
#3
jimmie avatar

jimmie

Totally Zenned

Join Date:
Jan 2013
Location:
New Port Richey, Florida
Posts:
970
Plugin Contributions:
0

Re: zx_pos plugin: PHP Fatal error: Uncaught Error: Call to protected method

zx_pos, he said he will fix it but i guess he busy

21 Jan 2025, 6:41 PM
#4
balihr avatar

balihr

Totally Zenned

Join Date:
Oct 2008
Location:
Croatia
Posts:
1,794
Plugin Contributions:
22

Re: zx_pos plugin: PHP Fatal error: Uncaught Error: Call to protected method

Yeah, sorry about that. As mentioned earlier, the plugin is currently compatible with up to 1.5.8. Updating it to work with 2.1.0 is on top of my priorities list, but my schedule has unexpectedly turned into a nightmare. I should be free after the first week of Feb and will be updating it first thing. Until then, I'm afraid I can't do much.

22 Jan 2025, 12:59 AM
#5
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,962
Plugin Contributions:
8

Re: zx_pos plugin: PHP Fatal error: Uncaught Error: Call to protected method

balihr:

Yeah, sorry about that. As mentioned earlier, the plugin is currently compatible with up to 1.5.8. Updating it to work with 2.1.0 is on top of my priorities list, but my schedule has unexpectedly turned into a nightmare. I should be free after the first week of Feb and will be updating it first thing. Until then, I'm afraid I can't do much.

wow, this is your plugin? who knew....

only because i truly like @balihr, i can provide some direction to the OP question.

please note, that while this may solve your original error; a new error may/will pop up. (note the use of a linux not windows slash! :smile:)

the situation is you want to load a language file, when ZC has not loaded it. this is how i solved this issue:

create a file; call it something like:

includes/functions/extra_functions/my_functions.php

in that location.

then within that file, put in the following code:

    function loadExtraLanguages(string $filename, string $middleDir = ''): void
    {
        global $template_dir, $languageLoader;

        if (empty($middleDir)) {
            $middleDir = '/' . $template_dir;
        }

        $new_langfile = DIR_FS_CATALOG . DIR_WS_LANGUAGES . $_SESSION['language'] . $middleDir . '/' . 'lang.' . $filename;
        if (file_exists($new_langfile)) {
            $languageLoader->loadExtraLanguageFiles(DIR_FS_CATALOG . DIR_WS_LANGUAGES, $_SESSION['language'], $filename, $middleDir);
        } else {
            $languageLoader->loadExtraLanguageFiles(DIR_FS_CATALOG . DIR_WS_LANGUAGES, $_SESSION['language'], $filename);
        }
    }

now, once that is done, on line 97 change accordingly:

//from:
$languageLoader->loadDefinesFromFile('', $_SESSION['language'], 'account.php');
//to:
loadExtraLanguages('account.php');

the function will load either the new style language file, ie lang.account.php or the old style, depending on what exists for the specific file.

please let us know if that works for you.

you may run into other errors, but this is how i accomplished loading a language file when needed in zc v158 and onwards...

you are welcome.

best.

22 Jan 2025, 6:57 PM
#6
balihr avatar

balihr

Totally Zenned

Join Date:
Oct 2008
Location:
Croatia
Posts:
1,794
Plugin Contributions:
22

Re: zx_pos plugin: PHP Fatal error: Uncaught Error: Call to protected method

carlwhat:

wow, this is your plugin? who knew....

only because i truly like @balihr, i can provide some direction to the OP question.

awwwwwww :blush::hug:

Thanks bud, this might even show up in the new release, although the plan is to drop support for older ZC versions... But there's A LOT of work to be done with it and refactor it all, will see what my options are.

22 Jan 2025, 9:33 PM
#7
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,962
Plugin Contributions:
8

Re: zx_pos plugin: PHP Fatal error: Uncaught Error: Call to protected method

balihr:

awwwwwww :blush::hug:

Thanks bud, this might even show up in the new release, although the plan is to drop support for older ZC versions... But there's A LOT of work to be done with it and refactor it all, will see what my options are.

this has nothing to do with older versions. in fact, i believe this function will only operate in v1.5.8 or greater environment. i have not tested it for use in v1.5.8; but definitely works in v2.x.x environments.

and again, it's use is to load a necessary language file that was not loaded as part of the normal ZC operation for the specific script you are running.

in the OP's situation, the script he is running is ajax_process.php. and he needs the language file for account.php. this function will load the relevant language file for account.php; and it will load either the new style (if it exists) or the old style if it does not.

best.

ps feel free to use it in your new release, just make sure i get some credit! https://mxworks.cc