Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added Class-Based Conditions #3

Merged
merged 1 commit into from
Jan 21, 2024
Merged

added Class-Based Conditions #3

merged 1 commit into from
Jan 21, 2024

Conversation

Safemood
Copy link
Owner

Description

This pull request introduces a new feature to Discountify - Class-Based Conditions. This enhancement empowers users to define more sophisticated discount strategies by encapsulating custom logic within dedicated classes.

Changes Made

  • Feature: Added support for Class-Based Conditions in the discount application process.
  • Implementation: Introduced a flexible mechanism for users to create their own discount strategies by defining classes.
  • Auto-Discovery: Classes placed under the App\Conditions namespace or within the app/conditions directory will be automatically discovered and available for use.

Usage Example

use App\Conditions\ConditionInterface;

class MoreThan1ProductsCondition implements ConditionInterface
{
    public string $slug = 'more_than_1_products_10';

    public int $discount = 10;

    public function __invoke(array $items): bool
    {
        return count($items) > 1;
    }
}

@Safemood Safemood merged commit 4cf8e65 into main Jan 21, 2024
7 checks passed
@Safemood Safemood deleted the class-based-conditions branch January 21, 2024 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant