You are here

function commerce_price_component_delete in Commerce Core 7

Remove all instances of a particular component from a price's data array.

Parameters

&$price: The price array to remove components from.

$type: The machine-name of the component type to delete.

Return value

The updated data array.

File

modules/price/commerce_price.module, line 1010
Defines the Price field with widgets and formatters used to add prices with currency codes to various Commerce entities.

Code

function commerce_price_component_delete($price, $type) {
  foreach ((array) $price['data']['components'] as $key => $component) {
    if ($component['name'] == $type) {
      unset($price['data']['components'][$key]);
    }
  }
  return $price['data'];
}