0

The above PHP error happens in PHP 8.1, and struggling to find a fix for this.

Code below, which is triggering the php uncaught error: Cannot access protected property shoppingCart::$content_type in

    public static function handleMissingDeliveryEntries($order, $us_state_codes)
    {
        if ($_SESSION['cart']->content_type == 'virtual') return $order->billing;
        if (isset($order->delivery) && $order->delivery !== false && $order->delivery['street_address'] != '') {
            return $order->delivery;
        }
        return $order->billing;
    }
}

Any ideas on how the above code can be re-done to overcome this php fatal error?

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
  • 1
    You can't access protected properties directly, that's what protected means. See [visibility](https://www.php.net/manual/en/language.oop5.visibility.php). The object might have a getter method like `getContentType()` or similar, you'll have to look at the source for that object. – Alex Howansky May 08 '23 at 18:19

0 Answers0