realrashid / cart

Meet Cart — your seamless solution for efficient shopping cart management in Laravel. Simplifying everything from product additions to total calculations, Cart ensures a frictionless user experience for e-commerce applications.
https://realrashid.github.io/cart/
MIT License
84 stars 5 forks source link

[Bug]: Percentage Discount Calculation and Cart::total() Returning 0.00 #7

Closed ash4sv closed 1 week ago

ash4sv commented 3 weeks ago

What happened?

When applying a percentage-based discount using the RealRashid Cart package, the Cart::total() method incorrectly returns 0.00 instead of the expected discounted total. This issue does not occur with fixed amount discounts, which suggests a bug in how the package handles percentage discounts.fixed-amount

How to reproduce the bug

Steps to Reproduce:

  1. Setup:

    • Use the RealRashid Cart package in a Laravel project.
    • Create a cart with items totaling a non-zero amount (e.g., 1800).
  2. Create a Percentage Coupon:

    • Define a percentage-based discount (e.g., 80%).
  3. Apply the Coupon:

    • Apply the percentage coupon to the cart.
  4. Check the Total:

    • After applying the coupon, call Cart::total() to retrieve the cart's total.

Package Version

1.0

PHP Version

PHP 8.3.10

Laravel Version

10.48

Which operating systems does with happen with?

macOS

Notes

No response

realrashid commented 3 weeks ago

I will look into this.

masoudalmashay commented 2 weeks ago

I tested it with percentage-based discounts, and everything seems to be working fine on my end. It might be worth checking your code implementation to ensure the discount is applied correctly. If the issue persists, it could be helpful to share more details

realrashid commented 2 weeks ago

Hello @ash4sv,

I've checked, and everything is working perfectly as expected. If possible, could you please share the code? I'd love to take a look and learn more from it.

Thank you! 😊

realrashid commented 1 week ago

Closing this issue due to inactivity.