How to implement fancy attributes in Line item types? I don't see Attribute selection widget "Rendered term" in field settings.

Comments

FiNeX’s picture

Hi, rendering field values like Commerce Fancy Attributes module does would be a killer feature!

AverilL’s picture

I'm trying to find a way forward with this also:

The site I'm working on requires a client to upload an image or text. The client must also select a font and a colour which would ideally be displayed using commerce_fancy_attributes so an image is displayed for the font and a colour block for the colour.

So far I've extended the function commerce_cart_form_field_ui_field_edit_form_alter(&$form, &$form_state) in commerce_cart.module to include the attriubute widget for commerce_line_item as per commerce_product

    $form['instance']['commerce_cart_settings']['attribute_widget'] = array(
      '#type' => 'radios',
      '#title' => t('Attribute selection widget'),
      '#description' => t('The type of element used to select an option if used on an Add to Cart form.'),
      '#options' => array(
        'select' => t('Select list'),
        'radios' => t('Radio buttons'),
      ),
      '#default_value' => $commerce_cart_settings['attribute_widget'],
      '#states' => array(
        'visible' => array(
          ':input[name="instance[commerce_cart_settings][attribute_field]"]' => array('checked' => TRUE),
        ),
      ),
    );
    $form['field']['cardinality']['#description'] .= '<br />' . t('Must be 1 for this field to function as an attribute selection field on Add to Cart forms.');
  }

and extended commerce_fancy_attributes.module function commerce_fancy_attributes_form_field_ui_field_edit_form_alter(&$form, &$form_state) with

  if (empty($form['locked']) && $instance['entity_type'] == 'commerce_line_item' &&
    commerce_cart_field_attribute_eligible($field) && $field['type'] == 'taxonomy_term_reference') {
    $form['instance']['commerce_cart_settings']['attribute_widget']['#options']['commerce_fancy_attributes'] = t('Rendered term');
  }

The result of this is the rendered term option appears on the add to cart attribute selection on the field edit form but taxonomy term is not rendered on the product display. The attributes of the taxonomy term show in the render view of Devel but are simply not rendered.

Am I going in the right direction with this? Would it be better just to create a field formatter for the specific product? Any pointers in the right direction would be much appreciated.

jordimateubesancon’s picture

nvahalik’s picture

Title: Line item types fancy attributes / Attribute selection widget? » Integrate with Commerce Fancy Attributes
Version: 7.x-1.0-beta2 » 7.x-1.x-dev
Category: Support request » Feature request
nvahalik’s picture

Component: User interface » Code