Fatal error when installed with WPML plugin
-
Hello
I am php developer working on WPML plugin (https://wpml.org). We found your plugin is causing fatal error when installed alongside with ours.
How to reproduce
Setup WPML and WCML in 2 languages
Enable multicurrency
Install Partial.Ly plugin – available from the WP repository
Make a rest request to: /wp-json/wc/v3/products
Notice a fatal error as mentioned aboveThe error is:
> PHP Fatal error: Uncaught Error: Call to a member function get_cart() on null in …\woo-partially\inc\gateway.php:20The piece of code there is:
// check for products in the cart with Partially disabled foreach (WC()->cart->get_cart() as $cart_item_key => $item) { if (get_post_meta( $item['product_id'], 'partially_disabled', true ) == 'yes') { $hasDisabled = true; } }
The cart is not set indeed. Could you wrap this piece od code into that if, so it will not be executed during REST API calls?
if ( null !== WC()->cart ) { // your code goes here }
- The topic ‘Fatal error when installed with WPML plugin’ is closed to new replies.