application/modules/api_v1/controllers/User.php
//Add and remove product in wishlist
Add and remove product in wishlist
Add and remove product in wishlist
function wishlist_put(){
        $this->check_service_auth();
        $user_id = $this->authData->userID;
        if(empty($this->put('product_id'))){
            $this->error_response(get_response_message(158)); 
        }
        $product_id = $this->put('product_id');
        $getWishlist = $this->common_model->getsingle(USER_WISHLIST,array('user_id'=> $user_id, 'product_id' => $product_id)); 
        if(empty($getWishlist)){ 
            $dataInsert['user_id'] = $user_id;
            $dataInsert['product_id'] = $product_id;
            $dataInsert['created_at'] = datetime();
            $insertWishlist = $this->common_model->insertData(USER_WISHLIST,$dataInsert);
            $this->success_response(get_response_message(166),['is_wishlist'=> "1"]);
        }else{ 
            $removeWishlist = $this->common_model->deleteData(USER_WISHLIST, array('user_id' => $user_id, 'product_id' => $product_id));
            if($removeWishlist === true){
                $this->success_response(get_response_message(167),['is_wishlist'=> "0"]);
            }
        }
    }
function wishlist_put ( ) { $ this -> check_service_auth ( ) ; $ user_id = $ this -> authData -> userID ; if ( empty ( $ this -> put ( 'product_id' ) ) ) { $ this -> error_response ( get_response_message ( 158 ) ) ; } $ product_id = $ this -> put ( 'product_id' ) ; $ getWishlist = $ this -> common_model -> getsingle ( USER_WISHLIST , array ( 'user_id' => $ user_id , 'product_id' => $ product_id ) ) ; if ( empty ( $ getWishlist ) ) { $ dataInsert [ 'user_id' ] = $ user_id ; $ dataInsert [ 'product_id' ] = $ product_id ; $ dataInsert [ 'created_at' ] = datetime ( ) ; $ insertWishlist = $ this -> common_model -> insertData ( USER_WISHLIST , $ dataInsert ) ; $ this -> success_response ( get_response_message ( 166 ) , [ 'is_wishlist' => " 1 " ] ) ; } else { $ removeWishlist = $ this -> common_model -> deleteData ( USER_WISHLIST , array ( 'user_id' => $ user_id , 'product_id' => $ product_id ) ) ; if ( $ removeWishlist === true ) { $ this -> success_response ( get_response_message ( 167 ) , [ 'is_wishlist' => " 0 " ] ) ; } } }
Add and remove product in wishlist
Add and remove product in wishlist
//error reponse //check product already in wishlist //If product not in wishlist then add //else remove from wishlist