// Widget.js
// Pricing Widget
//
// Created by Tim Samson on 8/8/24.
//
const storeId = '846';
const productId = '16572';
const token = 'c8391bbe0e060ed51037a2452417a1d778a94de83a9138d816380a6e6699c354';
const retail = '500.00'
const apiUrl = `https://moreyspiers.ltibooking.com/v1.2/products/${productId}?store_id=${storeId}`;
var discount = 'retail'-'price'
var discountPercent = "'Discount'/'retail'×100"
const fetchTicketInfo = async () => {
try {
const response = await fetch(apiUrl, {
method: 'GET',
headers: {
'Accept': 'application/json',
'Authorization': `Bearer ${token}`,
'Accept-Language': 'en'
}
});
if (!response.ok) {
throw new Error('Network response was not ok ' + response.statusText);
}
const data = await response.json();
const ticket = data.dated_ticket_types[0].days[0].ticket;
document.getElementById('price').textContent = `Price: ${ticket.price} ${ticket.currency}`;
document.getElementById('quantity').textContent = `Tickets Remaining: ${ticket.quantity_available}`;
} catch (error) {
console.error('There was a problem with the fetch operation:', error);
}
};
document.addEventListener('DOMContentLoaded', fetchTicketInfo);
top of page
bottom of page