WooCommerce Waitlist incompatibility for single products – part 2

This topic has 6 replies, 2 voices, and was last updated 1 years, 6 months ago ago by Rose Tyler

  • Avatar: Krzysztof
    Krzysztof
    Participant
    January 18, 2023 at 15:22

    Hello again
    This is continuation to topic started here: https://www.8theme.com/topic/woocommerce-waitlist-incompatibility-for-single-products/

    I noticed only now that your solution works great but only for single product which is out of stock. For single product in backorder it placing waitlist widget in wrong place.

    Here what i see now: https://gyazo.com/edaf4e70ffc49df73c7d0b0cc90e884b

    as you see waitlist is after add to cart buttons but should be above as it is for now in case of variable products in backorder: https://gyazo.com/029f5fec1f5404079e8c718421b34c7a

    I did try to modify your code by adding one more IF

    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 ( is_product() ) {
    					if ( $product->is_in_stock() ) {
    			           add_action('woocommerce_before_add_to_cart_button', array('Pie_WCWL_Frontend_Simple', 'output_waitlist_elements'), 15);
    					}
    					else {
               			add_action('etheme_woocommerce_template_single_add_to_cart', array('Pie_WCWL_Frontend_Simple', 'output_waitlist_elements'), 30);			
    					} 
    				}
           }
        }
    }, 20);

    but Im not sure this is the best solution as even if I got the right place on single product page I also added this widget to other paces … e.g. in sticky bar: https://gyazo.com/886d28d9357a25ece349d678ad666580

    As by my code I could mess up too much I kindly ask you for support please πŸ™‚

    Please, contact administrator
    for this information.
    5 Answers
    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

    Avatar: Krzysztof
    Krzysztof
    Participant
    January 19, 2023 at 10:05

    Hello, Rose

    We are almost there πŸ™‚
    Waitlist widget is in the right place now =, thank you for corrected code, but again it is missing on simple product which is out-of-stock … so case where we started πŸ™‚

    Please contact administrator
    for this information.
    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    January 19, 2023 at 11:35

    Hello, Krzysztof,

    We changed the code in your xstore-child/functions.php ( https://prnt.sc/2gpoaYbtPd-p ), and also it was changed in the previous answer.
    For now, those products have waitlist form, please, check !

    Kind Regards,
    8theme team

    Avatar: Krzysztof
    Krzysztof
    Participant
    January 19, 2023 at 16:41

    Looks good now … thank you very very much.
    I will make fer more deep tests prior to production strat and will let you know if I will find anything else (but I do not expect any more issues) πŸ™‚

    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    January 19, 2023 at 16:49

    You’re welcome!
    Would you mind to rate our product – https://themeforest.net/downloads
    We’d appreciate if you could take a moment to give us 5-stars on ThemeForest!

    Kind Regards,
    8theme team

  • Viewing 6 results - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.