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
Show file tree
Hide file tree
Changes from all commits
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
67 changes: 65 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,60 @@ 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 conditions 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 +666,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 conditions applied
$item->getPriceSum(); // the subtotal without conditions applied
$item->getPriceWithConditions(); // the single price with conditions applied
$item->getPriceSumWithConditions(); // the subtotal with conditions applied
$item->quantity; // the quantity
$item->attributes; // the attributes

Expand All @@ -633,7 +691,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 conditions applied
$item->getPriceSum(); // the subtotal without conditions applied
$item->getPriceWithConditions(); // the single price with conditions 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
2 changes: 1 addition & 1 deletion src/Darryldecode/Cart/ItemCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __get($name)
}

/**
* check if item has confitions
* check if item has conditions
*
* @return bool
*/
Expand Down