Advance feature for online courses

I need a feature like below for add to cart button in wix store

To hide the add to cart button if a user has already purchased the product linked with it, you can use the getMember() function in the page’s onReady() function to retrieve the ID of the current user viewing the page. Then query() the Stores/Orders collection and filter by the buyerInfo field using the member ID. This will return orders on your store made by that user.

If any of the orders contain that product, then hide() the “add to cart” button and show() the other one.

I am thinking that there may be an error in filtering data from wix store

Hello. Can you please post your code snippet in a code block? It will be easier to read. I’m also not completely sure what the question is. Can you explain what you are trying to do and what in your code is not working?

you wrote this as a function but didn’t call it from what I can see.

import { currentMember } from ‘wix-members’ ;
import wixData from ‘wix-data’ ;

$w . onReady ( function () {

let options = { fieldsets : [ ‘FULL’ ]}
currentMember . getMember ( options )
. then (( member ) => {
const id = member . _id ;
const fullName = ${ member . contactDetails . firstName } ${ member . contactDetails . lastName };
return member ;
})
. catch (( error ) => {
console . error ( error );
});

wixData . query ( “Stores/Orders” )
. eq ( “id” , “buyerInfo” )
. find ()
. then ( ( results ) => {
if ( results . items . length > 0 ) {
let firstItem = results . items [ 0 ];
if ( firstItem == ‘Solar Skill Development’ ) {
$w ( ‘#addToCartButton3’ ). hide ();
}
else {
$w ( ‘#addToCartButton3’ ). show ();
}
} else {
// handle case where no matching items found
}
} )
. catch ( ( err ) => {
let errorMsg = err ;

} ); 

});

Here i am attcahing the code. Please have a look solve the issues. Thanks in advance

import { currentMember } from 'wix-members';
import wixData from 'wix-data';

$w.onReady(function () {
  
  let options = {fieldsets: [ 'FULL' ]}
  currentMember.getMember(options)
  .then((member) => {
     const id = member._id;
     const fullName = `${member.contactDetails.firstName} ${member.contactDetails.lastName}`;
    return member;
   })
  .catch((error) => {
    console.error(error);
  });
  
  wixData.query("Stores/Orders")
    .eq("id","buyerInfo")
    .find()
    .then( (results) => {
      if(results.items.length > 0) {
        let firstItem = results.items[0];        
        if(firstItem=='Solar Skill Development') {
          $w('#addToCartButton3').hide();
        }
        else {
          $w('#addToCartButton3').show();
        }
      } else {
      // handle case where no matching items found
      }
    } )
    .catch( (err) => {
      let errorMsg = err;
      
    } );
    
    


});