LaravelShoppingcart
LaravelShoppingcart copied to clipboard
Tax Customization
Sir I wanna ask you one thing , how to customize the tax value
This can be set in config/cart.php
.
See here for an example file - https://github.com/Crinsane/LaravelShoppingcart/blob/master/config/cart.php
I think the question is how to customize the tax for each product this in the config will add default tax for all the products, what if each product has it's own tax?
+1 I would like support for adding both taxable and non-taxable items to the same cart.
publishing the config file and editing the value doesn't seem to override the package config file's value
+1 I would like support for different tax per product Edit: Found somthing really usefull. https://github.com/Crinsane/LaravelShoppingcart/wiki/Adding-new-tax-to-cart-item This worked for me.
@jelmerbou Thanks , I was looking for the same , just want to ask if you know while looping all products in car.blade.php how do i display tax of each rowId i.e each product tax , is there any method defined for this
@jelmerbou Thanks , I was looking for the same , just want to ask if you know while looping all products in car.blade.php how do i display tax of each rowId i.e each product tax , is there any method defined for this
You can find all available methods in the Cart.php and CartItem.php. There are just methods for the tax as an amount of money, not percentage. You have to re-calculate that percentage yourself or get it from where you got it in the first place since there is no way to access the private taxRate. You can fork this repository and add the functionality yourself or provide a PR to one of the many forks. I might add it to mine.
@bumbummen99 Yeah Thanks For The Suggestions .
@shanks25 It is now in my fork, you can look at the referenced commit to find out how to get the desired behavior but to keep things simple i basically changed $taxRate to be a public member. You just have to remember to use setTaxRate()
instead of direct access for chaining method calls as setTaxRate()
will return $this.