Refactor code for adding products to cart #6000