Skip to content Skip to sidebar

This thread is resolved. Here is a description of the problem and solution.

Problem:
When cancelling a WooCommerce Booking in wp-admin, a fatal error occurs related to the cancellation email. This issue is due to a conflict between WooCommerce Multilingual & Multicurrency and WPML Multilingual CMS.

Solution:
We recommend modifying the code in the WooCommerce Multilingual plugin to handle null values correctly. Specifically, in the file

wp-content/plugins/woocommerce-multilingual/compatibility/WcBookings/class-wcml-bookings.php

, make the following changes:

1. For the method

\WCML_Bookings::get_translated_booking_resource_id

around line 948, replace:

if (is_null($trnsl_booking_resource_id)) {<br />    $trnsl_booking_resource_id = '';<br />}

with:

if (is_null($trnsl_booking_resource_id)) {<br />    $trnsl_booking_resource_id = $booking_resource_id;<br />}

2. Similarly, for

WCML_Bookings::get_translated_booking_product_id

around line 932, change:

if ($booking_product_id) {<br />    $trnsl_booking_product_id = apply_filters('translate_object_id', $booking_product_id, 'product', false, $language);<br />    if (is_null($trnsl_booking_product_id)) {<br />        $trnsl_booking_product_id = $booking_product_id;<br />    }<br />}

If this solution does not resolve your issue or seems irrelevant due to updates or different circumstances, please check the related known issues and confirm that you have installed the latest versions of themes and plugins. If the problem persists, we highly recommend opening a new support ticket at WPML support forum.

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 7 replies, has 2 voices.

Last updated by Dražen 11 months, 3 weeks ago.

Assisted by: Dražen.

Author Posts
August 28, 2024 at 11:03 am #16114390

scottM-22

Background of the issue:
When cancelling a WooCommerce Booking on wp-admin, a fatal error is generated related to the cancellation email.

WooCommerce support indicated that the issue is related to WPML. See the fatal error details and WooCommerce's feedback below.

WooCommerce Support Feedback:
"From the fatal errors and the PDF you shared, I see that the third-party plugins "̌WooCommerce Multilingual & Multicurrency" and "WPML Multilingual CMS" are conflicting with canceled booking emails.

You can also review this in the fatal errors stack trace:

#5 [internal function]: WCMLCompatibilityWcBookingsEmails->sendWithoutDuplicates()
#6 /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-content/plugins/sitepress-multilingual05/08/2024, 12:41 R&B Distillers Limited Mail - Fwd: [Isle of Raasay Distillery] Your Site is Experiencing a Technical Issue
#10 /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-includes/class-wp-hook.php(326):
WCMLCompatibilityWcBookingsEmails->WCMLCompatibilityWcBookings{closure}()

Screenshot: hidden link "

Symptoms:
A fatal error occurs when a user cancels a WooCommerce Booking.

A fatal error occurs when a user cancels a WooCommerce Booking. The error message is: Error Details
=============
An error of type E_ERROR was caused in line 49 of the file /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-content/plugins/woocommerce-bookings/templates/emails/customer-booking-cancelled.php. Error message: Uncaught Error: Call to a member function get_resource_label() on null in /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-content/plugins/woocommerce-bookings/templates/emails/customer-booking-cancelled.php:49
Stack trace:
#0 /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-content/plugins/woocommerce/includes/wc-core-functions.php(345): include()
#1 /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-content/plugins/woocommerce-bookings/includes/emails/class-wc-email-booking-cancelled.php(120): wc_get_template()
#2 /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-content/plugins/woocommerce/includes/emails/class-wc-email.php(588): WC_Email_Booking_Cancelled->get_content_html()
#3 /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-content/plugins/woocommerce-bookings/includes/emails/class-wc-email-booking-cancelled.php(103): WC_Email->get_content()
#4 /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-content/plugins/woocommerce-multilingual/compatibility/WcBookings/Emails.php(182): WC_Email_Booking_Cancelled->trigger()
#5 [internal function]: WCMLCompatibilityWcBookingsEmails->sendWithoutDuplicates()
#6 /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/fp/core/functions.php(83): call_user_func_array()
#7 [internal function]: WPMLFP{closure}()
#8 /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/collect/src/Illuminate/Support/Collection.php(603): array_map()
#9 /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-content/plugins/woocommerce-multilingual/compatibility/WcBookings/Emails.php(163): WPMLCollectSupportCollection->map()
#10 /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-includes/class-wp-hook.php(326): WCMLCompatibilityWcBookingsEmails->WCMLCompatibilityWcBookings{closure}()
#11 /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#12 /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-includes/plugin.php(565): WP_Hook->do_action()
#13 /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-content/plugins/woocommerce/includes/class-wc-emails.php(172): do_action_ref_array()
#14 /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-includes/class-wp-hook.php(324): WC_Emails::send_transactional_email()
#15 /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#16 /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-includes/plugin.php(517): WP_Hook->do_action()
#17 /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-content/plugins/woocommerce-bookings/includes/data-objects/class-wc-booking.php(365): do_action()
#18 /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-content/plugins/woocommerce-bookings/includes/data-objects/class-wc-booking.php(261): WC_Booking->status_transitioned_handler()
#19 /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-content/plugins/woocommerce-bookings/includes/data-objects/class-wc-booking.php(226): WC_Booking->status_transition()
#20 /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-content/plugins/woocommerce-bookings/includes/admin/class-wc-bookings-details-meta-box.php(682): WC_Booking->save()
#21 /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-includes/class-wp-hook.php(326): WC_Bookings_Details_Meta_Box->meta_box_save()
#22 /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#23 /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-includes/plugin.php(517): WP_Hook->do_action()
#24 /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-includes/post.php(4891): do_action()
#25 /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-includes/post.php(4993): wp_insert_post()
#26 /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-admin/includes/post.php(453): wp_update_post()
#27 /mnt/data/home/585904.cloudwaysapps.com/sfvbzahsjd/public_html/wp-admin/post.php(227): edit_post()
#28 {main}
thrown

