-
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #12 from n1crack/v2
V2 release
- Loading branch information
Showing
42 changed files
with
1,352 additions
and
1,743 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
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,22 +1,28 @@ | ||
<?php | ||
|
||
return [ | ||
use Ozdemir\Aurora\Cart; | ||
use Ozdemir\Aurora\Generators\GenerateChecksum; | ||
use Ozdemir\Aurora\Generators\GenerateSessionKey; | ||
use Ozdemir\Aurora\Storages\SessionStorage; | ||
|
||
return [ | ||
'instance' => 'cart', | ||
|
||
'storage' => \Ozdemir\Aurora\Storage\SessionStorage::class, | ||
'cart_class' => Cart::class, | ||
|
||
'cart_class' => \Ozdemir\Aurora\Cart::class, | ||
'storage' => SessionStorage::class, | ||
|
||
'cart_item' => \Ozdemir\Aurora\CartItem::class, | ||
'cache_store' => env('CART_STORE', config('cache.default')), | ||
|
||
'cache_store' => config('cache.default'), | ||
'monetary' => [ | ||
'precision' => env('CART_CURRENCY_PRECISION', 2), | ||
], | ||
|
||
'precision' => 2, | ||
'session_key_generator' => GenerateSessionKey::class, | ||
|
||
'condition_order' => [ | ||
'cart' => ['discount', 'other', 'shipping', 'coupon', 'tax'], | ||
'item' => ['discount', 'other', 'shipping', 'coupon', 'tax'], | ||
], | ||
'checksum_generator' => GenerateChecksum::class, | ||
|
||
'calculate_using' => [ | ||
// | ||
] | ||
]; |
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,25 @@ | ||
<?php | ||
|
||
namespace Ozdemir\Aurora; | ||
|
||
class CalculationResult | ||
{ | ||
protected float $total; | ||
protected mixed $breakdowns; | ||
|
||
public function __construct($total, $breakdowns) | ||
{ | ||
$this->total = $total; | ||
$this->breakdowns = $breakdowns; | ||
} | ||
|
||
public function total(): float | ||
{ | ||
return $this->total; | ||
} | ||
|
||
public function breakdowns(): mixed | ||
{ | ||
return $this->breakdowns; | ||
} | ||
} |
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,41 @@ | ||
<?php | ||
|
||
namespace Ozdemir\Aurora; | ||
|
||
use Illuminate\Support\Collection; | ||
|
||
class Calculator | ||
{ | ||
public ?string $skip = null; | ||
|
||
private Collection $calculators; | ||
|
||
public function __construct() | ||
{ | ||
$this->calculators = new Collection(config('cart.calculate_using')); | ||
} | ||
|
||
public function calculators(): Collection | ||
{ | ||
return $this->calculators; | ||
} | ||
|
||
public function calculate($price, $calculations = []) | ||
{ | ||
return resolve('pipeline') | ||
->send([$price, []]) | ||
->through(collect($calculations)->reject(fn ($calculation) => $calculation === $this->skip)->toArray()) | ||
->thenReturn(); | ||
} | ||
|
||
public function skip($class, $callback): mixed | ||
{ | ||
$this->skip = is_string($class) ? $class : get_class($class); | ||
|
||
$value = $callback(); | ||
|
||
$this->skip = null; | ||
|
||
return $value; | ||
} | ||
} |
Oops, something went wrong.