Add purchase query function