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' => commerce_paypal_price_amount(commerce_currency_convert($amount, $order_currency_code, $currency_code), $currency_code),
'item_name_1' => t('Order @order_number at @store', array('@order_number' => $order->order_number, '@store' => variable_get('site_name', url('<front>', array('absolute' => TRUE))))),
'on0_1' => t('Product count'),
'os0_1' => commerce_line_items_quantity($wrapper->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(&$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.