How can I retrieve the 'total_price' from a json cart?

How can I retrieve the 'total_price' from a json cart?

flyfire_09
Tourist
10 0 1

Hi! Please help me. I'm trying to get 'total_price' after added first item to cart, json has the next:

  1. attributes: {}
  2. cart_level_discount_applications: []
  3. currency: "EUR"
  4. item_count: 0
  5. items: []
  6. items_subtotal_price: 0
  7. note: null
  8. original_total_price: 0
  9. requires_shipping: false
  10. token: "80ad0c6559873f2d3bafe42695677b25"
  11. total_discount: 0
  12. total_price: 0
  13. total_weight: 0

 

 

 

 

 const cartJson = '/cart.js';
  async function getCartJson() {
    
    fetch(cartJson).then((res) => {
        return res.json();
      }).then((data) => {
        let x = 0;
        for (i in data.items) {
        x += data.items[i].total_price;     
        }
        console.log(x);

      });
    
  }

 

btw request cart/add has "final_price: 100" - can I get this?

Reply 1 (1)

flyfire_09
Tourist
10 0 1

I done it
sorry