wojodesign / simplecart-js

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

show prices including tax #234

Closed swfredrik closed 12 years ago

swfredrik commented 12 years ago

I want to show item_price including tax in the simpleCart_shelfItem

Then in my cart I need some new variables like:

simpleCart_total_without_tax simpleCart_grandTotal_without_tax

An example with tax_rate= 0.25: item_price = 1000 simpleCart_tax = 200 simpleCart_grandTotal = 1000

brettwejrowski commented 12 years ago

what version are you using?

swfredrik commented 12 years ago

V3 latest

3 maj 2012 kl. 06:46 skrev brettwejrowskireply@reply.github.com:

what version are you using?


Reply to this email directly or view it on GitHub: https://github.com/wojodesign/simplecart-js/issues/234#issuecomment-5480923

brettwejrowski commented 12 years ago

Awesome! You can bind your own custom outputs like this:


// run on .ready() so we make sure simpleCart is ready:
simpleCart.ready(function(){

  simpleCart.bindOutlets({
    // create selector that goes after the "simpleCart_"
    "grandTotal_without_tax": {
      callback: function () {
        // return currency formatted grand total - tax
        return simpleCart.toCurrency( simpleCart.grandTotal() - simpleCart.tax() );
      }
    }
  });

});
brettwejrowski commented 12 years ago

actually @swfredrik I just just updated the latest v3 to remove the 'callback' keyword for simplicity, so you would instead use:


simpleCart.ready(function(){

  simpleCart.bindOutlets({
    // create selector that goes after the "simpleCart_"
    "grandTotal_without_tax": function () {
      // return currency formatted grand total - tax
      return simpleCart.toCurrency( simpleCart.grandTotal() - simpleCart.tax() );
    }
  });

});
swfredrik commented 12 years ago

Thanks a bunch!! Really simple and flexible shoppingcart, I really love it :)