function commerce_product_bundle_line_item_add_form_submit in Commerce Product Bundle 7.2
Same name and namespace in other branches
- 7 commerce_product_bundle.module \commerce_product_bundle_line_item_add_form_submit()
Adds the selected shipping information to a line item added via a line item manager widget.
@TODO: Implement this method correct.
Parameters
obj $line_item: The newly created line item object.
array $element: The array representing the widget form element.
array $form_state: The present state of the form upon the latest submission.
array $form: The actual form array.
File
- ./
commerce_product_bundle.module, line 1109 - Allows the bundling of products in Drupal Commerce.
Code
function commerce_product_bundle_line_item_add_form_submit(&$line_item, $element, &$form_state, $form) {
$order = $form_state['commerce_order'];
// Populate the line item with the product data.
$line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
$line_item_wrapper->commerce_unit_price->amount = $element['actions']['amount']['#value'];
$line_item_wrapper->commerce_unit_price->currency_code = $element['actions']['currency_code']['#value'];
$line_item_wrapper->commerce_unit_price->data = commerce_price_component_add($line_item_wrapper->commerce_unit_price
->value(), 'base_price', $line_item_wrapper->commerce_unit_price
->value(), TRUE);
}