'Shopify checkout dynamic generated html class?
I'm reaching the checkout for getting the final price to pay :
let checkout = await fetch("/checkout/");
checkout = await checkout.text();
let total_price = checkout.match(
/<dl class="order-summary-toggle(.*?)<\/dl>/gim
);
The problem is i noticed on some store checkout page got dynamic generated class, and i dont know why and cant reproduce?
Is someone know why is it happening ? or if there is an better way to get the checkout final price ?
Solution 1:[1]
The html will not be complete because is dynimically created with Javascript.
If you are using liquid the total price can be accessed with {{cart.total_price}}.
If not, and you want to use the cartjs api you can call /cart.js and use the field "total_price"
$.ajax({
type: 'GET',
url: '/cart.js',
dataType: 'json',
success: function (data) {
alert("Your total is: "+data.total_price);
},
error: function () {
}
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Fabio Filippi |
