This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by Bobby 2 months ago.

Assigned support staff: Bobby.

Author Posts
August 8, 2019 at 8:36 pm

phimyadaK

I am trying to:
Setup Woocommerce Multilingual on our Car Rental Page since the car rental system is based on WooCommerce. The errors dissappear if WPML and WooC. Multi. are deactivated and deleted. The main problem is caused according to the debug.log by the Multi-Currency functionality.

I expected to see:
No errors since the theme developers promised 100% WPML and W.Multi. Compatibility.

Instead, I got:
see debug.log-Image attached.

One thing that is really weird and only happens if WooCommerce Multilingual is activated is that im having unexpected behavior with the Cart. Calling get_total() or any other method accessing the cart returns either "null" or 0 or only the subtotal of the cart and not the total. But i think solving the main issue, the fatal error should solve this weird behavior too.

August 8, 2019 at 11:55 pm
August 8, 2019 at 11:58 pm #4366277

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hi There,

i am having a hard time reproducing the error

when i go to WC->WCML->Multi Currency it is activated and i dont see any apparent errors , i do see the error in the error log though

now what steps do i need to take exactly to see this error in the front end or its behavior

also within wp-content/themes/motors/inc/woocommerce_setups_rental.php:71

did you wrap the following code with

if ( !is_admin() ) {
function stm_get_cart_current_total()
{
    if ( !is_admin() ) {
        return apply_filters( 'stm_rent_current_total', WC()->cart->get_total() );
    }

    return 0;
}
August 9, 2019 at 12:45 am #4366361

phimyadaK

Hi,
in order to see the weird behaviour which this error leads to, is when you try to book a car and reach the checkout page and click on the paypal payment method you then see left in the car order details that there is added a paypal fee. I managed to do that with some custom code and ajax which can be found in the functions.php of the child theme. The problem is now that when i try to get the carts total value in order to calculate the fee and add it, i only get the subtotal and not the overall total. This seems to have nothing to do with the error but before WPML and multi currency this worked fine, i got the total and the calculation was correct. The only thing i added to the page was WPML and WooCommerce Multi so i assume it breaks something with the theme. Regarding the stacktrace it must be something with the multi currencency.

And no i did not wrap the code with !is_admin() that is the code from the theme developers.

August 12, 2019 at 5:51 pm #4382941

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hello,

please review the following documentation and let me know your results

https://wpml.org/errata/woocommerce-with-multiple-currencies-triggers-a-call-to-get_cart-too-early/

it seems that your custom code for the paypal fee calculation is triggering a call to get_cart before the wp_loaded action

please try the workaround provided above and let me know your results

The topic ‘[Closed] Fatal Error: get_total() on null and get_cart() was called incorrectly.’ is closed to new replies.