Home Forums WoodMart support forum Wishlist sending onsale email when price change to regular

Wishlist sending onsale email when price change to regular

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #682032

    metuza
    Participant

    Hello,

    I have noticed that now and then when i update product prices from saleprice to regular price i do receive the email telling me that a product now is for sale in my wishlist. Since this happens only now and then i have not done anything with it.

    Today i received an forwarded email from a customer showing me that she had received the onsale email for a product that was adjusted from onsale to regular yesterday so i belive that there is a bug somewhere. But not easy to find as this happens just now and then.

    I am always using the WooCommerce Advanced Bulk Edit plugin when i do these changes.

    Brgds
    Rune

    #682153

    Artem Temos
    Keymaster
    Xtemos team

    Hello,

    Could you please send us your admin access and step-by-step instructions on how to reproduce this issue on your website? We don’t see any problems on our staging.

    Kind Regards

    #682197

    metuza
    Participant

    Hello,

    I’m sorry that is the problem, it is impossible to investigate. I have maybe used the wishlist for 12-14 months and only once i have received complains from customers and that was today. And myself has received that product onsale email maybe 3 times during these months, and i usually make sure i have onsale items in my wishlist when i change to regular price just to test.

    I have done lots, and lots of tests but never received the onsale email during any of my tests. When checked database today (woodmart_wishlist_products) i also find that the product the customer received email about had value 0 in the onsale column, so not on sale and all ok there.

    So it is really wierd and i do not think it is a big problem as it as mentioned almost never happens. So you can do hundreds of tests and never see any problem.

    I just wanted to mention it in case you had a suspicion about something in the code. I have study the code myself and can not find anything there that should be able to send the wrong email.

    Brgds
    Rune

    #682205

    Artem Temos
    Keymaster
    Xtemos team

    Try to add the following code snippet to the functions.php file in your child theme. It will add extra conditions to fix such cases

    if ( ! function_exists( 'woodmart_cleanup_invalid_sale_products' ) ) {
    	/**
    	 * This removes the item from the 'Wishlist on Sale' letter queue if the product is not on sale.
    	 *
    	 * @param int   $user_id User ID.
    	 * @param array $product_ids Array of product IDs.
    	 */
    	function woodmart_cleanup_invalid_sale_products( $user_id, $product_ids ) {
    		$products_on_sale = get_option( 'woodmart_wishlist_products_on_sale', array() );
    
    		if ( ! $products_on_sale ) {
    			return;
    		}
    
    		foreach ( $product_ids as $product_id ) {
    			$product = wc_get_product( $product_id );
    
    			if ( ! $product || ! $product->is_on_sale() ) {
    				if ( isset( $products_on_sale[ $user_id ] ) ) {
    					$key = array_search( $product_id, $products_on_sale[ $user_id ], true );
    
    					if ( false !== $key ) {
    						unset( $products_on_sale[ $user_id ][ $key ] );
    					}
    				}
    			}
    		}
    
    		if ( isset( $products_on_sale[ $user_id ] ) ) {
    			$products_on_sale[ $user_id ] = array_values( $products_on_sale[ $user_id ] );
    
    			if ( empty( $products_on_sale[ $user_id ] ) ) {
    				unset( $products_on_sale[ $user_id ] );
    			}
    		}
    
    		update_option( 'woodmart_wishlist_products_on_sale', $products_on_sale, false );
    	}
    
    	add_action( 'woodmart_send_on_sale_products_mail', 'woodmart_cleanup_invalid_sale_products', 5, 2 );
    }
    #682264

    metuza
    Participant

    Thank you 🙂 I have added it to my functions and will let you know in a year or so, or if it happens again.

    Thanks again ..

    Brgds
    Rune

    #682314

    Artem Temos
    Keymaster
    Xtemos team

    OK, great. I will keep this topic open.

    Kind Regards

Viewing 6 posts - 1 through 6 (of 6 total)