skip to Main Content

I have to create lists of favorites products in woocommerce.

First I’ve created a new custom post type to manage my products list.
Now I need to add my products list to my custom type but I don’t know how to do this.

The final result will be a page listing all my lists for a user contains all added products by user.

Can anyone help ?

2

Answers


  1. Chosen as BEST ANSWER

    Thanks for your answer but i've needed to make my own plugin. WC Wishlist allow you to make only one list ;)

    After some works i've found a solution with meta_user_data to manage my lists.

     public function action_create_favorite_list(){
     
     
    
      if( ! is_user_logged_in() ) :
        return;
      endif;
    
      $list = new stdClass();
      $list->name = $_POST["list_name"];
      $list->items = array();
    
      $fav = get_user_meta( get_current_user_id(), 'user_'.get_current_user_id().'_favlist', true);
      if(empty($fav))
      {
        add_user_meta( get_current_user_id(), 'user_'.get_current_user_id().'_favlist', array());
        $fav = get_user_meta( get_current_user_id(), 'user_'.get_current_user_id().'_favlist', true);
      }
    
      array_push($fav,$list);
    
      update_user_meta( get_current_user_id(), 'user_'.get_current_user_id().'_favlist', $fav);
    
      wp_send_json($fav);
      wp_die();
    }
    

  2. I found a pretty comprehensive (paid) plugin by WooCommerce that does exactly this: WooCommerce Wishlists. I haven’t tried it.

    WooCommerce Wishlists allows guests and customers to create and add products to an unlimited number of Wishlists. From birthdays to weddings and everything in between, WooCommerce Wishlists is a welcome addition to any WooCommerce store.

    Plugin link: https://woocommerce.com/products/woocommerce-wishlists/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search