implements if control in ajax call for cart