Custom Field
-
Hi,
Love the plugin so far. I just need 1 option to make it perfect. On my checkout page, would it be possible to add a textbox that ask for information, for example like favorite color. Once they submit the payment, if the payment is successful, that information they typed into the textbox is sent to the database, or sent to another server like this : http://server.com?color=WhatTheyTyped
-
Thank you for your suggestion. I have submitted a message to the developers to investigate further your request.
Kind regards
We will look at adding something for it.
For me, it would be ideal to have a checkbox – in particular for confirming that the purchaser is happy to receive further emails from us. Otherwise any follow up emails are legally considered spam!
Otherwise thanks for a really good plugin.
Thank you for your input, gentlemen. And also thanks for example usage cases. I didn’t quite get why would you need to send a value to some other server, but a checkbox to subscribe to newsletter is pretty clear usage case.
Stripe doesn’t allow to insert any custom fields into its payment pop-up. So this additional field (or checkbox) should be added either before the payment or after it (on checkout results page, for example).
Can’t give you any ETA at the moment, but this would be surely added to the things to implement.
I didnβt quite get why would you need to send a value to some other server
It’s actually on the same server. Let’s say for example that I have users who pay for service somewhere else. If they pay for it via stripe, their username should continue to be “VIP” or something like that. Right now, all I can do is redirect them to a page after they pay, I have no way of updating my database and giving them VIP status.
I thought that on successful payment, it would take their username that they type in and sends it to another PHP script I create, and add their username in the database. That’s just one way I thought of doing it
@dadelayer, thanks for your explanations. Will try to think of a way how this could be achieved.
Ok, I figured how this could be done. It would work the same as custom amount is currently working. E.g. there will be an input (or a checkbox; depending what you select in the settings), which you can use for your purposes. It can be made mandatory in the settings as well, so users won’t be able to proceed to the payment unless they fill it (or click the checkmark – this could be useful for accepting terms and conditions, for example). This input’s name and value would be placed into the order info, plus emailed to you if you set it in the settings.
To catch the value programmatically, the plugin will do_action() with the array containing user information he entered during the payment, including the custom field name and value. You can then attach to this hook and do what you want with the entered username or checkbox status.
Does it sounds like a plan?
@alexanderfoxc, that sounds fantastic. With the username information or checkbox confirmation data after the payment, I could then go ahead and do some backend things with it.
Ok, I have assembled a testing version of the plugin with Custom Field functionality implemented – https://stripe-plugins.com/testing/stripe-payments-1.7.2_testing1.zip
Custom Field Settings are located in Stripe Payments -> Settings, Advanced Settings tab. I think those pretty much self-explanatory.
To be able to receive the information entered in this custom field by email, you need to add {custom_field} tag to email body on Email Settings page.
To receive the value programmatically (that’s for you @dadelayer), you need to listen for ‘asp_stripe_payment_completed’ hook (e.g. add_action(‘asp_stripe_payment_completed’,’your_function_to_handle_it’,10,2); ). The action is passing 2 parameters – $post_data and $charge. What you need is in $post_data[‘custom_field_value’]. Keep in mind it could be not set (if custom field is a checkbox), so before working with it, make sure it’s set ( if (isset($post_data[‘custom_field_value’])) { //do your thing} ). $post_data array also has some additional information available, like button or product name, paid amount etc.
Please let me know how it goes.
-
This reply was modified 8 years, 3 months ago by
Alexander C..
Alexander,
I’ve implemented and tested (as checkbox only), all seems fine thanks. A few minor observations:
1. Settings – Custom Field Settings – heading says “Filed Type” instead of Field Type
2. Under ‘Enable for all Buttons and Products’ there’s a typo “… when shorcode…”
3. Ideally there should be a way to opt for the custom field to be included in the Product display (/asp-products/productname/), but if you have a page with a shortcode call instead you can get around this.
4. It would be great to include in the documentation info about the formatting so we can modify in custom css.But this works for me thanks!
Roger
The new version of this plugin has a feature for it.
Thank you. We have fixed the typo.
One more suggestion – it can help to have a sentence of explanation for the custom field, so a larger (or expansible) text box in the settings area would be helpful.
Thanks for the update guys. I was trying this out and it works but I’m going to have to add some custom code into the stripe::success_payment otherwise people can just add their own username to my database haha
Hey gentlemen, thank you for your input. I’ve been away for a couple of days, but as you can see our team is doing the job regardless of my presence π
@rogbiz, thank you for your detailed report. We have fixed typos, also added a link to documentation in plugin settings. If you need any help regarding CSS, please do let me know. We will add this to the documentation a bit later though, when everything is gathered in one piece.
@dadelayer, you can just catch the hook I was referring to in my previous message and do all the checks etc. there. No need to add any additional code to the plugin itself (it will get overwritten during the update), so just make it in a proper way once and you won’t have to worry about it anymore π
-
This reply was modified 8 years, 3 months ago by
The topic ‘Custom Field’ is closed to new replies.