wojodesign / simplecart-js

A simple javascript shopping cart that easily integrates with your current website.
simplecartjs.org
1.79k stars 492 forks source link

Display grand Total to Input value Field (Hidden) #486

Open bonucci opened 9 years ago

bonucci commented 9 years ago

Hello there, im trying to display the total price in a input field, does anybody no how to do that?

irsah commented 9 years ago

Coming in late but hope this will help somebody.. think there's plenty of examples here...

<input type="text" id="show-total" val="" />

<script>
simpleCart.ready(function(){
    var total = simpleCart.total(); // grabs the total in a var
    $("#show-total").val(total); // assign the total as the new input value
});
</script>

Edit Use below to get the grand total in cart...

<script>
simpleCart.ready(function(){
    var grandTotal = simpleCart.grandTotal(); // grabs the grand total in a var
    $("#show-total").val(grandTotal); // assign the grand total as the new input value
});
</script>
zacrose14 commented 6 years ago

Does this part work for anyone else?