function commerce_autosku_element_validate_sku_pattern in Commerce AutoSKU 7
1 string reference to 'commerce_autosku_element_validate_sku_pattern'
File
- ./
commerce_autosku.module, line 109 - Module hooks and helper functions for commerce_autosku
Code
function commerce_autosku_element_validate_sku_pattern(&$element, &$form_state) {
if ($form_state['values']['product_type']['autosku_status']) {
$tokens = token_scan($element['#value']);
if (empty($tokens)) {
form_error($element, t('SKU pattern must contain at least one valid token.'));
return;
}
if (isset($tokens['commerce-product']['sku'])) {
form_error($element, t('You may not use the SKU token in the SKU Pattern.'));
return;
}
if (!module_exists('token') && drupal_strlen($element['#value'])) {
if (!isset($tokens['commerce-product']) || count($tokens) > 1) {
form_error($element, t('You must have one or more product tokens, and no other kinds of tokens in the SKU Pattern.'));
}
}
}
}