Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1
    Join Date
    Mar 2022
    Location
    United States
    Posts
    8
    Plugin Contributions
    0

    Default 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
    Click image for larger version. 

Name:	Screenshot 2022-03-06 134714_a.jpg 
Views:	140 
Size:	26.6 KB 
ID:	19918

    Image B
    Click image for larger version. 

Name:	Screenshot 2022-03-06 134758_b.jpg 
Views:	139 
Size:	26.8 KB 
ID:	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.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Screenshot 2022-03-06 134714.jpg 
Views:	108 
Size:	23.7 KB 
ID:	19916   Click image for larger version. 

Name:	Screenshot 2022-03-06 134758.jpg 
Views:	108 
Size:	17.9 KB 
ID:	19917  

  2. #2
    Join Date
    Mar 2022
    Location
    United States
    Posts
    8
    Plugin Contributions
    0

    Default Re: Error when installing the shipping surcharge module

    Is there anybody out there?

  3. #3
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default 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.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  4. #4
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default 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.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,688
    Plugin Contributions
    9

    Default Re: Error when installing the shipping surcharge module

    Quote Originally Posted by Semi-Crazy View Post
    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
    Click image for larger version. 

Name:	Screenshot 2022-03-06 134714_a.jpg 
Views:	140 
Size:	26.6 KB 
ID:	19918

    Image B
    Click image for larger version. 

Name:	Screenshot 2022-03-06 134758_b.jpg 
Views:	139 
Size:	26.8 KB 
ID:	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.
    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.
    author of square Webpay.
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

  6. #6
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Error when installing the shipping surcharge module

    Quote Originally Posted by carlwhat View Post
    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
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #7
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,688
    Plugin Contributions
    9

    Default 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.
    Last edited by carlwhat; 14 Mar 2022 at 12:57 AM.
    author of square Webpay.
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

  8. #8
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Error when installing the shipping surcharge module

    Quote Originally Posted by carlwhat View Post
    @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.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  9. #9
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,684
    Plugin Contributions
    123

    Default 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.
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  10. #10
    Join Date
    Mar 2022
    Location
    United States
    Posts
    8
    Plugin Contributions
    0

    Default Re: Error when installing the shipping surcharge module

    Quote Originally Posted by mc12345678 View Post
    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.
    Last edited by Semi-Crazy; 18 Mar 2022 at 02:08 AM.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 16
    Last Post: 28 Sep 2020, 02:18 AM
  2. Add a flat surcharge into cart when using USPS module?
    By stride-r in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 9 Dec 2008, 02:57 AM
  3. Installing shipping module causes headers already sent error
    By swguy in forum Built-in Shipping and Payment Modules
    Replies: 3
    Last Post: 22 Dec 2007, 06:19 PM
  4. Error installing cloned zone shipping module
    By shocker in forum Built-in Shipping and Payment Modules
    Replies: 11
    Last Post: 16 Aug 2007, 04:15 AM
  5. Canada Post shipping module - Fuel Surcharge
    By jbrit in forum Addon Shipping Modules
    Replies: 0
    Last Post: 4 Aug 2006, 05:36 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR