Skip to content

Commit

Permalink
add docs for ItemCollection
Browse files Browse the repository at this point in the history
  • Loading branch information
SimoTod committed Nov 5, 2015
1 parent f52e04d commit cf4979a
Showing 1 changed file with 55 additions and 2 deletions.
57 changes: 55 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down

0 comments on commit cf4979a

Please sign in to comment.