Home Forums WoodMart support forum Product variation name is not showing in wishlist Reply To: Product variation name is not showing in wishlist

#554227

Luke Nielsen
Keymaster

Hello,

In the wp-content\themes\woodmart\inc\integrations\woocommerce\modules\wishlist\class-wishlist.php file find the remove_unnecessary_products function and replace it with the below code:

public function remove_unnecessary_products() {
		if ( is_user_logged_in() ) {
			if ( ! get_user_meta( get_current_user_id(), 'wishlist_cleared_time', true ) ) {
				update_user_meta( get_current_user_id(), 'wishlist_cleared_time', time() );
			}

			$wishlist_cleared_time = get_user_meta( get_current_user_id(), 'wishlist_cleared_time', true );
		} else {
			if ( ! woodmart_get_cookie( 'wishlist_cleared_time' ) ) {
				woodmart_set_cookie( 'wishlist_cleared_time', time() );
			}

			$wishlist_cleared_time = woodmart_get_cookie( 'wishlist_cleared_time' );
		}

		$wishlist_cleared_time = intval( $wishlist_cleared_time );

		if ( time() < $wishlist_cleared_time + DAY_IN_SECONDS ) {
			return;
		}

		foreach ( $this->get_all() as $product_data ) {
			$product_id  = $product_data['product_id'];
			$wishlist_id = ! empty( $product_data['wishlist_id'] ) ? $product_data['wishlist_id'] : $this->get_id();

			if ( 'publish' !== get_post_status( $product_id ) || 'product' !== get_post_type( $product_id ) ) {
				$this->remove( $product_id, $wishlist_id );
			}
		}

		$this->update_count_cookie();

		if ( is_user_logged_in() ) {
			update_user_meta( get_current_user_id(), 'wishlist_cleared_time', time() );
		} else {
			woodmart_set_cookie( 'wishlist_cleared_time', time() );
		}
}

Kind Regards