Reply 344356 to: WooCommerce Waitlist incompatibility for single products – part 2

Avatar: Rose Tyler
Rose Tyler
Support staff
January 19, 2023 at 08:39

Hello, Krzysztof,

Please check the results now. We have provided screenshots for your reference at the following links: https://prnt.sc/imq1P3zGYPrP and https://prnt.sc/OXpE7Beg-Qw5

Additionally, we have also provided an improved version of the code, which can be found at the following link: https://prnt.sc/v7sHazYZ1KtI

Code:

add_action('wp', function() {
	// add compatibility with WooCommerce Waitlist plugin and XStore Single product builder
	if ( class_exists('Pie_WCWL_Frontend_Simple') ) {
		if ( Pie_WCWL_Frontend_Simple::$product_id ) {
			global $product;
			if ( !$product->is_in_stock() ) {
				add_action('etheme_woocommerce_template_single_add_to_cart', array('Pie_WCWL_Frontend_Simple', 'output_waitlist_elements'), 20);
			}
			else {
        		add_action('woocommerce_before_add_to_cart_form', array('Pie_WCWL_Frontend_Simple', 'output_waitlist_elements'), 10);			
        		add_action('etheme_sticky_add_to_cart_before', function() {
        			remove_action('woocommerce_before_add_to_cart_form', array('Pie_WCWL_Frontend_Simple', 'output_waitlist_elements'), 10);			
        		});
        		add_action('etheme_sticky_add_to_cart_after', function() {
        			add_action('woocommerce_before_add_to_cart_form', array('Pie_WCWL_Frontend_Simple', 'output_waitlist_elements'), 10);			
        		});
        	}
		}
	}
}, 20);

Kind Regards,
8theme team

Go To The Whole Conversation In Topic
We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.