Error when adding a product to the cart
-
When I add a product to the cart, the preloader remains spinning continually. In the backend, I see this error happening during the add-to-cart AJAX request:
2022-02-23T16:25:54+00:00 CRITICAL Uncaught Error: Class name must be a valid object or a string in /www/rezilirhealth_342/public/wp-content/plugins/flexible-shipping-fedex/vendor_prefixed/jeremy-dunn/php-fedex-api-wrapper/src/FedEx/AbstractComplexType.php:161
I debugged the code in the AbstractComplexType.php file and the problem comes from this line:
$arrayType = \FedExVendor\FedEx\Reflection::getAbstractClassSetterMethodArrayType($reflectionParameter);
$arrayType is null and, later on, the following line throws the actual error:
$class = new $arrayType();
The temporary fix that I implemented in the code is the following:
if ( ! empty( $arrayType ) ) { $class = new $arrayType(); $parameterValue[] = $class; $class->populateFromStdClass($stdClass->{$stdPropertyName}); }
But this fix is temporary, as it will be overridden in a plugin update. Also, I am not sure if any plugin functionality will be skipped here, because it is very difficult to understand the scope of the code.
Can you give me more information about this problem, and a potentially better solution?
- The topic ‘Error when adding a product to the cart’ is closed to new replies.