2

I have enabled two currencies for price in Drupal commerce but I want to enable only one of them for one of products. At this moment I can see both of them in product creation time. Where or how can I set this?

0

I'm afraid there's no custom module for this, you'll need to alter the product form add/create to adapt to your settings/conditions (simplified logic below):

/**
 * Implements hook_form_FORM_ID_alter().
 */
function my_module_commerce_form_commerce_product_ui_product_form_alter(&$form, &$form_state, $form_id) {
  // Calculate the currency for a given product.
  $currency_code = 'USD';
  $form['commerce_price'][LANGUAGE_NONE][0]['currency_code']['#type'] = 'value';
  $form['commerce_price'][LANGUAGE_NONE][0]['currency_code']['#default_value'] = $currency_code;
  $form['commerce_price'][LANGUAGE_NONE][0]['amount']['#field_suffix'] = $currency_code;
}

A more complex and customizable option would be to use hook_field_widget_info_alter and modify the settings form to add whatever conditions you want for selecting a currency on a product form.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.