class FlexiformFormEntityNewCommerceLineItem in Flexiform 7
Form Entity Class for getting new commerce line items.
Hierarchy
- class \FlexiformFormEntityBase implements FlexiformFormEntityInterface
Expanded class hierarchy of FlexiformFormEntityNewCommerceLineItem
1 string reference to 'FlexiformFormEntityNewCommerceLineItem'
File
- includes/
form_entity/ commerce_line_item.form_entity.inc, line 10 - Contains class for a basic entity getter.
View source
class FlexiformFormEntityNewCommerceLineItem extends FlexiformFormEntityBase {
/**
* {@inheritdoc}
*/
public function getEntity() {
parent::getEntity();
// Get the base order
$order = $this
->getParam('base');
// Check we have enough information to load the entity.
if (!$order) {
return FALSE;
}
$target_entity = commerce_line_item_new($this->settings['bundle'], $order->order_id);
return $this
->checkBundle($target_entity) ? $target_entity : FALSE;
}
/**
* {@inheritdoc}
*/
public function saveEntity($entity) {
// If the entity is still false do not save it!
if ($entity === FALSE) {
return;
}
$order = $this
->getParam('base');
if (empty($entity->order_id)) {
if (empty($order->order_id)) {
commerce_order_save($order);
}
$entity->order_id = $order->order_id;
}
// Make sure commerce_unit_price has components.
if (!empty($entity->commerce_unit_price[LANGUAGE_NONE][0]) && empty($entity->commerce_unit_price[LANGUAGE_NONE][0]['data']['components'])) {
$price =& $entity->commerce_unit_price[LANGUAGE_NONE][0];
$price['data'] = commerce_price_component_add($price, 'base_price', $price, TRUE);
}
commerce_line_item_save($entity);
$order->commerce_line_items[LANGUAGE_NONE][] = array(
'line_item_id' => $entity->line_item_id,
);
commerce_order_save($order);
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FlexiformFormEntityBase:: |
public | property | The namespace of this entity. | |
FlexiformFormEntityBase:: |
public | property | The type of this entity. | |
FlexiformFormEntityBase:: |
public | property | Details of the getter. | |
FlexiformFormEntityBase:: |
public | property | The Flexiform Entity Manager | |
FlexiformFormEntityBase:: |
public | property | The settings for this entity on the flexiform. | |
FlexiformFormEntityBase:: |
public | function | Check bundle. | |
FlexiformFormEntityBase:: |
public | function |
Get the Configuration Form. Overrides FlexiformFormEntityInterface:: |
3 |
FlexiformFormEntityBase:: |
public | function |
Submit the Configuration Form. Overrides FlexiformFormEntityInterface:: |
|
FlexiformFormEntityBase:: |
public | function |
Validate the configuration form. Overrides FlexiformFormEntityInterface:: |
|
FlexiformFormEntityBase:: |
public | function | Get a Parameter From the Entity Manager. | |
FlexiformFormEntityBase:: |
public | function | Get a Parameter's entity settings from the Entity Manager. | |
FlexiformFormEntityBase:: |
public | function | Get the entity type of a parameter. | |
FlexiformFormEntityBase:: |
public | function | Construct a Flexiform Form Entity class. | |
FlexiformFormEntityNewCommerceLineItem:: |
public | function |
Get the entity for the form. Overrides FlexiformFormEntityBase:: |
|
FlexiformFormEntityNewCommerceLineItem:: |
public | function |
Save the entity upon submission of the form. Overrides FlexiformFormEntityBase:: |