Custom Fieldd
-
Hello, is there a way to pass custom data to paypal on checkout ? I tried to add custom data to the PayPal checkout using “ppcp_create_order_request_body_data” which didn’t work at all.
Best Regards
Marc
-
Hello @forge12
It is important to note that although theppcp_create_order_request_body_data
filter allows you to modify the order creation data, there are some nuances to consider. For example, any custom data changed in the order creation request may be overwritten when the order is subsequently patched. To ensure that customizations are preserved, you may need to use theppcp_patch_order_request_body_data
filter in conjunction with the create order filter.However, to provide you with the best possible guidance, it would be helpful to have more clarity on your specific requirements. Are you looking to send custom data in general, or is there a specific custom field you’re focusing on?
Additionally, if you could share the example code you used that didn’t work, it would assist us in diagnosing the issue and providing a more accurate solution.
Kind Regards,
Krystian
Hello @krystian,
Thanks for your reply. We’ve added the account number for each user on WordPress as a meta field and now trying to send it as a custom field to PayPal to ensure the accounting knows which order relays to which customer account number.
Is there any way to add a custom field that will be shown in the transaction details in PayPal?
Best Regards,
MarcHello @forge12
If you are saving this?
account_number
?in the?wp_usermeta
?table, the “Memo” field in PayPal could be updated to show this:This code snippet intercepts the data sent to PayPal when creating an order. It retrieves the current user’s account number from the
wp_usermeta
table and updates the description field for the item in the purchase unit. This is where the account number will be displayed in the transaction details on PayPal.// Modify the create order data add_filter('ppcp_create_order_request_body_data', static function (array $data): array { if (isset($data['purchase_units'][0]['items'][0]['description'])) { $user_id = get_current_user_id(); $account_number = get_user_meta($user_id, 'account_number', true); $data['purchase_units'][0]['items'][0]['description'] = $account_number; } return $data; });
This snippet is similar to the first but is used when an order is updated (patched) after its initial creation. It ensures that the account number is also updated in such cases.
// Modify the patch order data add_filter('ppcp_patch_order_request_body_data', function($patches_array) { if (isset($patches_array[0]['value']['items'][0])) { $user_id = get_current_user_id(); $account_number = get_user_meta($user_id, 'account_number', true); $patches_array[0]['value']['items'][0]['description'] = $account_number; } return $patches_array; }, 10);
However, it depends on your implementation of custom field.
This is the only place where PayPal supports displaying custom information.
The? “Custom” field could in theory also be changed, but the plugin uses this field to match webhook events, so it should not be touched. But the memo field (= product description) should be safe to adjust.If you have any further questions or need additional assistance, please don’t hesitate to get in touch.
Kind regards,
KrystianHello @Krystain,
thank you for your patience, unfortunately I do not get any description in the PayPal transaction details for the ordered products. It only shows the count (1), the price (24,30€) and the taxes. Do i have to configure something to show the product/item description?Thanks in advance,
Best Regards,
MarcHello @Krystain,
I’ve checked both functions, unfortunately neither of those hooks work. The accounting number is never transferred to the paypal transaction details. Any hints why it is not working?Best Regards,
MarcHello @Krystain,
any update on this issue ?
Best Regards
MarcHello @forge12
I didn’t notice your responses because you tagged my nickname instead of my WP username (@inpsydekrystian). Sorry for the lack of response from our side.
We assume that the provided solution should work seamlessly. Therefore we suggest you contact us directly for further assistance. We may need to examine your system report or logs to better understand what’s happening. You can open a ticket with our service desk. Here’s how you can request support:?Request Support. Please make sure to include the URL of this thread in your ticket for reference.
Kind regards,
Krystian
- The topic ‘Custom Fieldd’ is closed to new replies.