diff --git a/README.md b/README.md index 3102b04..d409f89 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ Next, run the Composer update command from the Terminal: ## HOW TO USE * [Usage](#usage) * [Conditions](#conditions) +* [Items](#items) * [Instances](#instances) * [Exceptions](#exceptions) * [Events](#events) @@ -521,6 +522,50 @@ Remove conditions by type: **Cart::removeConditionsByType($type)** public function removeConditionsByType($type) ``` +## Items + +The method **Cart::getContent()** returns a collection of items. +To get the id of an item, use the property **$item->id**. +To get the name of an item, use the property **$item->name**. +To get the quantity of an item, use the property **$item->quantity**. +To get the attributes of an item, use the property **$item->attributes**. +To get the price of a single item without the conditions applied, use the property **$item->price**. +To get the subtotal of an item without the conditions applied, use the method **$item->getPriceSum()**. +```php +/** +* get the sum of price +* +* @return mixed|null +*/ +public function getPriceSum() + +``` + +To get the price of a single item without the conditions applied, use the method **$item->getPriceWithConditions()**. +```php +/** +* get the single price in which conditions are already applied +* +* @return mixed|null +*/ +public function getPriceWithConditions() + +``` + +To get the subtotal of an item with the conditions applied, use the method **$item->getPriceSumWithConditions +```php +/** +* get the sum of price in which conditions are already applied +* +* @return mixed|null +*/ +public function getPriceSumWithConditions() + +``` + +Note: When you get price with conditions applied, only the conditions assigned to the current item will be calculated. +Cart condition won't be applied to price. + ## Instances You may also want multiple cart instances on the same page without conflicts. @@ -611,7 +656,10 @@ foreach($items as $item) { $item->id; // the Id of the item $item->name; // the name - $item->price; // the price + $item->price; // the single price without condition applied + $item->getPriceSum(); // the subtotal without conditions applied + $item->getPriceWithConditions(); // the single price with condition applied + $item->getPriceSumWithConditions(); // the subtotal with conditions applied $item->quantity; // the quantity $item->attributes; // the attributes @@ -633,7 +681,12 @@ $items->each(function($item) { $item->id; // the Id of the item $item->name; // the name - $item->price; // the price + $item->price; // the single price without condition applied + $item->getPriceSum(); // the subtotal without conditions applied + $item->getPriceWithConditions(); // the single price with condition applied + $item->getPriceSumWithConditions(); // the subtotal with conditions applied + $item->price; // the single price + $item->price; // the single price $item->quantity; // the quantity $item->attributes; // the attributes