Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Fatal Error After Changing Host Rate Topic   - - - - -

 
  • jeta
  • Senior Member
  • Trial users
  • Join Date: 01-Apr 16
  • 191 posts

Posted 21 October 2020 - 12:12 PM #1

Hello,

 

I am experiencing an issue with my site after changing the host:

 

Fatal error: Cannot use $this as parameter in /home/public_html/app/functions/fn.promotions.php on line 1882

 

i am using version 4.7.1.SP2,

 

Can anyone tell me why is this happening?

 

 

 
  • soft-solid
  • Junior Member
  • Authorized Reseller
  • Join Date: 19-Apr 10
  • 1477 posts

Posted 21 October 2020 - 12:18 PM #2

Hello

 

This is problem with version php. Please check version on server.

 

Best regards

Robert


Team of SoftSolid
cs-cart.pl, marketplace

We specialize in creating the highest quality addons, safe, useful and flexible


 
  • jeta
  • Senior Member
  • Trial users
  • Join Date: 01-Apr 16
  • 191 posts

Posted 21 October 2020 - 12:46 PM #3

Hello

 

This is problem with version php. Please check version on server.

 

Best regards

Robert

The server default is PHP 7.4



 
  • soft-solid
  • Junior Member
  • Authorized Reseller
  • Join Date: 19-Apr 10
  • 1477 posts

Posted 21 October 2020 - 12:49 PM #4

Hello

 

Try to lower it to e.g. 7.0

 

Best regards

Robert


Team of SoftSolid
cs-cart.pl, marketplace

We specialize in creating the highest quality addons, safe, useful and flexible


 
  • jeta
  • Senior Member
  • Trial users
  • Join Date: 01-Apr 16
  • 191 posts

Posted 22 October 2020 - 09:13 AM #5

Hello

 

Try to lower it to e.g. 7.0

 

Best regards

Robert

i tried to lower it to 7.2 and i got this error message:

 

Error 503 - Service Unavailable
The resource you requested is currently unavailable. Typically this is a temporary condition. Please contact the web site owner for further assistance.


 
  • jeta
  • Senior Member
  • Trial users
  • Join Date: 01-Apr 16
  • 191 posts

Posted 22 October 2020 - 09:40 AM #6

i downgraded to php 7.0 and still the same error:

 

Fatal error: Cannot use $this as parameter in /home/public_html/app/functions/fn.promotions.php on line 1882

 

What should i do?



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 22386 posts

Posted 22 October 2020 - 01:52 PM #7

What do you have on the mentioned line (1882) ? 


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 1210     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 4025     CS-Cart + YOUPI      USD 1459      Multi-Vendor Ultimate       USD 7500 (6000)


 
  • jeta
  • Senior Member
  • Trial users
  • Join Date: 01-Apr 16
  • 191 posts

Posted 23 October 2020 - 04:49 PM #8

What do you have on the mentioned line (1882) ? 

function fn_promotion_shippings($this, $cart)  line 1882
{
    $result = false;
 
    if ($this['operator'] == 'eq') {
        $result = false;
    } elseif ($this['operator'] == 'neq') {
        $result = true;
    }


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12119 posts

Posted 23 October 2020 - 06:17 PM #9

$this is a reserved word in PHP..  Suggest you change

$this to $promotion_condition in the function parameters and in the function body.

 

I'm going to guess this was a bug specific to your cs-cart version and a test case didn't exist for shipping promotions.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 22386 posts

Posted 26 October 2020 - 04:58 AM #10

In my 4.7.1 local installation this function has the following code

 

function fn_promotion_shippings($promotion_condition, $cart)
{
    $result = false;


    if ($promotion_condition['operator'] == 'eq') {
        $result = false;
    } elseif ($promotion_condition['operator'] == 'neq') {
        $result = true;
    }


    if (!empty($cart['chosen_shipping'])) {
        foreach ($cart['chosen_shipping'] as $id) {
            if ($promotion_condition['operator'] == 'eq' && $id == $promotion_condition['value']) {
                $result = true;
            } elseif ($promotion_condition['operator'] == 'neq' && $id != $promotion_condition['value']) {
                $result = false;
            }
        }
    }


    return $result;
}

Try to replace function code and check the result


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 1210     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 4025     CS-Cart + YOUPI      USD 1459      Multi-Vendor Ultimate       USD 7500 (6000)


 
  • jeta
  • Senior Member
  • Trial users
  • Join Date: 01-Apr 16
  • 191 posts

Posted 26 October 2020 - 08:02 AM #11

 

In my 4.7.1 local installation this function has the following code

 

function fn_promotion_shippings($promotion_condition, $cart)
{
    $result = false;


    if ($promotion_condition['operator'] == 'eq') {
        $result = false;
    } elseif ($promotion_condition['operator'] == 'neq') {
        $result = true;
    }


    if (!empty($cart['chosen_shipping'])) {
        foreach ($cart['chosen_shipping'] as $id) {
            if ($promotion_condition['operator'] == 'eq' && $id == $promotion_condition['value']) {
                $result = true;
            } elseif ($promotion_condition['operator'] == 'neq' && $id != $promotion_condition['value']) {
                $result = false;
            }
        }
    }


    return $result;
}

Try to replace function code and check the result

 

Thank you very much, it seems to be working fine now :)