# \Thelia\ActionCart

Class Cart where all actions are manage like adding, modifying or delete items.

Class Cart

## Summary

Methods
Properties
Constants
addItem()
deleteItem()
changeItem()
getSubscribedEvents()
__construct()
getDispatcher()
No public properties found
No constants found
updateQuantity()
doAddItem()
findItem()
validateForm()
propagateFormError()
$container
N/A
No private methods found
No private properties found
N/A

File
  Action/Cart.php
Package
  \Thelia\Action
Class hierarchy
  \Thelia\Action\BaseAction
  \Thelia\Action\Cart

## Tags

None found

## Properties

### $container

    $container : \Thelia\Action\The

#### Type

\Thelia\Action\The — container

#

Inherited from
  \Thelia\Action\BaseAction

## Tags

None found

## Methods

### addItem()

    addItem(\Thelia\Core\Event\CartEvent $event)

add an article in the current cart

#### Parameters

\Thelia\Core\Event\CartEvent | $event |

#

## Tags

None found

### deleteItem()

    deleteItem(\Thelia\Core\Event\CartEvent $event)

Delete specify article present into cart

#### Parameters

\Thelia\Core\Event\CartEvent | $event |

#

## Tags

None found

### changeItem()

    changeItem(\Thelia\Core\Event\CartEvent $event)

Modify article's quantity

don't use Form here just test the Request.

#### Parameters

\Thelia\Core\Event\CartEvent | $event |

#

## Tags

None found

### getSubscribedEvents()

    getSubscribedEvents() : array

Returns an array of event names this subscriber wants to listen to.

The array keys are event names and the value can be:

- The method name to call (priority defaults to 0)
- An array composed of the method name to call and the priority
- An array of arrays composed of the method names to call and respective priorities, or 0 if unset

For instance:

- array('eventName' => 'methodName')
- array('eventName' => array('methodName', $priority))
- array('eventName' => array(array('methodName1', $priority), array('methodName2'))

#### Returns

array —

The event names to listen to

#

static

## Tags

api |

### __construct()

    __construct(\Symfony\Component\DependencyInjection\ContainerInterface $container)

#### Parameters

\Symfony\Component\DependencyInjection\ContainerInterface | $container |

#

Inherited from
  \Thelia\Action\BaseAction

## Tags

None found

### getDispatcher()

    getDispatcher() : \Symfony\Component\EventDispatcher\EventDispatcherInterface

Return the event dispatcher,

#### Returns

\Symfony\Component\EventDispatcher\EventDispatcherInterface

#

Inherited from
  \Thelia\Action\BaseAction

## Tags

None found

### updateQuantity()

    updateQuantity(\Thelia\Model\CartItem $cartItem, float $quantity)

increase the quantity for an existing cartItem

#### Parameters

\Thelia\Model\CartItem | $cartItem |
float | $quantity |

#

## Tags

None found

### doAddItem()

    doAddItem(\Thelia\Model\Cart $cart, int $productId, int $productSaleElementsId, float $quantity, \Thelia\Model\ProductPrice $productPrice)

try to attach a new item to an existing cart

#### Parameters

\Thelia\Model\Cart | $cart |
int | $productId |
int | $productSaleElementsId |
float | $quantity |
\Thelia\Model\ProductPrice | $productPrice |

#

## Tags

None found

### findItem()

    findItem(int $cartId, int $productId, int $productSaleElementsId) : \Thelia\Action\ChildCartItem

find a specific record in CartItem table using the Cart id, the product id and the product_sale_elements id

#### Parameters

int | $cartId |
int | $productId |
int | $productSaleElementsId |

#### Returns

\Thelia\Action\ChildCartItem

#

## Tags

None found

### validateForm()

    validateForm(\Thelia\Form\BaseForm $aBaseForm, string $expectedMethod) : \Symfony\Component\Form\Form

Validate a BaseForm

#### Parameters

\Thelia\Form\BaseForm | $aBaseForm | the form
string | $expectedMethod | the expected method, POST or GET, or null for any of them

#### Throws

\Thelia\Action\Exception\FormValidationException

  is the form contains error, or the method is not the right one

#### Returns

\Symfony\Component\Form\Form —

Form the symfony form object

#

Inherited from
  \Thelia\Action\BaseAction

## Tags

None found

### propagateFormError()

    propagateFormError(\Thelia\Form\BaseForm $aBaseForm, string $error_message, \Thelia\Core\Event\ActionEvent $event)

Propagate a form error in the action event

#### Parameters

\Thelia\Form\BaseForm | $aBaseForm | the form
string | $error_message | an error message that may be displayed to the customer
\Thelia\Core\Event\ActionEvent | $event | the action event

#

Inherited from
  \Thelia\Action\BaseAction

## Tags

None found

### Cart.php