mirror of
https://github.com/wearepixel/laravel-cart.git
synced 2026-11-14 22:01:48 +00:00
code cleanup
This commit is contained in:
+8
-14
@@ -3,34 +3,28 @@
|
|||||||
return [
|
return [
|
||||||
/*
|
/*
|
||||||
* ---------------------------------------------------------------
|
* ---------------------------------------------------------------
|
||||||
* formatting
|
* Formatting
|
||||||
* ---------------------------------------------------------------
|
* ---------------------------------------------------------------
|
||||||
*
|
|
||||||
* the formatting of shopping cart values
|
|
||||||
*/
|
*/
|
||||||
'format_numbers' => env('SHOPPING_FORMAT_VALUES', false),
|
'format_numbers' => env('LARAVEL_CART_FORMAT_VALUES', false),
|
||||||
|
|
||||||
'decimals' => env('SHOPPING_DECIMALS', 0),
|
'decimals' => env('LARAVEL_CART_DECIMALS', 0),
|
||||||
|
|
||||||
'dec_point' => env('SHOPPING_DEC_POINT', '.'),
|
'dec_point' => env('LARAVEL_CART_DEC_POINT', '.'),
|
||||||
|
|
||||||
'thousands_sep' => env('SHOPPING_THOUSANDS_SEP', ','),
|
'thousands_sep' => env('LARAVEL_CART_THOUSANDS_SEP', ','),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ---------------------------------------------------------------
|
* ---------------------------------------------------------------
|
||||||
* persistence
|
* Persistence
|
||||||
* ---------------------------------------------------------------
|
* ---------------------------------------------------------------
|
||||||
*
|
|
||||||
* the configuration for persisting cart
|
|
||||||
*/
|
*/
|
||||||
'storage' => null,
|
'storage' => null,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ---------------------------------------------------------------
|
* ---------------------------------------------------------------
|
||||||
* events
|
* Events
|
||||||
* ---------------------------------------------------------------
|
* ---------------------------------------------------------------
|
||||||
*
|
|
||||||
* the configuration for cart events
|
|
||||||
*/
|
*/
|
||||||
'events' => null,
|
'events' => null,
|
||||||
];
|
];
|
||||||
|
|||||||
+1
-1
@@ -569,7 +569,7 @@ public function getSubTotalWithoutConditions($formatted = true)
|
|||||||
*
|
*
|
||||||
* @param bool $formatted
|
* @param bool $formatted
|
||||||
*/
|
*/
|
||||||
public function getSubTotal($formatted = true): int|float
|
public function getSubTotal($formatted = true): int|float|string
|
||||||
{
|
{
|
||||||
$subTotal = 0.00;
|
$subTotal = 0.00;
|
||||||
// add all the items together with conditions applied
|
// add all the items together with conditions applied
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public function getAttributes()
|
|||||||
/**
|
/**
|
||||||
* the value of this the condition
|
* the value of this the condition
|
||||||
*/
|
*/
|
||||||
public function getValue(): int|float
|
public function getValue(): int|float|string
|
||||||
{
|
{
|
||||||
return $this->args['value'];
|
return $this->args['value'];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public static function formatValue($value, $formatNumber, $config)
|
|||||||
if ($formatNumber || $config['format_numbers']) {
|
if ($formatNumber || $config['format_numbers']) {
|
||||||
return floatval(number_format($value, $config['decimals'], $config['dec_point'], $config['thousands_sep']));
|
return floatval(number_format($value, $config['decimals'], $config['dec_point'], $config['thousands_sep']));
|
||||||
} else {
|
} else {
|
||||||
return $value;
|
return floatval($value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -790,7 +790,7 @@
|
|||||||
expect($this->cart->getCalculatedValueForCondition('Gift Card'))->toEqual(0, 'Gift Card should be 0');
|
expect($this->cart->getCalculatedValueForCondition('Gift Card'))->toEqual(0, 'Gift Card should be 0');
|
||||||
expect($couponDiscount->getCalculatedValue())->toEqual(200.0, 'Coupon Discount value should be 200.0');
|
expect($couponDiscount->getCalculatedValue())->toEqual(200.0, 'Coupon Discount value should be 200.0');
|
||||||
expect($giftCard->getCalculatedValue())->toEqual(0, 'Gift Card value should be 0');
|
expect($giftCard->getCalculatedValue())->toEqual(0, 'Gift Card value should be 0');
|
||||||
})->only();
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('item level conditions', function () {
|
describe('item level conditions', function () {
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
expect($this->cart->getContent()->count())->toEqual(1, 'Cart content should be 1');
|
expect($this->cart->getContent()->count())->toEqual(1, 'Cart content should be 1');
|
||||||
expect($this->cart->getContent()->first()['id'])->toEqual(1, 'Item added has ID of 1 so first content ID should be 1');
|
expect($this->cart->getContent()->first()['id'])->toEqual(1, 'Item added has ID of 1 so first content ID should be 1');
|
||||||
expect($this->cart->getContent()->first()['price'])->toEqual(10099, 'Item added has price of 100.99 so first content price should be 100.99');
|
expect($this->cart->getContent()->first()['price'])->toEqual(10099, 'Item added has price of 100.99 so first content price should be 100.99');
|
||||||
})->only();
|
});
|
||||||
|
|
||||||
test('can add an item with no price', function () {
|
test('can add an item with no price', function () {
|
||||||
$this->cart->add(455, 'Sample Item', 0, 2, []);
|
$this->cart->add(455, 'Sample Item', 0, 2, []);
|
||||||
|
|||||||
Reference in New Issue
Block a user