torvista / Zen_Cart-Back_in_Stock_Notifications

Customers can subscribe to a notification when a product in not in stock.
GNU General Public License v3.0
0 stars 1 forks source link

PHP Fatal error: Uncaught Error: Undefined constant "BACK_IN_STOCK_REQUIRES_LOGIN" #8

Closed cstdenis closed 2 years ago

cstdenis commented 2 years ago

[15-Feb-2022 20:23:03 America/Vancouver] PHP Fatal error: Uncaught Error: Undefined constant "BACK_IN_STOCK_REQUIRES_LOGIN" in /usr/home/sites/zen15/www/includes/languages/english/extra_definitions/back_in_stock_notifications.php:23 Stack trace:

0 /usr/home/sites/zen15/www/includes/modules/extra_definitions.php(45): include()

1 /usr/home/sites/zen15/www/includes/init_includes/init_templates.php(85): include('/usr/home/sites...')

2 /usr/home/sites/zen15/www/includes/autoload_func.php(37): require_once('/usr/home/sites...')

3 /usr/home/sites/zen15/www/includes/application_top.php(222): require('/usr/home/sites...')

4 /usr/home/sites/zen15/www/index.php(25): require('/usr/home/sites...')

5 {main}

thrown in /usr/home/sites/zen15/www/includes/languages/english/extra_definitions/back_in_stock_notifications.php on

--- /usr/home/sites/zen15/www/includes/languages/english/extra_definitions/back_in_stock_notifications.php.old  2022-02-15 20:27:17.771032000 -0800
+++ /usr/home/sites/zen15/www/includes/languages/english/extra_definitions/back_in_stock_notifications.php      2022-02-15 20:30:26.138009000 -0800
@@ -20,7 +20,7 @@
  * Note that the link is added in place of %s, %s must be present for the link to work!
  */
 define('BACK_IN_STOCK_NOTIFICATION_TEXT_PRODUCT_LISTING_ALREADY_SUBSCRIBED', '<br />You have requested to be notified when this product is back in stock.');
-if (BACK_IN_STOCK_REQUIRES_LOGIN == '1') {
+if (defined('BACK_IN_STOCK_REQUIRES_LOGIN') && BACK_IN_STOCK_REQUIRES_LOGIN == '1') {
   define('BACK_IN_STOCK_NOTIFICATION_TEXT_PRODUCT_LISTING_FORM_LINK', '<br />To be notified when this product is back in stock please <a href="%s">click here</a>. (Requires account)');
 } else {
   define('BACK_IN_STOCK_NOTIFICATION_TEXT_PRODUCT_LISTING_FORM_LINK', '<br />To be notified when this product is back in stock please <a href="%s">click here</a>.');
@@ -30,7 +30,7 @@
  * Text/HTML for other pages.
  */
 define('BACK_IN_STOCK_NOTIFICATION_TEXT_ALREADY_SUBSCRIBED', 'You have requested to be notified when this product is back in stock.');
-if (BACK_IN_STOCK_REQUIRES_LOGIN == '1') {
+if (defined('BACK_IN_STOCK_REQUIRES_LOGIN') && BACK_IN_STOCK_REQUIRES_LOGIN == '1') {
   define('BACK_IN_STOCK_NOTIFICATION_TEXT_FORM_LINK', 'To be notified when this product is back in stock please <a href="%s">click here</a>. (Requires account)');
 } else {
   define('BACK_IN_STOCK_NOTIFICATION_TEXT_FORM_LINK', 'To be notified when this product is back in stock please <a href="%s">click here</a>.');
torvista commented 2 years ago

I can't trigger this. Zen Cart version? php version? On what page is this triggered? Look in your database for BACK_IN_STOCK_REQUIRES_LOGIN

cstdenis commented 2 years ago

ZenCart 1.5.7c PHP 8.0.15

I think it was happening on all pages.

Clean install of files, but using an existing database which contains an older version of back in stock. BACK_IN_STOCK_REQUIRES_LOGIN does not exist in the older version of the database.

Looking at the code, manually accessing admin/back_in_stock_notifications.php probably fixes this.

torvista commented 2 years ago

To add the constant BACK_IN_STOCK_REQUIRES_LOGIN.

Either you can uninstall (I could not find instructions for that) and re-install, or add it manually like this.

1) In your admin, hover over the link to BISN in the Configuration menu to get the gID of the url, eg. here it is 33,

Clipboard01

2)Use the following SQL in the admin->Tools->SQL Patch Tool, replacing the 33 with your site's gID.

INSERT INTOconfiguration(configuration_title,configuration_key,configuration_value,configuration_description,configuration_group_id,sort_order,set_function,date_added) VALUES ('Back in Stock requires login', 'BACK_IN_STOCK_REQUIRES_LOGIN', '1', '<br>If enabled, only logged in customers may use the Back in Stock notification system<br><br>0 = off<br>1 = on', '33', '1', 'zen_cfg_select_option(array(''0'', ''1''), ', NOW() );