Hrach Ghapantsyan
Hrach Ghapantsyan

Reputation: 699

OpenCart - Adding a product via a link

I am currently using OpenCart and would like to replace their 'Add to Cart' button with a simple link that says add to cart but I am currently running into a few problems. Currently, OpenCart uses javascript to add products to the cart using a button:

<button type="button" onclick="cart.add('41');"><i class=""></i> <span class="hidden-xs hidden-sm hidden-md">Add to Cart</span></button>

Now, products are added by using "onclick" which as I understand can also be used in <a> tags. Therefore, I have also tried to do this using a simple link:

<a onclick="cart.add('41');" href="#">Add to Cart</a>

What I am failing to understand is why the product is added to the cart as it should be when using the button but then when using the link, nothing happens. All help will be appreciated, Thanks.

Upvotes: 1

Views: 608

Answers (1)

Hrach Ghapantsyan
Hrach Ghapantsyan

Reputation: 699

This seemed to be an issue with OpenCart's built in cache system. After clicking on the link today, It worked successfully. If anyone else experience this issue in the future, do not forget to delete OpenCart's cache files.

Upvotes: 2

Related Questions