You are here

function commerce_ss_entity_property_info_alter in Commerce Stock 7.2

Implements hook_entity_property_info_alter().

File

modules/commerce_ss/commerce_ss.module, line 33
Allow commerce products to have stock levels associated with their SKU.

Code

function commerce_ss_entity_property_info_alter(&$info) {

  // Copy metadata about our stock field from the product bundle to the
  // commerce_product entity.
  if (!empty($info['commerce_product']['bundles'])) {
    $properties = array();
    foreach ($info['commerce_product']['bundles'] as $bundle => $bundle_info) {
      $bundle_info += array(
        'properties' => array(),
      );
      $properties += $bundle_info['properties'];
    }
    if (isset($properties['commerce_stock'])) {
      $info['commerce_product']['properties']['commerce_stock'] = $properties['commerce_stock'];
    }
    if (isset($properties['commerce_stock_override'])) {
      $info['commerce_product']['properties']['commerce_stock_override'] = $properties['commerce_stock_override'];
      unset($info['commerce_product']['properties']['commerce_stock_override']['options list']);
    }
  }
}