1 reply [Last post]
bloke_zero's picture
Offline
Joined: 03/24/2009
Juice: 62
Was this information Helpful?

Hi,

I'm trying to add a start date when someone is booking a class. The classes have the Date CCK field added with 'repeat', so getting the complete list of dates is easy from the form.

There are 2 ways I can think of to do it.

1. with Jquery, if I pull the list out of the form and create a drop down and then add some jquery to fill in a hidden text field. That's easy enough, but I was wondering if there was a way using PHP not js.
2. Use the same list of dates and add them when uc_product_add_to_cart_form get's triggered as attributes

At the moment I'm doing this:

function classdate_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == "uc_product_add_to_cart_form_68") {
$start_dates = Array();
$class = $form['node'];
$dates = $class['#value']->field_dates;

foreach ($dates as $date){
$start_dates[]=$date['value'];
$form['attributes'][7]['#options'][]=$date['value'];
}
  }
}

Which adds to the list of options, but doesn't show up in the cart (obviously).

I was toying with the idea of adding them on node creation (node_form) but I'm beginning to think that attributes is the wrong track because I wouldn't want to end up with all possible dates as attributes in the database (after a few courses have been created there would be hundreds of options).

Any thoughts?

Cheers

Alex

------------------------------
http://zero-design.info

markagray's picture
Offline
Joined: 09/09/2009
Juice: 192
Re: Best way to add a date to a product - jQuery or attribute

Did you find a solution to this? I also need to add a start date selection to a product.