• Hi

    Today I got this error:

    WordPress versie 5.7
    Huidige plugin: Events Manager – Event Cancellation (versie 2.0.2)
    PHP versie 7.4.16

    Foutdetails
    ===========
    Een fout van het type E_ERROR werd veroorzaakt op regelnummer 90 van het bestand /var/web/vd17908/public_html/wp-content/plugins/stonehenge-em-cancellation/classes/class-admin.php. Foutmelding: Uncaught ArgumentCountError: Too few arguments to function

    Stonehenge_EM_Event_Cancellation_Admin::add_booking_status(), 1 passed in /var/web/vd17908/public_html/wp-includes/class-wp-hook.php on line 292 and exactly 2 expected in /var/web/vd17908/public_html/wp-content/plugins/stonehenge-em-cancellation/classes/class-admin.php:90
    Stack trace:
    #0 /var/web/vd17908/public_html/wp-includes/class-wp-hook.php(292): Stonehenge_EM_Event_Cancellation_Admin->add_booking_status(Object(EM_Booking))
    #1 /var/web/vd17908/public_html/wp-includes/class-wp-hook.php(316): WP_Hook->apply_filters(NULL, Array)
    #2 /var/web/vd17908/public_html/wp-includes/plugin.php(484): WP_Hook->do_action(Array)
    #3 /var/web/vd17908/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(469) : eval()'d code(3): do_action('em_booking', Object(EM_Booking))
    #4 /var/web/vd17908/public_html/wp-includes/class-wp-hook.php(292): {closure}('')
    #5 /var/web/vd17908/public_html/wp-includes/class-wp-hook.php(316): WP_Hook->apply_filters('', Array)
    #6

    Is is possible that Event Cancellation is not compatible with Events Manager WooCommerce?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Stonehenge Creations

    (@duisterdenhaag)

    Hi @crossroast,

    Thank you for reporting this error. I have not come across that before.

    The error states that only one parameter is being parsed, while two are expected. Looking at the action hook that this method uses in the Events Manager code is:
    do_action('em_booking', $this, $booking_data);
    $this is the $EM_Booking object.

    The error indicates also that you have a custom PHP snippet using the same action. If that snippet does not have the second parameter and is called before this plugin, that could explain the error. Could you check that, please?

    Thread Starter crossroast

    (@crossroast)

    Hi @duisterdenhaag

    Thanks for the respond (I tried via the plug-in support forum, but can’t log-in anymore)

    It’s true I have a custom PHP snippet:

    add_action('em_bookings_admin_page', function(){
    	global $EM_Booking;
    	if( !empty($EM_Booking) ) do_action('em_booking', $EM_Booking);
    });
    add_action('em_booking', function( $EM_Booking ){
    	if( !empty($EM_Booking->booking_id) && $EM_Booking->person_id == 0 && !empty($EM_Booking->booking_meta['woocommerce']['order_id']) && empty($EM_Booking->booking_meta['registration']['first_name']) ){
    		$post = get_post($EM_Booking->booking_meta['woocommerce']['order_id']);
    		if( $post !== null ){
    			$order = new \WC_Order( $EM_Booking->booking_meta['woocommerce']['order_id'] );
    			if( $order->get_id() > 0 ){
    				$order_function_map = array(
    					'first_name' => 'get_billing_first_name',
    					'last_name' => 'get_billing_last_name',
    					'user_name' => 'get_formatted_billing_full_name',
    					'user_email' => 'get_billing_email',
    					'address' => 'get_billing_address_1',
    					'address_2' => 'get_billing_address_2',
    					'city' => 'get_billing_city',
    					'state' => 'get_billing_state',
    					'zip' => 'get_billing_postcode',
    					'country' => 'get_billing_country',
    					'company' => 'get_billing_company',
    					'phone' => 'get_billing_phone',
    				);
    				$associated_fields = get_option('emp_gateway_customer_fields');
    				foreach( $order_function_map as $field_key => $order_function ){
    					if( !empty($associated_fields[$field_key]) ) {
    						$form_field_id = $associated_fields[$field_key];
    						$EM_Booking->booking_meta['registration'][$form_field_id] = $order->$order_function();
    					}elseif( in_array($field_key, array('first_name', 'last_name', 'user_name', 'user_email')) ){
    						$EM_Booking->booking_meta['registration'][$field_key] = $order->$order_function();
    					}
    				}
    			}
    		}
    		$EM_Booking->booking_meta['woocommerce']['synced'] = true;
    	}
    }, 10, 1);

    This is from EM as a temporarily fix for the issue that we lost out customer booking data if we go via WooCommerce.

    So if that’s now a issue, I fear that if they have a fix it could be more of an issue.

    Plugin Author Stonehenge Creations

    (@duisterdenhaag)

    Thank you for the snippet.
    It appears that the EM team discards their own parameters, which I find a bit strange and personally, I am not a big fan of anonymous functions. ??

    But, since it’s their plugin we are hooking into, I will comply with the snippet they gave you.

    Because I am not using WooCommerce myself, could you please do a little test for me? If that indeed solves this conflict, I will release an updated version of EM – Events Cancellation.

    In /wp-content/stonehenge-em-cancellation/classes/class-init.php, change line 38 to:
    add_action('em_booking', array($this, 'add_booking_status'), 10, 1);

    Then in /wp-content/stonehenge-em-cancellation/classes/class-admin.php, change line 90 to:
    public function add_booking_status( $EM_Booking ) {

    Thread Starter crossroast

    (@crossroast)

    Hi @duisterdenhaag

    I think the snippet they gave me is only a temporarily fix to help me out and therefor discards their own parameters.

    That seems to solves this conflict.

    Maybe I don’t mark this as resolved as just yet, if EM comes with a update I can tell you here.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘E_ERROR with event Cancellation plug-in’ is closed to new replies.