add bellow code in * Callback function for commerce_userpoints_discount_pane_checkout_form()
for display errors in form with ajax

function commerce_userpoints_discount_use_credit_callback_input($form, $form_state) {
...
  $commands[] = ajax_command_html('#example-cart-contents-wrapper', render($cart_contents_view));
+  $commands[] = ajax_command_remove('div.messages');
+  $commands[] = ajax_command_before('#main-content', theme('status_messages'));

that is ok

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

m2jalali’s picture

Issue summary: View changes

exactly code

zenimagine’s picture

Issue summary: View changes

Thank you, your solution works for me.
How to display the messages in the user panel points ?
instead of displaying the top of the page.

/sites/all/modules/commerce_userpoints/commerce_userpoints_discount/commerce_userpoints_discount.module

/**
 * Callback function for commerce_userpoints_discount_pane_checkout_form()
 * This function calls the commerce_userpoints_discount_use_credit_callback with the parameters
 * set for the case where the user wishes to use a specified amount of points
 *
 * @param array $form
 *  $form variable from commerce_userpoints_discount_pane_checkout_form()
 * @param array $form_state
 *  $form_state variable from commerce_userpoints_discount_pane_checkout_form()
 */
function commerce_userpoints_discount_use_credit_callback_input($form, $form_state) {
  $order = $form_state['order'];
  $amount = $form_state['values']['commerce_userpoints_discount']['amount'];
  $currency = $form_state['values']['commerce_userpoints_discount']['currency'];
  
  commerce_userpoints_discount_use_credit_callback($order, $amount, $currency);

  $cart_contents_view =  _commerce_userpoints_discount_update_cart_view($order->order_id);
 
  $commands = array();
  $commands[] = ajax_command_html('#commerce-userpoints-discount-cart-contents-wrapper', render($cart_contents_view));
  $commands[] = ajax_command_remove('div.messages');
  $commands[] = ajax_command_before('#main-content', theme('status_messages'));
  return array('#type' => 'ajax', '#commands' => $commands);
}
zenimagine’s picture

The messages should be displayed as for commerce coupon :