mirror of
https://github.com/wearepixel/laravel-cart.git
synced 2026-11-14 13:51:44 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b3ef4c38fc | ||
|
|
a45121ca63 | ||
|
|
5505f121c7 |
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "wearepixel/laravel-cart",
|
||||
"version": "1.0.10",
|
||||
"version": "1.0.11",
|
||||
"description": "A cart implementation for Laravel",
|
||||
"keywords": [
|
||||
"laravel",
|
||||
|
||||
+6
-5
@@ -458,9 +458,6 @@ public function removeItemCondition($itemId, $conditionName)
|
||||
}
|
||||
}
|
||||
|
||||
// reset indexes
|
||||
$item['conditions'] = array_values($item['conditions']);
|
||||
|
||||
$this->update($itemId, [
|
||||
'conditions' => $item['conditions'],
|
||||
]);
|
||||
@@ -601,10 +598,14 @@ public function getTotal(): int|float
|
||||
return Helpers::formatValue($subTotal, $this->config['format_numbers'], $this->config);
|
||||
}
|
||||
|
||||
$conditionsForTotal->each(function (CartCondition $condition) use ($subTotal, &$total) {
|
||||
$toBeCalculated = $total > 0 ? $total : $subTotal;
|
||||
$index = 0;
|
||||
|
||||
$conditionsForTotal->each(function (CartCondition $condition) use ($subTotal, &$total, &$index) {
|
||||
$toBeCalculated = ($index > 0) ? $total : $subTotal;
|
||||
|
||||
$total = $condition->applyCondition($toBeCalculated);
|
||||
|
||||
$index++;
|
||||
});
|
||||
|
||||
return Helpers::formatValue($total, $this->config['format_numbers'], $this->config);
|
||||
|
||||
@@ -1310,7 +1310,7 @@
|
||||
|
||||
// now we should have only 1 condition left on that item
|
||||
expect($this->cart->get(1)['conditions'])->toHaveCount(1, 'Item should have one condition left');
|
||||
expect($this->cart->get(1)['conditions'][0]->getName())->toEqual('Mother\'s Day Gift Pack');
|
||||
expect($this->cart->get(1)['conditions'][1]->getName())->toEqual('Mother\'s Day Gift Pack');
|
||||
});
|
||||
|
||||
test('can add item with multiple negative item conditions', function () {
|
||||
|
||||
Reference in New Issue
Block a user