jeta
October 21, 2020, 12:00am
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?
Hello
This is problem with version php. Please check version on server.
Best regards
Robert
jeta
October 21, 2020, 12:00am
3
Hello
This is problem with version php. Please check version on server.
Best regards
Robert
The server default is PHP 7.4
Hello
Try to lower it to e.g. 7.0
Best regards
Robert
jeta
October 22, 2020, 12:00am
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
October 22, 2020, 12:00am
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?
What do you have on the mentioned line (1882 ) ?
jeta
October 23, 2020, 12:00am
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;
}
$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.
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
jeta
October 26, 2020, 12:00am
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 :)