Fatal Error: Uncaught Error: Call to a member function get_price() on bool
-
Hi Team,
We are using Divi theme and every time we open ‘Page Visual editor’ for Pages it’s not loading. Upon further investigation, we found the website caught the following fatal error.
PHP Fatal error: Uncaught Error: Call to a member function get_price() on bool in /wp-content/plugins/woocommerce-afterpay/woocommerce-afterpay.php:1181
P.s. the page loads on normal, only the visual editor is getting this error. This is not happening with Products, the issue is only with Pages/Posts.
Here is the function we found in the plugin file.
`/**
* Showing the Pay Over Time information on the individual product page
*
* @since 1.0.0
**/
function afterpay_show_pay_over_time_info_product_page() {
$settings = get_option(‘woocommerce_afterpay_settings’);if (!isset($settings[‘enabled’]) || $settings[‘enabled’] !== ‘yes’) return;
if (isset($settings[‘show-info-on-product-pages’]) && $settings[‘show-info-on-product-pages’] == ‘yes’ && isset($settings[‘product-pages-info-text’])) {
global $post;
if( function_exists(“wc_get_product”) ) {
$product = wc_get_product($post->ID);
}
else {
$product = new WC_Product($post->ID);
}
$price = $product->get_price();// Don’t display if the product is a subscription product
if ($product->is_type(‘subscription’)) return;// Don’t show if the string has [AMOUNT] and price is variable, if the amount is zero, or if the amount doesn’t fit within the limits
if ((strpos($settings[‘product-pages-info-text’],'[AMOUNT]’) !== false && strpos($product->get_price_html(),’–’) !== false) || $price == 0 || $settings[‘pay-over-time-limit-max’] < $price || $settings[‘pay-over-time-limit-min’] > $price) return;$amount = wc_price($price/4);
$text = str_replace(array(‘[AMOUNT]’),$amount,$settings[‘product-pages-info-text’]);
echo ‘<p class=”afterpay-payment-info”>’.$text.'</p>’;
}
}We need to make the new site go live asap, so this has become a very important one. Please help.
The page I need help with: [log in to see the link]
- The topic ‘Fatal Error: Uncaught Error: Call to a member function get_price() on bool’ is closed to new replies.