add purchase function