• Resolved bonzait

    (@bonzait)


    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.

    • This topic was modified 2 years ago by bonzait.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Afterpay

    (@afterpayit)

    Hi @bonzait,

    Thanks for your message.

    The above described plugin file path and function do not match the latest Afterpay plugin. It seems like an out dated plugin may be in use, possibly WooCommerce Afterpay Gateway. Please refer to this post Re: WooCommerce Afterpay Gateway v1.3.1 and try again with the latest Afterpay Gateway for WooCommerce plugin.

    Thank you.

    Thread Starter bonzait

    (@bonzait)

    thank you very much for the heads up. Yes, that was the issue. We have installed the new version and configured it. The visual editor loads fine now with no errors. J

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Fatal Error: Uncaught Error: Call to a member function get_price() on bool’ is closed to new replies.