Skip to content
Advertisement

I want to change the image I am using whenever the product is added to cart

I am using this right now, need to add a condition in such a way that whenever the getCartCount is 0 it should show image as bag_empty instead of bag and when the cart count is more than 0 it should show bag

JavaScript

Advertisement

Answer

You could use a ternary operator like below, assuming that you have your empty bag image in your public folder.

JavaScript
Advertisement