Discount Codes

cm_sc_discount_code.php error on line 44 - Discount Codes

cm_sc_discount_code.php error on line 44

by plamastus » Thu Apr 01, 2021 7:33 pm

Hi,

Phoenix 1.0.8
Discount_Codes_5.4.2_Phoenix

I get the following in the error_log:

[01-Apr-2021 14:20:28 America/New_York] PHP Fatal error: Uncaught Error: Call to a member function
count_contents() on null in /home/site/public_html/includes/modules/content/shopping_cart/cm_sc_discount_code.php:44
Stack trace:
#0 /home/site/public_html/includes/system/override/slim_checkout/osc_template.php(136): cm_sc_discount_code->execute()
#1 /home/site/public_html/templates/default/includes/pages/shopping_cart.php(13): oscTemplate->getContent('shopping_cart')
#2 /home/site/public_html/shopping_cart.php(17): require('/home/geishacof...')
#3 {main}
thrown in /home/site/public_html/includes/modules/content/shopping_cart/cm_sc_discount_code.php on line 44


Thanks,

Patrick
patrick
plamastus
Member
Posts: 82
Joined: Fri Mar 12, 2021 2:09 am
Phoenix Version:
Contact:

Re: cm_sc_discount_code.php error on line 44

by raiwa » Fri Apr 02, 2021 8:29 am

Hi Patrick,

THis sounds like you get the discount code showing with an empty shopping cart. This should not happen as it is coded. Could you give more details in which conditions you get this error.

Anyway, you could try to get rid of it with this modification in the discount module:
includes/modules/content/shopping_cart/cm_sc_discount_code.php line 42-44 change to:

Code: Select all

    function execute() {
      global $sess_discount_code;

      if ( isset($_SESSION['cart']) && $_SESSION['cart']->count_contents() > 0 ) {
        $content_width = (int)MODULE_CONTENT_SC_DISCOUNT_CODE_CONTENT_WIDTH;
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
raiwa
Certified Developer
Posts: 1640
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Contact: