4 Attachment(s)
Error when installing the shipping surcharge module
I've followed the instructions for unzipping and uploading the files for the shipping surcharge module and it shows up in the "Order Totals Modules" list.
Unfortunately when I click on it so the right hand side bar with the “Install” button should show up all I get is the partial list of the "Order Totals Modules" that shows above the shipping surcharge module. I see nothing of the list that should be below and no right hand side bar were the ”Install” button should be.
Image A
Attachment 19918
Image B
Attachment 19919
Here is the debug log file that I get with it. (I've replaced admin folder name and IP address with *)
[06-Mar-2022 19:35:54 UTC] PHP Fatal error: Uncaught Error: Call to a member function Execute() on null in /includes/modules/order_total/ot_shippingsurcharge.php:115
Stack trace:
#0 /*********/modules.php(218): ot_shippingsurcharge->keys()
#1 /*********/index.php(11): require('/nfs/home4/home...')
#2 {main}
thrown in /includes/modules/order_total/ot_shippingsurcharge.php on line 115
[06-Mar-2022 19:35:54 UTC] Request URI: /*********/index.php?cmd=modules&set=ordertotal&module=ot_shippingsurcharge, IP address: ***.**.**.**
--> PHP Fatal error: Uncaught Error: Call to a member function Execute() on null in /includes/modules/order_total/ot_shippingsurcharge.php:115
Stack trace:
#0 /*********/modules.php(218): ot_shippingsurcharge->keys()
#1 /*********/index.php(11): require('/nfs/home4/home...')
#2 {main}
thrown in /includes/modules/order_total/ot_shippingsurcharge.php on line 115.
Thanks for any help that anyone can provide. I'm just a beginner at this coding stuff.:( :ohmy: :shocking:
Re: Error when installing the shipping surcharge module
Is there anybody out there?
Re: Error when installing the shipping surcharge module
Able to provide the code that is at line 115 and before to a point where you see something like:
function
public function
protected function
static function
Or any thing like the above?
The error message suggests that a variable or class method is being used that hasn't been set or shared in the current code space.
Should be an easy fix. Also may help to post the location where this code is available. Suggest including the version number installed to your system and php version.
Re: Error when installing the shipping surcharge module
I forgot to mention. Good job of working this far to try to solve the problem. You identified a partial blank screen and checked your logs for what might be causing the issue. Then you posted the logs for interpretation.
Ideally the associated software would have a forum thread in which to post this issue. Can't tell yet because of not knowing from where it was downloaded.
Re: Error when installing the shipping surcharge module
Quote:
Originally Posted by
Semi-Crazy
I've followed the instructions for unzipping and uploading the files for the shipping surcharge module and it shows up in the "Order Totals Modules" list.
Unfortunately when I click on it so the right hand side bar with the “Install” button should show up all I get is the partial list of the "Order Totals Modules" that shows above the shipping surcharge module. I see nothing of the list that should be below and no right hand side bar were the ”Install” button should be.
Image A
Attachment 19918
Image B
Attachment 19919
Here is the debug log file that I get with it. (I've replaced admin folder name and IP address with *)
[06-Mar-2022 19:35:54 UTC] PHP Fatal error: Uncaught Error: Call to a member function Execute() on null in /includes/modules/order_total/ot_shippingsurcharge.php:115
Stack trace:
#0 /*********/modules.php(218): ot_shippingsurcharge->keys()
#1 /*********/index.php(11): require('/nfs/home4/home...')
#2 {main}
thrown in /includes/modules/order_total/ot_shippingsurcharge.php on line 115
[06-Mar-2022 19:35:54 UTC] Request URI: /*********/index.php?cmd=modules&set=ordertotal&module=ot_shippingsurcharge, IP address: ***.**.**.**
--> PHP Fatal error: Uncaught Error: Call to a member function Execute() on null in /includes/modules/order_total/ot_shippingsurcharge.php:115
Stack trace:
#0 /*********/modules.php(218): ot_shippingsurcharge->keys()
#1 /*********/index.php(11): require('/nfs/home4/home...')
#2 {main}
thrown in /includes/modules/order_total/ot_shippingsurcharge.php on line 115.
Thanks for any help that anyone can provide. I'm just a beginner at this coding stuff.:( :ohmy: :shocking:
in /includes/modules/order_total/ot_shippingsurcharge.php lines 114-119 SHOULD be deleted:
PHP Code:
if (!defined('MODULE_ORDER_TOTAL_SHIPPINGSURCHARGE_VALUE_THRESHOLD')) {
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Value threshold for Shipping Surcharge', 'MODULE_ORDER_TOTAL_SHIPPINGSURCHARGE_VALUE_THRESHOLD', '0', 'Charge shipping surcharge for orders over this value.', '6', '4', now())");
}
if (!defined('MODULE_ORDER_TOTAL_SHIPPINGSURCHARGE_WEIGHT_THRESHOLD')) {
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Weight threshold for Shipping Surcharge', 'MODULE_ORDER_TOTAL_SHIPPINGSURCHARGE_WEIGHT_THRESHOLD', '0', 'Charge shipping surcharge for orders over this weight.', '6', '4', now())");
}
alternatively one could comment them out.
@swguy is the plugin author. it needs fixing.
Re: Error when installing the shipping surcharge module
Quote:
Originally Posted by
carlwhat
in /includes/modules/order_total/ot_shippingsurcharge.php lines 114-119 SHOULD be deleted:
PHP Code:
if (!defined('MODULE_ORDER_TOTAL_SHIPPINGSURCHARGE_VALUE_THRESHOLD')) {
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Value threshold for Shipping Surcharge', 'MODULE_ORDER_TOTAL_SHIPPINGSURCHARGE_VALUE_THRESHOLD', '0', 'Charge shipping surcharge for orders over this value.', '6', '4', now())");
}
if (!defined('MODULE_ORDER_TOTAL_SHIPPINGSURCHARGE_WEIGHT_THRESHOLD')) {
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Weight threshold for Shipping Surcharge', 'MODULE_ORDER_TOTAL_SHIPPINGSURCHARGE_WEIGHT_THRESHOLD', '0', 'Charge shipping surcharge for orders over this weight.', '6', '4', now())");
}
alternatively one could comment them out.
@swguy is the plugin author. it needs fixing.
I disagree with the need to comment out or remove the code. Perhaps for this user if the software has never ever been installed to the store, though there is little information provided about the history of the particular store's database.
The code requested to be posted was:
Code:
function keys() {
if (!defined('MODULE_ORDER_TOTAL_SHIPPINGSURCHARGE_VALUE_THRESHOLD')) {
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Value threshold for Shipping Surcharge', 'MODULE_ORDER_TOTAL_SHIPPINGSURCHARGE_VALUE_THRESHOLD', '0', 'Charge shipping surcharge for orders over this value.', '6', '4', now())");
The fix to this is to ensure that $db is set to something meaningful. As provided it is null because it is undeclared. In Zen Cart, $db is intended to provide access to the database and related functions. That is typically done by making the variable global or globally accessible.
So the fix would be to add the following line:
Code:
function keys() {
global $db;
if (!defined('MODULE_ORDER_TOTAL_SHIPPINGSURCHARGE_VALUE_THRESHOLD')) {
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Value threshold for Shipping Surcharge', 'MODULE_ORDER_TOTAL_SHIPPINGSURCHARGE_VALUE_THRESHOLD', '0', 'Charge shipping surcharge for orders over this value.', '6', '4', now())");
As to the appropriate location to get the best help on this software? That would be in the forum thread for the plugin: https://www.zen-cart.com/showthread....ping-Surcharge
Re: Error when installing the shipping surcharge module
@mc12345678 you are wrong.
the keys method is not the place to install configuration values. if one were to add the global $db declaration in said method, what happens when we call the install method, and we try to execute lines 127 and 128? we would now have an attempt to insert a duplicate key into the configuration table. (i can't remember which method gets called first, the result is the same.)
i would encourage you to test your recommendations (as i did) prior to making them. adding the global $db declaration just causes a new error. and, to me, it's pretty clear where the config values should get installed.... in the install method.
this is the answer and the best help for the OPs issue.
Re: Error when installing the shipping surcharge module
Quote:
Originally Posted by
carlwhat
@mc12345678 you are wrong.
the keys method is not the place to install configuration values. if one were to add the global $db declaration in said method, what happens when we call the install method, and we try to execute lines 127 and 128? we would now have an attempt to insert a duplicate key into the configuration table. (i can't remember which method gets called first, the result is the same.)
i would encourage you to test your recommendations (as i did) prior to making them. adding the global $db declaration just causes a new error. and, to me, it's pretty clear where the config values should get installed.... in the install method.
this is the answer and the best help for the OPs issue.
And apparently you missed the memo. Ways of installing/upgrading are to not require removal in order to upgrade. Been that way for a few zen Cart versions. Not sure what type of purist you are, but the keys method is out of the way of routine operation as once the missing keys are present there's no need to check again.
So looks like with that added information about the additional install issue that the query for the two newly added keys within the related install method should each start with insert ignore.
Re: Error when installing the shipping surcharge module
A couple of flubs on my part - as noted above, the $db variable needs to be global'ed but also the INSERT in keys() - which saves a remove/reinstall for upgraders - should *only* be done if the module is already installed. This provides an easier path for users to update plugins which might have new configuration keys. See (for example) authorizenet.php line 525.
Will update this module shortly.
Re: Error when installing the shipping surcharge module
Quote:
Originally Posted by
mc12345678
Able to provide the code that is at line 115 and before to a point where you see something like:
function
public function
protected function
static function
Or any thing like the above?
The error message suggests that a variable or class method is being used that hasn't been set or shared in the current code space.
Should be an easy fix. Also may help to post the location where this code is available. Suggest including the version number installed to your system and php version.
I meant to include the ZenCart version and PHP version being used on the server but I forgot. ZenCart Version is 1.5.7c. The PHP version running on the server at this time is 7.4
The site that I'm working with is https://eastforksales.com/.
Lines 98 thru 115:
function check() {
global $db;
if (!isset($this->_check)) {
$check_query = "SELECT configuration_value
FROM " . TABLE_CONFIGURATION . "
WHERE configuration_key = 'MODULE_ORDER_TOTAL_SHIPPINGSURCHARGE_STATUS'";
$check_query = $db->Execute($check_query);
$this->_check = $check_query->RecordCount();
}
return $this->_check;
}
function keys() {
if (!defined('MODULE_ORDER_TOTAL_SHIPPINGSURCHARGE_VALUE_THRESHOLD')) {
$db->Execute(" " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Value threshold for Shipping Surcharge', 'MODULE_ORDER_TOTAL_SHIPPINGSURCHARGE_VALUE_THRESHOLD', '0', 'Charge shipping surcharge for orders over this value.', '6', '4', now())");
I hope that this is the info that you were looking for.
Thanks.