happypixels / laravel-shopr

A developer-friendly e-commerce foundation for your Laravel app
https://laravel-shopr.happypixels.se
MIT License
208 stars 19 forks source link

Discount coupons #6

Closed mattias-persson closed 5 years ago

mattias-persson commented 5 years ago

A highly requested feature which I've wanted to implement since the beginning of Shopr is Discount coupons. This issue will serve as a gathering place for checklists and discussions for this feature.

Database structure I figure we'll add another table and model to the package. I thought about letting each user build their own database design, but eventually landed in the fact that this package is meant to make it as easy as possible to get started with a web shop, while still allowing for flexibility. Most projects won't need to modify the discount functionality or design if we just think it through, and so they shouldn't have to think about how to structure their discount table.

Validation Some projects may need the ability to add custom validation to make sure the applied discount code is valid according to rules beyond a timestamp, code validation and other default rules. We need to make this easily configurable and modifiable.

Todo

mattias-persson commented 5 years ago

One idea on the validation is to provide each rule separately in the configuration file, with the most common rules built in. That way anyone could add or remove rules as they'd like. Something like this:

'discount_coupons' => [
    'validation_rules' => [
        Happypixels\Shopr\Rules\Cart\CartNotEmpty::class,
        Happypixels\Shopr\Rules\Discounts\OnlyOneCouponPerOrder::class,        
        Happypixels\Shopr\Rules\Discounts\CouponHasNotBeenApplied::class,
        Happypixels\Shopr\Rules\Discounts\CouponExists::class,
        Happypixels\Shopr\Rules\Discounts\DateIsWithinCouponTimespan::class,
    ]
]
mattias-persson commented 5 years ago

Resolved in release 1.1.