Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation #40

Merged
merged 3 commits into from
Nov 6, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add docs for ItemCollection
  • Loading branch information
SimoTod committed Nov 5, 2015
commit cf4979af38a3df79ce67886c2c6a469a6cc29967
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