public static function Utility::getFieldsConfig in Basic cart 8
Same name and namespace in other branches
- 8.6 src/Utility.php \Drupal\basic_cart\Utility::getFieldsConfig()
- 8.0 src/Utility.php \Drupal\basic_cart\Utility::getFieldsConfig()
- 8.2 src/Utility.php \Drupal\basic_cart\Utility::getFieldsConfig()
- 8.3 src/Utility.php \Drupal\basic_cart\Utility::getFieldsConfig()
- 8.4 src/Utility.php \Drupal\basic_cart\Utility::getFieldsConfig()
- 8.5 src/Utility.php \Drupal\basic_cart\Utility::getFieldsConfig()
Returns the fields we need to create.
Return value
mixed Key / Value pair of field name => field type.
1 call to Utility::getFieldsConfig()
- Utility::createFields in src/
Utility.php
File
- src/
Utility.php, line 98 - Contains \Drupal\basic_cart\Utility
Class
Namespace
Drupal\basic_cartCode
public static function getFieldsConfig($type = null) {
$config = self::cartSettings();
$fields['bundle_types'] = $config
->get('content_type');
foreach ($config
->get('content_type') as $key => $value) {
if ($value) {
$bundles[$key] = $key;
}
}
$fields['bundle_types'] = $bundles;
if ($type == self::FIELD_ORDERCONNECT) {
$fields['bundle_types'] = array(
'basic_cart_connect' => 'basic_cart_connect',
);
$fields['fields'] = array(
'basic_cart_contentoconnect' => array(
'type' => 'entity_reference',
'entity_type' => 'node',
'bundle' => 'basic_cart_connect',
'title' => t('Basic Cart Content Connect'),
'label' => t('Basic Cart Content Connect'),
'required' => FALSE,
'description' => t('Basic Cart content connect'),
'settings' => array(
'handler' => 'default:node',
'handler_settings' => array(
"target_bundles" => $bundles,
),
),
),
);
}
else {
$fields['fields'] = array(
'add_to_cart_price' => array(
'type' => 'decimal',
'entity_type' => 'node',
'title' => t($config
->get('price_label')),
'label' => t($config
->get('price_label')),
'required' => FALSE,
'description' => t('Please enter this item\'s price.'),
'widget' => array(
'type' => 'number',
),
'formatter' => array(
'default' => array(
'label' => 'inline',
'type' => 'number_decimal',
'weight' => 11,
),
'search_result' => 'default',
'teaser' => 'default',
),
),
'add_to_cart' => array(
'type' => 'addtocart',
'entity_type' => 'node',
'title' => t($config
->get('add_to_cart_button')),
'label' => t($config
->get('add_to_cart_button')),
'required' => FALSE,
'description' => 'Enable add to cart button',
'widget' => array(
'type' => 'addtocart',
),
'formatter' => array(
'default' => array(
'label' => 'hidden',
'weight' => 11,
'type' => $config
->get('quantity_status') ? 'addtocartwithquantity' : 'addtocart',
),
'search_result' => array(
'label' => 'hidden',
'weight' => 11,
'type' => 'addtocart',
),
'teaser' => array(
'label' => 'hidden',
'weight' => 11,
'type' => 'addtocart',
),
),
),
);
}
return (object) $fields;
}