shekwo
shekwo

Reputation: 1447

How to override Shopping Cart total in Laravel 5

I am using gloudemans package to build a shopping cart. How do I override Cart::total() so it can output a different value if a user enters a coupon?

For example,

Cart::total() = 200;
$coupon = 20;
Cart::total() = 180;

Upvotes: 0

Views: 1273

Answers (2)

Md Zahid
Md Zahid

Reputation: 1162

Run this command for getting cart.php file in your config/cart.php

php artisan vendor: publish --provider="Gloudemans\Shoppingcart\ShoppingcartServiceProvider" --tag="config"

after that you will get this file you have to update the tax amount from cart.php file like this

Before enter image description here

After enter image description here

and after update you need to do clear your cart and add cart item to your cart page

Upvotes: 2

Hamidreza Ghanbari
Hamidreza Ghanbari

Reputation: 307

if you use total method laravel shopping cart add tax to real total of prices just use Cart::subtotal() to get real to total of prices without adding tax to it.

Upvotes: 0

Related Questions