You are here

function commerce_cart_field_instance_access_settings in Commerce Core 7

Returns an array of cart form field access settings for a field instance.

Fields attached to line item types can be included on the Add to Cart form so customers can supply additional information for the line item when it is added to the cart. Certain fields will not be exposed based on line item field access integration, such as the total price field which is always computationally generated on line item save.

Parameters

$instance: The info array of the field instance whose field access settings should be retrieved.

Return value

An array of field access settings including:

  • field_access: boolean indicating whether or not this field instance should appear on the Add to Cart form.
2 calls to commerce_cart_field_instance_access_settings()
commerce_cart_add_to_cart_form in modules/cart/commerce_cart.module
Builds an Add to Cart form for a set of products.
commerce_cart_form_field_ui_field_edit_form_alter in modules/cart/commerce_cart.module
Implements hook_form_FORM_ID_alter().

File

modules/cart/commerce_cart.module, line 1642
Implements the shopping cart system and add to cart features.

Code

function commerce_cart_field_instance_access_settings($instance) {
  if (empty($instance['commerce_cart_settings']) || !is_array($instance['commerce_cart_settings'])) {
    $commerce_cart_settings = array();
  }
  else {
    $commerce_cart_settings = $instance['commerce_cart_settings'];
  }

  // Supply default values for the cart settings pertaining here to field access
  // on the Add to Cart form.
  $commerce_cart_settings += array(
    'field_access' => FALSE,
  );
  return $commerce_cart_settings;
}