Home Forums Plugins CURCY – WooCommerce Multi Currency Call to a member function get_shipping_country() on null

Call to a member function get_shipping_country() on null

  • Author
    Posts
  • #259877

    I’m editing a site with Touro theme using Elementor. Besides CURCY I’m also using Tourfic and Instantio. When I try to open elementor, I’m getting Error 500 with:

    Call to a member function get_shipping_country() on null in CURCY’s checkout.php:296

    This is CURCY calling WC()->customer->get_shipping_country() during plugin initialization, but WC()->customer is null at that point — because Instantio triggers WC_Checkout::get_checkout_fields() very early in the WordPress boot sequence (at plugins_loaded), before WooCommerce has finished setting up its customer session object. CURCY’s checkout hook fires in that window and crashes.
    This fatal kills the PHP process, so Elementor never gets a chance to load.

    To solve it, I patched /wp-content/plugins/woocommerce-multi-currency/frontend/checkout.php and it seems to be working now. Here is the code in case you want to consider it for further releases.

    settings = WOOMULTI_CURRENCY_Data::get_ins();
    if ( $this->settings->get_enable() ) {
    add_action( ‘woocommerce_checkout_process’, array( $this, ‘woocommerce_checkout_process’ ) );
    add_action( ‘woocommerce_checkout_update_order_review’, array(
    $this,
    ‘woocommerce_checkout_update_order_review’
    ), 99 );

    add_filter( ‘woocommerce_available_payment_gateways’, array( $this, ‘control_payment_methods’ ), 12 );
    add_action( ‘woocommerce_before_checkout_process’, array( $this, ‘change_currency_to_checkout’ ) );

    $equivalent_currency_page = $this->settings->get_param( ‘equivalent_currency_page’ );
    switch ( $equivalent_currency_page ) {
    case ”:
    case ‘checkout’:
    add_action( ‘woocommerce_checkout_init’, array( $this, ‘checkout_init’ ) );
    break;
    case ‘cart’:
    add_action( ‘woocommerce_before_cart’, array( $this, ‘checkout_init’ ), 9999 );
    break;
    case ‘cart_n_checkout’:
    add_action( ‘woocommerce_before_cart’, array( $this, ‘checkout_init’ ), 9999 );
    add_action( ‘woocommerce_checkout_init’, array( $this, ‘checkout_init’ ) );
    break;
    }

    add_filter( ‘woocommerce_cart_totals_order_total_html’, array( $this, ‘previous_currency_order_total’ ) );
    add_filter( ‘woocommerce_cart_totals_taxes_total_html’, array( $this, ‘previous_currency_taxes_total’ ) );
    // add_filter( ‘woocommerce_cart_tax_totals’, array( $this, ‘woocommerce_cart_tax_totals’ ), 10, 2 );
    add_filter( ‘woocommerce_cart_totals_fee_html’, array( $this, ‘previous_currency_fee_html’ ), 10, 2 );
    add_filter( ‘woocommerce_cart_subtotal’, array( $this, ‘previous_currency_cart_subtotal’ ), 10, 3 );
    add_filter( ‘woocommerce_cart_item_price’, array( $this, ‘previous_currency_item_price’ ), 10, 3 );
    add_filter( ‘woocommerce_cart_product_subtotal’, array( $this, ‘previous_currency_item_subtotal’ ), 10, 4 );
    add_filter( ‘woocommerce_cart_totals_coupon_html’, array( $this, ‘previous_currency_coupon_html’ ), 10, 3 );
    add_filter( ‘woocommerce_cart_shipping_method_full_label’, array(
    $this,
    ‘previous_currency_shipping_label’
    ), 10, 2 );

    add_filter( ‘woocommerce_checkout_get_value’, array( $this, ‘save_shipping_country’ ), 10, 2 );

    $theme = wp_get_theme();
    if ( ‘Elessi Theme Child’ != $theme->name

You must be logged in to see replies to this topic. Click here to login or register