How would I have the coupon checkout pane by default collapsed? I tried it with CSS but then the user has to click twice to open it, which is undesirable.

CommentFileSizeAuthor
#7 uc_coupon_collapsed.tgz462 bytesñull

Comments

wodenx’s picture

you could use hook_form_alter() and change the #collapsed field to "true"

ñull’s picture

I tried the following:

function uc_coupon_collapsed_form_alter(&$form, &$form_state, $form_id){
  if ($form_id == 'uc_cart_checkout_form') {
  // Collapse 'coupon' fieldset.
    $form['coupon']['#collapsed'] = TRUE;
  }
//  drupal_set_message("Form ID is : " . $form_id);
//  drupal_set_message("Forms: " . print_r($form,true));
}

Doesn't work. Then I read this. So simply overriding is not possible.

I also tried this but the code doesn't work and I could not find the right one. Any more ideas?

ñull’s picture

I also tried to change the module by adding 'collapsed' => TRUE which didn't work either:

function uc_coupon_cart_pane($items) {
  $panes[] = array(
    'id' => 'coupon',
    'body' => drupal_get_form('uc_cart_pane_coupon'),
    'title' => t('Coupon discount'),
    'desc' => t('Allows shoppers to use a coupon during checkout for order discounts.'),
    'weight' => 1,
    'enabled' => TRUE,
    'collapsed' => TRUE,
  );
  return $panes;
}
wodenx’s picture

this:

<?php


function MYMODULE_form_uc_cart_checkout_form_alter( &$form, &$form_state ) {
  ...
  $form['panes']['coupon']['#collapsed']=TRUE;
  ...
}

seems to work for me...

wodenx’s picture

this:

<?php


function MYMODULE_form_uc_cart_checkout_form_alter( &$form, &$form_state ) {
  ...
  $form['panes']['coupon']['#collapsed']=TRUE;
  ...
}

seems to work for me...

ñull’s picture

Status: Active » Fixed

Thanks a lot!

ñull’s picture

StatusFileSize
new462 bytes

To save others some time I attach here the module.

longwave’s picture

Title: collapsed by default » Collapse checkout pane by default
Category: support » feature
Status: Fixed » Patch (to be ported)

I guess this could be useful to others, so marking "to be ported" and I will try to include it as an option in the module itself at some point.

longwave’s picture

Status: Patch (to be ported) » Fixed

Committed to CVS. Configuration option is at /admin/store/settings/checkout/edit/panes

ñull’s picture

Cool!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.