Advertisement
Guest User

ajax callback

a guest
Feb 8th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.79 KB | None | 0 0
  1. // Эта функция отрабатывает в кастомном модуле вместо uc_payment_get_totals (код ее ниже привожу)
  2. function с_checkout_quote_get_totals($form, $form_state, $wrapper = NULL) {
  3.   //$shiping_method = $form_state['values']['panes']['quotes']['quotes']['quote_option'];
  4.   //$order = $form['panes']['payment']['line_items']['#order'];
  5.   //$line_items = uc_order_load_line_items_display($order);
  6.   //$form['panes']['payment']['line_items']['#order']->line_items[1]['amount'] = 890;
  7.   //if ($order->payment_method == 'cod' && $shiping_method== 'flatrate_8---0') {
  8.   //  $form['panes']['payment']['line_items']['#order']->line_items[1]['amount'] = 14000;
  9.   //}
  10.  
  11.   // вот не пойму, какой элемент формы нужно изменить,
  12.   // чтобы drupal_render($form['panes']['payment']['line_items']) вернула html с нужной мне стоимостью доставки.
  13.   $commands[] = ajax_command_replace('#line-items-div', trim(drupal_render($form['panes']['payment']['line_items'])));
  14.   return array('#type' => 'ajax', '#commands' => $commands);
  15. }
  16.  
  17. /**
  18.  * Returns a formatted list of line items for an order total preview.
  19.  *
  20.  * @param $return
  21.  *   TRUE or FALSE to specify whether or not to return the results instead of
  22.  *   printing them and exiting.
  23.  * @param $order
  24.  *   Optionally pass in a full order object to use instead of finding it in the
  25.  *   $_POST data.
  26.  *
  27.  * @return
  28.  *   The formatted HTML of the order total preview if $return is set to TRUE.
  29.  */
  30. function uc_payment_get_totals($form, $form_state) {
  31.   $commands[] = ajax_command_replace('#line-items-div', trim(drupal_render($form['panes']['payment']['line_items'])));
  32.  
  33.   return array('#type' => 'ajax', '#commands' => $commands);
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement