orderTotal = document.getElementById('order-total'), currentTotal = parseFloat(orderTotal.innerHTML); orderTotal.innerHTML = currentTotal + cost; }; PubSub.subscribe('checkout.item', function(msg, item) { updateOrderTotal(item.quantity * item.cost); }); PubSub.subscribe('checkout.delivery-cost', function(msg, deliveryCost) { updateOrderTotal(deliveryCost); }); };