Questions:
How can I resolve the fatal error when cancelling a WooCommerce Booking?
Is there a known conflict between WPML and WooCommerce Booking cancellation emails?

August 28, 2024 at 11:59 am #16114775

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

I have tried to reproduce the same issue on new test site, but I do not get an error. I have setup a new website with WC Bookings and created a new bookable product. Made an order from frontend in the default language, and then tried to cancel the order from back, it works fine and no error.

Can you please check: hidden link

seems some specific steps or settings are needed for the issue to happen.

Let me know.

Regards,
Drazen

August 28, 2024 at 12:09 pm #16114821

scottM-22

I'm not clear why but your test site is not setting the booked products to Paid status, they seem to stay at Unpaid even with the order is set to processing.

The bookings should be set to paid, until then they aren't confirmed bookings.

The above is something to do with the test site's payment method I would guess.

I suspect a booking set to Unpaid won't trigger the cancellation email, hence the lack of error.

If we manually set the booking to paid, then cancel it the error is reproduced: hidden link

August 28, 2024 at 12:39 pm #16114981

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

thanks, that is correct, but I also see you have added resources and products but have not translated them.

I have translated both and seems the fatal error is not there, but seems there is another bug, when making an order you are not redirected to the thank you page, even if the order is created in the back.

Can you test this on the test site and your website and let me know how it goes?

Note is needed to translate resources as explained in the docs:

https://wpml.org/documentation/woocommerce-extensions-compatibility/translating-woocommerce-bookings-woocommerce-multilingual/

Regards,
Drazen

August 28, 2024 at 1:18 pm #16115359

scottM-22

I have both Booking and booking resources set to Not Translatable.

Surely your plugin should be able to cope with this scenario without causing a fatal error on the site?!

To be blunt I've spent enough time on this - in my view this is a bug that can be reproduced on a fresh install and should be investigated and addressed.

Screenshot 2024-08-28 at 14.11.14.png
August 28, 2024 at 2:00 pm #16115691

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

I just wanted to check if that would be helpful and works for your case when you follow the recommended steps.

Anyway, I have escalated this to our compatibility team and will update you when there is some feedback.

Regards,
Drazen

August 28, 2024 at 3:09 pm #16115974

scottM-22

No worries - thanks for escalating. Scott

August 29, 2024 at 1:48 pm #16120404

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

the issue is escalated to our developers, and in the meantime, you can use the next workaround:

in wp-content/plugins/woocommerce-multilingual/compatibility/WcBookings/class-wcml-bookings.php \WCML_Bookings::get_translated_booking_resource_id around line 948

replace

			if ( is_null( $trnsl_booking_resource_id ) ) {
				$trnsl_booking_resource_id = '';
			}

to

			if ( is_null( $trnsl_booking_resource_id ) ) {
				$trnsl_booking_resource_id = $booking_resource_id;
			}

Also same should be done for WCML_Bookings::get_translated_booking_product_id around line 932 and change the code to:

		if ( $booking_product_id ) {
			$trnsl_booking_product_id = apply_filters( 'translate_object_id', $booking_product_id, 'product', false, $language );
			if ( is_null( $trnsl_booking_product_id ) ) {
				$trnsl_booking_product_id = $booking_product_id;
			}
		}

Regards,
Drazen