Commerce- How can I modify order details with hook_commerce_paypal_wps_order_form_data_alter()? I want to modify the information Commerce sends to PayPal so that the order description on PayPal describes the product, not the order (users on my site can only order one of two products, so I think that is more useful).

This is what I want to change:


These strings are in the Commerce Website Payments Standard submodule. I am using the hook_commerce_paypal_wps_order_form_data_alter() function as suggested in the answer to this question.

However, in the API, there is no example for this function (I also looked at the Commerce Examples module but didn't find anything), and I'm a bit lost about how to handle it.

The string I want to override is defined in commerce_paypal_wps_order_form() in this section:

    // Define a single item in the cart representing the whole order
    'amount_1' =&gt; commerce_paypal_price_amount(commerce_currency_convert($amount, $order_currency_code, $currency_code), $currency_code),
    'item_name_1' =&gt; t('Order @order_number at @store', array('@order_number' =&gt; $order-&gt;order_number, '@store' =&gt; variable_get('site_name', url('&lt;front&gt;', array('absolute' =&gt; TRUE))))),
    'on0_1' =&gt; t('Product count'),
    'os0_1' =&gt; commerce_line_items_quantity($wrapper-&gt;commerce_line_items, commerce_product_line_item_types()),
  );


I want to change item_name_1 to t('My string') and remove on0_1 and os0_1.

I tried this:

function MYMODULE_commerce_paypal_wps_order_form_data_alter(&amp;$data, $order) {
  $data['item_name_1'] = t('My string');
  unset($data['on0_1']);
  unset($data['os0_1']);
}


But nothing is changed, even after clearing the caches.  I'm having a really hard time debugging this because it is called immediately before the redirect to PayPal, so even if I use dpm() I'm not able to see it.
When you can not see the HTML output of debugging tools such as dpm(), you should use the utility function dd() instead. The logging data will be stored in a file called drupal_debug.txt which you can inspect later.