Commit ecdfaaa2 authored by Thorsten Buss's avatar Thorsten Buss

rename undependend to independend

parent 2bd1fc70
......@@ -81,6 +81,7 @@ Cart::add(array(
'name' => 'Sample Item 1',
'price' => 67.99,
'quantity' => 4,
'quantity_independent' => true, // only one for item, not multiply with quantity
'attributes' => array()
),
array(
......@@ -703,6 +704,14 @@ $items->each(function($item)
## Changelogs
**3.1.3
- add attributes to cart
- change condition calcuation behaviour
- add Condition attribute "quantity_independent" to calculate the condition only once per item, not multiply with the quantity
**3.1.2
- add __isset() to the __get() function
**3.1.1
- cart is completly "Arrayable"
- condition target is optional and subtotal is changed to cart
......
......@@ -99,8 +99,8 @@ class Condition extends Collection {
/**
* should the amount be multiplied by the item quantity
*/
public function getQuantityUndepended() {
return $this->get('quantity_undepended', false);
public function getQuantityIndependent() {
return $this->get('quantity_independent', false);
}
/**
......@@ -173,7 +173,7 @@ class Condition extends Collection {
* @return int
*/
protected function applyWithQuantity($totalOrSubTotalOrPrice, $conditionValue, $quantity=1) {
return $this->apply($totalOrSubTotalOrPrice, $conditionValue) * ($this->getQuantityUndepended() ? 1 : $quantity);
return $this->apply($totalOrSubTotalOrPrice, $conditionValue) * ($this->getQuantityIndependent() ? 1 : $quantity);
}
/**
......
......@@ -47,7 +47,7 @@ class CurrencyCondition extends Condition {
* @return int
*/
protected function applyWithQuantity($totalOrSubTotalOrPrice, $conditionValue, $quantity = 1) {
return $this->getQuantityUndepended()
return $this->getQuantityIndependent()
? $this->apply($totalOrSubTotalOrPrice, $conditionValue)
: $this->apply($totalOrSubTotalOrPrice, $conditionValue) * $quantity;
}
......
......@@ -821,28 +821,28 @@ class CartConditionTest extends PHPUnit_Framework_TestCase {
'name' => 'Test Fix 500',
'type' => 'sale',
'target' => 'item',
'quantity_undepended' => true,
'quantity_independent' => true,
'value' => '500'
));
$itemCondition1 = new Condition(array(
'name' => 'Test 10%',
'type' => 'sale',
'target' => 'item',
'quantity_undepended' => true,
'quantity_independent' => true,
'value' => '+10%'
));
$itemCondition2 = new Condition(array(
'name' => 'Test 10% per Item',
'type' => 'sale',
'target' => 'item',
'quantity_undepended' => false,
'quantity_independent' => false,
'value' => '+10%'
));
$itemCondition3 = new Condition(array(
'name' => 'Test Fix 250',
'type' => 'sale',
'target' => 'item',
'quantity_undepended' => false,
'quantity_independent' => false,
'value' => '250'
));
......@@ -861,12 +861,12 @@ class CartConditionTest extends PHPUnit_Framework_TestCase {
);
$this->cart->add($item);
# Fix quantity undependend
# Fix quantity independent
$this->assertEquals(500, $itemCondition->applyCondition(0), 'condition');
$this->assertEquals(500, $itemCondition->applyConditionWithQuantity(0, 3), 'Quantitycondition');
$this->assertEquals(500, $itemCondition->applyConditionWithQuantity(1000, 3), 'Quantitycondition +itemAmount');
# % quantity undependend
# % quantity independent
$this->assertEquals(0, $itemCondition1->applyCondition(0), 'condition');
$this->assertEquals(10, $itemCondition1->applyCondition(100), 'condition');
$this->assertEquals(10, $itemCondition1->applyConditionWithQuantity(100, 3), 'Quantitycondition +itemAmount');
......@@ -892,14 +892,14 @@ class CartConditionTest extends PHPUnit_Framework_TestCase {
'name' => 'Test1',
'type' => 'sale',
'target' => 'item',
'quantity_undepended' => true,
'quantity_independent' => true,
'value' => '500'
));
$itemCondition1 = new Condition(array(
'name' => 'Test1',
'type' => 'sale',
'target' => 'item',
'quantity_undepended' => true,
'quantity_independent' => true,
'value' => '500'
));
......
......@@ -892,28 +892,28 @@ class CurrencyCartConditionTest extends PHPUnit_Framework_TestCase {
'name' => 'Test Fix 500',
'type' => 'sale',
'target' => 'item',
'quantity_undepended' => true,
'quantity_independent' => true,
'value' => new Money(500)
));
$itemCondition1 = new CurrencyCondition(array(
'name' => 'Test 10%',
'type' => 'sale',
'target' => 'item',
'quantity_undepended' => true,
'quantity_independent' => true,
'value' => '+10%'
));
$itemCondition2 = new CurrencyCondition(array(
'name' => 'Test 10% per Item',
'type' => 'sale',
'target' => 'item',
'quantity_undepended' => false,
'quantity_independent' => false,
'value' => '+10%'
));
$itemCondition3 = new CurrencyCondition(array(
'name' => 'Test Fix 250',
'type' => 'sale',
'target' => 'item',
'quantity_undepended' => false,
'quantity_independent' => false,
'value' => new Money(250)
));
......@@ -932,12 +932,12 @@ class CurrencyCartConditionTest extends PHPUnit_Framework_TestCase {
);
$this->cart->add($item);
# Fix quantity undependend
# Fix quantity independent
$this->assertEquals(500, $itemCondition->applyCondition(0), 'condition');
$this->assertEquals(500, $itemCondition->applyConditionWithQuantity(0, 3), 'Quantitycondition');
$this->assertEquals(500, $itemCondition->applyConditionWithQuantity(1000, 3), 'Quantitycondition +itemAmount');
# % quantity undependend
# % quantity independent
$this->assertEquals(0, $itemCondition1->applyCondition(0), 'condition');
$this->assertEquals(10, $itemCondition1->applyCondition(100), 'condition');
$this->assertEquals(10, $itemCondition1->applyConditionWithQuantity(100, 3), 'Quantitycondition +itemAmount');
......@@ -961,14 +961,14 @@ class CurrencyCartConditionTest extends PHPUnit_Framework_TestCase {
'name' => 'Test1',
'type' => 'sale',
'target' => 'item',
'quantity_undepended' => true,
'quantity_independent' => true,
'value' => new Money(500)
));
$itemCondition1 = new CurrencyCondition(array(
'name' => 'Test1',
'type' => 'sale',
'target' => 'item',
'quantity_undepended' => true,
'quantity_independent' => true,
'value' => new Money(500)
));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment