Laravel E-Commerce – Coupons & Discounts – Part 6

Share it with your friends Like

Thanks! Share it with your friends!


In this video, we add the ability to use coupons and coupon codes for discounts. We implement fixed value coupons and percent off coupons in our database. We then make sure that the appropriate discounts are being passed through correctly to Stripe.

5:13 – Note: I re-seeded the database so the price of the item in the cart changed, which may cause confusion in the rest of the video.

10:58 – You can see the item price and the Subtotal are not the same (they should be). This continues throughout the entire video. Sorry! I caught it after I finished recording. I should have cleared the cart contents after I re-seeded the database.

Pushing Polymorphism to the Database:

GitHub repo:

Polymorphic Relations:

Coupon Code in cart or checkout:

How to handle money in web apps:

Sign up for my newsletter:
My website:


David Gonzalez says:

Perhaps this is gonna be the silliest question but I can't make that the presentPrice function in helpers.php be taken in count when I run the serve throwing the following error:

Call to undefined function presentPrice() (View: C:xampphtdocsnuevoresourcesviewscheckout.blade.php)

Is there a step I may have missed about calling it or declaring it somewhere?

If it's not trouble there's also another error:

A non well formed numeric value encountered

referring to:

$newSubtotal = (Cart::subtotal() – $discount);

on CheckoutController

Thank you in advance!!

vcmattsucr says:

So, there's an issue here. If you have multiple items in the cart and apply a discount, then things are great. BUT, if after applying the discount you remove an item, then the discount, new subtotal, etc. do not update accordingly. Any thoughts on this and how to fix it?

brindha brindha says:

your awsome bro thank you

La Chaparrita Azteca says:

what do we want to have happen… im not gonna forget that lol

John Ferrie Vivo says:

Hey Andre, I have noticed that when you add items to the cart and put 50% discount coupon, the discount was applied, but when I add another items to the cart, the 50% discount coupon is not updating based on the price of all items in the cart. The coupon is only applied to the items you put the coupon discount before.

John Ferrie Vivo says:

I am encountering A non well formed numeric value encountered error in $newSubtotal = (Cart::subtotal() – $discount); in the CheckoutController.

I did diedump Cart::subtotal() and it shows a price but with a quotation that's why i can't perform subtraction with the newsubtotal. How to solve this?

Jose Luis Garcia says:

Do you plan to integrate the user registration and login to complete the purchase?

Minhy Nguyen says:

This videos is very useful!!! I hope you will make a videos about reservation in a restaurant with a
certain time such as 1 hour, 30 minutes or 1 day. Thank You So Much!!!!

Milan Janković says:

This function money_format() don't work on Windows systems so anyone who get fatal error while execute code , use instead number_format() function .

vcmattsucr says:

Andre, I sent you an email (via your website) about a potential project. What's your usual response time? Thank you! Also going through these videos and think they're great!

Jose Luis Garcia says:

excellent video. It could be implemented that single coupon is valid when you purchase a SKU or a specific category. appreciate you it enough

Łukasz P says:

Hello there! Great tutorial! Which plug-ins, theme do you use for this project in the VS Code?

Write a comment