Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 22nd, 2012  |  syntax: PHP  |  size: 1.04 KB  |  hits: 23  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  
  3. * Implementation of hook_form_alter().
  4.  
  5. function commerce_dedicatoria_form_alter(&$form, &$form_state, $form_id) {
  6.         if ($form_id == 'commerce_checkout_form_checkout') {
  7.                 drupal_set_message("estoy en commerce_dedicatoria_form_alter ");
  8.                 $form['buttons']['continue']['#submit'][] = 'commerce_dedicatoria_add_cart_submit';
  9.                 dsm($form_id);  // print form ID to messages
  10.                 dsm($form);
  11.   }
  12. }
  13.  
  14. /**
  15.  * Submit handler for the simple add to cart.
  16.  *
  17.  * This uses the default values of commerce_cart_product_add_by_id(), but that
  18.  * function also accepts $quantity, $combine, and $uid arguments.
  19.  *
  20.  * Note that commerce_cart_product_add_by_id() simply wraps up the creation
  21.  * of a line item and the adding of the line item to the product. The code
  22.  * inside is not very hard either.
  23.  */
  24. function commerce_dedicatoria_add_cart_submit($form, &$form_state) {
  25.         //commerce_cart_product_add_by_id($form_state['values']['addcart_product']);
  26.         //El producto con el id=75 es mi dedicatoria personalizada
  27.         commerce_cart_product_add_by_id(75);
  28. }