A critical error being triggered with smartButton after last update
-
Hello,
We get getting fatal errors since our last update. We have upgraded from 1.9.2 to 1.9.5
Here is the complete error for you r reference –Fatal error: Uncaught Error: Call to a member function is_in_stock() on array in /www/mountainarchery_228/public/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-button/src/Assets/SmartButton.php:1419 Stack trace: #0 /www/mountainarchery_228/public/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-button/src/Assets/SmartButton.php(1365): WooCommerce\PayPalCommerce\Button\Assets\SmartButton->has_in_stock_variation(Array) #1 /www/mountainarchery_228/public/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-button/src/Assets/SmartButton.php(431): WooCommerce\PayPalCommerce\Button\Assets\SmartButton->product_supports_payment(Object(Premmerce\Optimizer\WooCommerce\Proxy\ProductVariableLite)) #2 /www/mountainarchery_228/public/wp-includes/class-wp-hook.php(307): WooCommerce\PayPalCommerce\Button\Assets\SmartButton->WooCommerce\PayPalCommerce\Button\Assets\{closure}(”) #3 /www/mountainarchery_228/public/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters(NULL, Array) #4 /www/mountainarchery_ in /www/mountainarchery_228/public/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-button/src/Assets/SmartButton.php on line 1419
There has been a critical error on this website.When I debug this issue, i found a function like –
protected function has_in_stock_variation( array $variations ): bool {
foreach ( $variations as $variation ) {
if ( $variation->is_in_stock() ) {
return true;
}
}
return false;
}And when I updated this like –
protected function has_in_stock_variation( array $variations ): bool {
foreach ( $variations as $variation ) {
if ( isset($variation[‘is_in_stock’]) && $variation[‘is_in_stock’]==1 ) {
return true;
}
}return false;
}It works fine, please let me know why we are getting error, is there any conflict with other plugin ? what should we do next to resolve this properly ?
Thanks
- The topic ‘A critical error being triggered with smartButton after last update’ is closed to new replies.