There are many plugins available that add Paypal payment forms to WordPress websites. For most instances a plugin isn’t even needed as Paypal provide the script for adding buttons to any website. Occasionally the Paypal supplied buttons don’t do exactly what is required. In this instance it is worth looking through the various Paypal plugins for WordPress.
WP Easy Paypal Payment Accept
Recently I had a requirement to implement a Paypal button and form, into a WordPress website, where the visitor to the website needed to fill an invoice number and a non-predefined dollar value. The values in the two fields needed to be sent to PayPal from where the visitor would pay. The Paypal supplied scripts don’t allow for this specific functionality so I looked in the WordPress for a plugin that could perform these actions.
I came across the WP Easy Paypal Payment Accept plugin that fulfilled most of the required functionality required so decided to give it a go.
Styling the Paypal form
There were a few items however that I needed to change with the WP Easy Paypal Payment Accept and some of these items couldn’t be performed with CSS so I decided to use Jquery. Here are the items amended and the accompanying Jquery used to achieve the required results.
Remove first four <br /> tags from HTML
The first thing I needed to do was remove the first four <br /> tags output by the plugin HTML. With Jquery the following worked
Remove consecutive<br /> tags from HTML
The HTML output by the WP Easy Paypal Payment Accept plugin includes multiple instances of <br /><br /> (i.e. double line breaks). For aesthetic purposes I wanted to keep only a single line break. The following Jquery does the trick
Change a string of words
As a text input field is being used (so the person entering the Paypal form can enter any dollar value into the field), my client required that the text output by the plugin, ‘Other Amount:’ be reworded. Changing the Plugin files isn’t a good idea as upon next update the changes will be lost. Changing the text with Jquery is therefore a great way to ensure that a string of text may be amended. Here is the script
Jquery is incredibly powerful and is quite simple to use where changing PHP, HTML or CSS in the PHP, HTML or CSS files isn’t possible or viable.