Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Safemood/class-based-conditions
added Class-Based Conditions
- Loading branch information
Showing
15 changed files
with
180 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
<?php | ||
|
||
return [ | ||
'global_discount' => 0, | ||
'global_tax_rate' => 0, | ||
'condition_namespace' => 'App\\Conditions', | ||
'condition_path' => app_path('Conditions'), | ||
'fields' => [ | ||
'quantity' => 'quantity', | ||
'price' => 'price', | ||
'quantity' => 'quantity', | ||
], | ||
'global_discount' => 0, | ||
'global_tax_rate' => 0, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,4 @@ return new class extends Migration | |
$table->timestamps(); | ||
}); | ||
} | ||
}; | ||
}; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Safemood\Discountify\Contracts; | ||
|
||
interface ConditionInterface | ||
{ | ||
/** | ||
* Invoke the condition logic. | ||
*/ | ||
public function __invoke(array $items): bool; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace Workbench\App\Conditions; | ||
|
||
use Safemood\Discountify\Contracts\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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace Workbench\App\Conditions; | ||
|
||
use Safemood\Discountify\Contracts\ConditionInterface; | ||
|
||
class SpecialTypeProductCondition implements ConditionInterface | ||
{ | ||
public string $slug = 'special_type_product_40'; | ||
|
||
public int $discount = 40; | ||
|
||
public function __invoke(array $items): bool | ||
{ | ||
return in_array('special', array_column($items, 'type')); | ||
} | ||
} |