How to add custom product sorting option based on wishlist in Woocommerce?

Viewed 46

Customers in our woocommerce store have their own wishlist. I can get product's ids of logged in customer with following code:

$user_id = get_current_user_id();
global $wpdb;
$wishlist_id = $wpdb->get_var("SELECT id FROM wp_wl_lists WHERE author = $user_id");
$products = $wpdb->get_col("SELECT product_id FROM wp_wl_items WHERE wishlist_id = $wishlist_id");

The thing I want to do is to make my own sorting option with products from customer wishlist first...

Have any ideas how to make it?

Thanks

0 Answers
Related