Totals API - Showing Bundle totals and discounts on your theme

This Javascript API will retrieve from our app the Bundle totals and discounts, the response includes the totals for the entire shopping cart and per each variant. 

Here is how you can use the Totals API:

window.RevyBundle.api.getTotal(response => {
	console.log(response)
})

The API response will be an object like this:

{
	bundleTotal: (bundle totals object)
	originalCart: (shopify cart object)
}

Response example:

{
  "bundleTotal": {
    "final": 32800,
    "original": 40000,
    "discount": 7200,
    "formatted": {
      "final": "$328.00",
      "original": "$400.00",
      "discount": "$72.00"
    },
    "per_variant": [
      {
        "final": 3280,
        "discount": 720,
        "unit_price": 4000,
        "original": 4000,
        "variant_id": 32039244693559,
        "quantity": 1,
        "formatted": {
          "final": "$32.80",
          "original": "$40.00",
          "discount": "$7.20"
        }
      },
      {
        "final": 6560,
        "discount": 1440,
        "unit_price": 4000,
        "original": 8000,
        "variant_id": 320392446280213,
        "quantity": 2,
        "formatted": {
          "final": "$65.60",
          "original": "$80.00",
          "discount": "$14.40"
        }
      },
      {
        "final": 6560,
        "discount": 1440,
        "unit_price": 4000,
        "original": 8000,
        "variant_id": 320392445925255,
        "quantity": 2,
        "formatted": {
          "final": "$65.60",
          "original": "$80.00",
          "discount": "$14.40"
        }
      },
      {
        "final": 16400,
        "discount": 3600,
        "unit_price": 4000,
        "original": 20000,
        "variant_id": 320392445362487,
        "quantity": 5,
        "formatted": {
          "final": "$164.00",
          "original": "$200.00",
          "discount": "$36.00"
        }
      }
    ]
  },
  "originalCart": {
    "token": "e6f36225c2adbe164d7f837368fac90b",
    "note": null,
    "attributes": {
      "revy_bundle_add": "65526",
      "Refersion ID": "2f4087dadab3710a0bb8beb34842ce4e"
    },
    "original_total_price": 40000,
    "total_price": 40000,
    "total_discount": 0,
    "total_weight": 10000,
    "item_count": 10,
    "items": [
      {
        "id": 32039244693559,
        "properties": {},
        "quantity": 1,
        "variant_id": 32039244693559,
        "key": "32039244693559:f6cdfeb20a770d9bdfdf33ef71e94294",
        "title": "Product A",
        "price": 4000,
        "original_price": 4000,
        "discounted_price": 4000,
        "line_price": 4000,
        "original_line_price": 4000,
        "total_discount": 0,
        "discounts": [],
        "sku": "XXX",
        "grams": 1000,
        "vendor": "Vendor A",
        "taxable": true,
        "product_id": 45469179921975,
        "product_has_only_default_variant": false,
        "gift_card": false,
        "final_price": 4000,
        "final_line_price": 4000,
        "url": "/products/product-a?variant=320392344693559",
        "featured_image": {
          "aspect_ratio": 1,
          "alt": "Product A",
          "height": 600,
          "url": "https://cdn.shopify.com/s/files/1/0268/9279/5959/products/product-a.jpg?v=1595831962",
          "width": 600
        },
        "image": "https://cdn.shopify.com/s/files/1/0268/9279/5959/products/product-a.jpg?v=1595831962",
        "handle": "product-a",
        "requires_shipping": true,
        "product_type": "Protein Powder",
        "product_title": "Product A",
        "product_description": "Product Description",
        "variant_title": "Default",
        "variant_options": [
          "Default"
        ],
        "options_with_values": [
          {
            "name": "Types",
            "value": "Default"
          }
        ],
        "line_level_discount_allocations": [],
        "line_level_total_discount": 0
      },
      {
        "id": 32039244628023,
        "properties": {},
        "quantity": 2,
        "variant_id": 32039244628023,
        "key": "32039244628023:bc2cdee57c01962759398b595143aff6",
        "title": "Product B",
        "price": 4000,
        "original_price": 4000,
        "discounted_price": 4000,
        "line_price": 8000,
        "original_line_price": 8000,
        "total_discount": 0,
        "discounts": [],
        "sku": "XXX",
        "grams": 1000,
        "vendor": "Vendor B",
        "taxable": true,
        "product_id": 4546979921975,
        "product_has_only_default_variant": false,
        "gift_card": false,
        "final_price": 4000,
        "final_line_price": 8000,
        "url": "/products/product-b?variant=32039244628023",
        "featured_image": {
          "aspect_ratio": 1,
          "alt": "Product B",
          "height": 600,
          "url": "https://cdn.shopify.com/s/files/1/0268/9279/5959/products/product-b.jpg?v=1595831917",
          "width": 600
        },
        "image": "https://cdn.shopify.com/s/files/1/0268/9279/5959/products/product-b.jpg?v=1595831917",
        "handle": "product-b",
        "requires_shipping": true,
        "product_type": "B",
        "product_title": "Product B",
        "product_description": "Product description",
        "variant_title": "Default",
        "variant_options": [
          "Default"
        ],
        "options_with_values": [
          {
            "name": "Types",
            "value": "Default"
          }
        ],
        "line_level_discount_allocations": [],
        "line_level_total_discount": 0
      },
      {
        "id": 32039244595255,
        "properties": {},
        "quantity": 2,
        "variant_id": 320392445952355,
        "key": "32039244595255:fbfbffd9d71271f6dc0cfdbaf62b6769",
        "title": "Product C",
        "price": 4000,
        "original_price": 4000,
        "discounted_price": 4000,
        "line_price": 8000,
        "original_line_price": 8000,
        "total_discount": 0,
        "discounts": [],
        "sku": "XXX",
        "grams": 1000,
        "vendor": "Vendor C",
        "taxable": true,
        "product_id": 45469739921975,
        "product_has_only_default_variant": false,
        "gift_card": false,
        "final_price": 4000,
        "final_line_price": 8000,
        "url": "/products/product-c?variant=32039244595255",
        "featured_image": {
          "aspect_ratio": 1,
          "alt": "Product C",
          "height": 600,
          "url": "https://cdn.shopify.com/s/files/1/0268/9279/5959/products/product-c.jpg?v=1595831890",
          "width": 600
        },
        "image": "https://cdn.shopify.com/s/files/1/0268/9279/5959/products/product-c.jpg?v=1595831890",
        "handle": "product-c",
        "requires_shipping": true,
        "product_type": "Default",
        "product_title": "Product C",
        "product_description": "Product Description",
        "variant_title": "Default",
        "variant_options": [
          "Default"
        ],
        "options_with_values": [
          {
            "name": "Typees",
            "value": "Default"
          }
        ],
        "line_level_discount_allocations": [],
        "line_level_total_discount": 0
      },
      {
        "id": 320392445624871,
        "properties": {},
        "quantity": 5,
        "variant_id": 320392445624871,
        "key": "32039244562487:342b7ef236ba6eba55bfe9ac224da9f2",
        "title": "Product D",
        "price": 4000,
        "original_price": 4000,
        "discounted_price": 4000,
        "line_price": 20000,
        "original_line_price": 20000,
        "total_discount": 0,
        "discounts": [],
        "sku": "XXX",
        "grams": 1000,
        "vendor": "Vendor D",
        "taxable": true,
        "product_id": 45469799219754,
        "product_has_only_default_variant": false,
        "gift_card": false,
        "final_price": 4000,
        "final_line_price": 20000,
        "url": "/products/product-d?variant=32039244562487",
        "featured_image": {
          "aspect_ratio": 1,
          "alt": "Product D",
          "height": 600,
          "url": "https://cdn.shopify.com/s/files/1/0268/9279/5959/products/product-d.jpg?v=1595831862",
          "width": 600
        },
        "image": "https://cdn.shopify.com/s/files/1/0268/9279/5959/products/product-d.jpg?v=1595831862",
        "handle": "product-d",
        "requires_shipping": true,
        "product_type": "Product Type",
        "product_title": "Product D",
        "product_description": "Product Description",
        "variant_title": "Default",
        "variant_options": [
          "default"
        ],
        "options_with_values": [
          {
            "name": "Types",
            "value": "Default"
          }
        ],
        "line_level_discount_allocations": [],
        "line_level_total_discount": 0
      }
    ],
    "requires_shipping": true,
    "currency": "AUD",
    "items_subtotal_price": 40000,
    "cart_level_discount_applications": []
  }
}

For questions or feedback please contact us at [email protected].

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us