function commerce_bpc_token_sample_values in Commerce Bulk Product Creation 7
Same name and namespace in other branches
- 7.2 commerce_bpc.tokens.inc \commerce_bpc_token_sample_values()
Collects sample values of tokens for a given product type.
Parameters
string $product_type: The product type for whose fields sample values should be returned.
Return value
array An array with entries of the form 'token_name' => 'sample_value'
1 call to commerce_bpc_token_sample_values()
- commerce_bpc_process_fragment_field in ./
commerce_bpc.forms.inc - Process SKU and title fragment fields.
File
- ./
commerce_bpc.tokens.inc, line 152 - Token API implementations for Commerce bulk product creation module.
Code
function commerce_bpc_token_sample_values($product_type) {
$samples = array();
$instances = field_info_instances('commerce_product', $product_type);
foreach ($instances as $instance) {
if (commerce_bpc_is_combination_field($instance)) {
$sample = module_invoke_all('commerce_bpc_token_sample_values', $instance);
$samples['values'][$instance['field_name']] = $sample['value'];
if (isset($sample['label'])) {
$samples['labels'][$instance['field_name']] = $sample['label'];
}
}
}
return $samples;
}