In my checkout form, I have 2 customer profiles: billing (default) and shipping (from commerce shipping module).

Basically, I need to emulate the commerce_shipping 7.x-1 option "copy shipping information from billing", but i need to do that manually in a validation function (the values depends from few factors).

My code:

function MYMODULE_form_commerce_checkout_form_checkout_alter(&$form, &$form_state, $form_id)
    // [...cut...]
    array_unshift($form['buttons']['continue']['#validate'], '_MYMODULE_validate_checkout');

function _MYMODULE_validate_checkout($form, &$form_state)
    // a custom checkbox i added in MYMODULE_form_commerce_checkout_form_checkout_alter
    if($form_state['values']['b2s'] == 1)

But i get this error:

Notice: Undefined index: #parents in form_set_value() (line 2514 di /httpdocs/includes/form.inc).

Recoverable fatal error: Argument 2 passed to drupal_array_set_nested_value() must be an array, null given, called in /httpdocs/includes/form.inc on line 2514 and defined in drupal_array_set_nested_value() (linea 6440 di /httpdocs/includes/common.inc).

I also tryed:

$form_state['values']['customer_profile_shipping']['customer_profile']->commerce_customer_address['und'][0] = $form_state['values']['customer_profile_billing']['customer_profile']->commerce_customer_address['und'][0];

and i dont get any errors, but it doesnt works.

Any idea? Basically, for now i just need to copy billing address into shipping address when my b2s checkbox is checked (when i understand how to do that, i will add my custom logic)

  • Why not copy address from billing to shipping text box using jquery/js ? – GoodSp33d Nov 6 '12 at 10:08
  • @2-Stroker I already do that, but i have few logic that cant be implemented client side (and btw i dont like to rely only on javascript for a thing that is mandatory for my site) – Strae Nov 6 '12 at 10:16

Your Answer

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

Browse other questions tagged or ask your own question.