Hi,
There are 3 things:
1. First, you need to add your javascript code on your pages. How to add that code to your website depends on what you're trying to do. There are many ways to go about it.
For example, this page presents several of them:
www.infyways.com/add-custom-javascript-to-joomla/
I would rather recommend this:
www.joomlashack.com/blog/joomla/custom-js/
2. Now that you know how to add javascript to your Joomla website, you want to know how your javascript code can be called when the cart is updated.
The documentation about javascript events actually starts with explanations on how to do it:
www.hikashop.com/support/documentation/6...ocumentation.html#js
So, as explained there, you would want to have something like this in your javascript code:
if(window.Oby) {
window.Oby.registerAjax(["cart.updated"],function(params){
// ... your javascript code ...
});
}
3. Then, you want to know how to get the total value of products in the cart.
As explained in the documentation you're pointing at, you have an array of product objects in params.resp.products
There, you have access to product_id which provides you with the id of the product and quantity which provides you with the quantity of the product in the cart.
You have two ways to go about it:
- you could create a plugin following :
webkul.com/blog/ajax-call-from-plugins-and-modules-in-joomla/
and in your javascript, use the JS code there to call your plugin to retrieve the information on the product price, or even the cart total amount.
- but I would recommend implementing instead the onGetCartProductsInfo event of the Cart API:
www.hikashop.com/support/documentation/6...nGetCartProductsInfo
With it, you'll be able to directly add extra data about the cart, like the total amount, in params.resp