For add to cart button there is a function setLocation called on click in which URL, product id and quantity…