You are here

commerce_pricing_attributes.module in Commerce Pricing Attributes 7.2

Same filename and directory in other branches
  1. 7 commerce_pricing_attributes.module

File

commerce_pricing_attributes.module
View source
<?php

/**
 * Implements hook_entity_info().
 */
function commerce_pricing_attributes_entity_info() {

  // Commerce Pricing Attributes Entity.
  $info['commerce_pricing_attibutes'] = array(
    'label' => t('Commerce Pricing Attributes'),
    'entity class' => 'EntityAPIController',
    'controller class' => 'EntityAPIController',
    'base table' => 'commerce_pricing_attributes',
    'fieldable' => TRUE,
    'entity keys' => array(
      'id' => 'attribute_id',
      'label' => 'name',
      'bundle' => 'type',
    ),
    'access callback' => 'commerce_pricing_attributes_access',
    'module' => 'commerce_pricing_attributes',
    'bundle keys' => array(
      'bundle' => 'type',
    ),
    'bundles' => array(),
  );
  return $info;
}

/**
 * Access callback for entity commerce_pricing_attributes.
 */
function commerce_pricing_attributes_access($op, $entity, $customer, $entity_type) {
  return TRUE;
}

/**
 * Returns all the product typesthat have enabled the Pricing Attributes.
 */
function commerce_pricing_attributes_enabled_product_types() {
  $types = array();

  // For all product types,
  foreach (commerce_product_types() as $product_type) {
    $type = $product_type['type'];

    // If product type has enables pricing attributes.
    if (variable_get('commerce_pricing_atrributes_' . $type . '_enabled', 0)) {

      //Keep the enabled.
      $types[$type] = $product_type;
    }
  }
  return $types;
}

Functions

Namesort descending Description
commerce_pricing_attributes_access Access callback for entity commerce_pricing_attributes.
commerce_pricing_attributes_enabled_product_types Returns all the product typesthat have enabled the Pricing Attributes.
commerce_pricing_attributes_entity_info Implements hook_entity_info().