Below, you’ll find a detailed guide on how to add the Quick Paypal Payments Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Quick Paypal Payments Plugin shortcodes not to show or not to work correctly.
Before starting, here is an overview of the Quick Paypal Payments Plugin and the shortcodes it provides:
![Plugin Icon](https://ps.w.org/quick-paypal-payments/assets/icon-128x128.png?rev=1069456)
"Quick Paypal Payments is an efficient WordPress plugin that simplifies the process of PayPal payments on your site, delivering a straightforward and secure transaction experience for users."
- [qpp]
- [qppreport]
- [test]
Quick Paypal Payments [qpp] Shortcode
The Quick Paypal Payments (QPP) shortcode enables seamless integration of PayPal payment forms into your WordPress site. It registers scripts, styles, and handles form submission and validation. The shortcode’s PHP function ‘qpp_loop’ manages the payment process. It checks if scripts are registered, enqueues necessary scripts and styles, and sets up the payment form. It also validates form submissions and processes payments, ensuring smooth transactions.
Shortcode: [qpp]
Parameters
Here is a list of all possible qpp shortcode parameters and attributes:
id
– Unique identifier for the payment formform
– Determines the form to be usedamount
– Sets the payment amountcombine
– Merges multiple items into a single paymentitemamount
– Sets the amount for individual itemssc
– Used for sanitizing the form data
Examples and Usage
Basic example – Display a default payment form using the ‘qpp’ shortcode. This will generate a form with the default settings as defined in your Quick Paypal Payments settings.
[qpp /]
Advanced examples
Display a specific payment form with a predefined amount. This is useful when you want to set a fixed amount for a specific product or service. In this example, the ‘form’ attribute is used to specify the form ID, and the ‘amount’ attribute is used to set the payment amount.
[qpp form="form1" amount="50" /]
Display a payment form with a predefined amount and a reference ID. This can be useful for tracking payments related to specific items or services. In this example, the ‘form’ attribute is used to specify the form ID, the ‘amount’ attribute is used to set the payment amount, and the ‘id’ attribute is used to set the reference ID.
[qpp form="form1" amount="50" id="ref123" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [qpp]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'qpp', 'qpp_loop' );
Shortcode PHP function:
function qpp_loop( $atts )
{
$qpp_setup = qpp_get_stored_setup();
if ( !wp_script_is( 'qpp_script', 'registered' ) ) {
qpp_register_scripts();
}
wp_enqueue_script( 'paypal_checkout_js' );
wp_enqueue_script( 'qpp_script' );
wp_enqueue_style( 'qpp_style' );
if ( $qpp_setup['location'] == 'php' ) {
qpp_create_css_file( '' );
wp_enqueue_style( 'qpp_custom_style' );
} else {
add_action( 'wp_head', 'qpp_head_css' );
}
wp_enqueue_script( "jquery-effects-core" );
wp_enqueue_script( 'jquery-ui-datepicker' );
wp_enqueue_style( 'jquery-style', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );
/*
Let the rest of wordpress know that there is a shortcode that we're looking for!
*/
global $qpp_shortcode_exists, $qpp_end_loop ;
if ( $qpp_end_loop ) {
return;
}
$qpp_shortcode_exists = true;
$form = $amount = $id = '';
$v = formulate_v(
$atts,
$form,
$amount,
$id
);
$form = ( $form ? $form : 'default' );
ob_start();
$v = array();
$form = $amount = $id = '';
$v = formulate_v(
$atts,
$form,
$amount,
$id
);
if ( isset( $_POST['qppsubmit' . $form] ) || isset( $_POST['qppsubmit' . $form . '_x'] ) ) {
$sc = qpp_sanitize( $_POST['sc'] );
$combine = isset( $_REQUEST['combine'] ) && 'checked' == $_REQUEST['combine'];
$itemamount = ( isset( $_REQUEST['itemamount'] ) ? sanitize_text_field( $_REQUEST['itemamount'] ) : 0 );
$formerrors = array();
// dont validate if only activating a coupon
if ( !isset( $_POST['qppapply' . $form] ) && !qpp_verify_form(
$v,
$formerrors,
$form,
$sc
) ) {
qpp_display_form(
$v,
$formerrors,
$form,
$atts
);
} else {
if ( $amount ) {
$v['amount'] = $amount;
}
if ( $id ) {
$v['reference'] = $id;
}
$payment = qpp_process_values(
$v,
$form,
$combine,
$itemamount
);
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- need to ensure escaped in origin of use wp_kses @TODO
echo qpp_process_form(
$v,
$form,
$payment,
$combine,
$itemamount
) ;
wp_add_inline_script( 'qpp_script', 'document.getElementById("frmCart").submit()', 'after' );
}
} else {
$digit1 = mt_rand( 1, 10 );
$digit2 = mt_rand( 1, 10 );
if ( $digit2 >= $digit1 ) {
$v['thesum'] = "{$digit1} + {$digit2}";
$v['answer'] = $digit1 + $digit2;
} else {
$v['thesum'] = "{$digit1} - {$digit2}";
$v['answer'] = $digit1 - $digit2;
}
qpp_display_form(
$v,
array(),
$form,
$atts
);
}
$output_string = ob_get_contents();
ob_end_clean();
return $output_string;
}
Code file location:
quick-paypal-payments/quick-paypal-payments/legacy/quick-paypal-payments.php
Quick Paypal Payments [qppreport] Shortcode
The Quick Paypal Payments (QPP) shortcode is a tool that generates a report of all payments. It uses the function ‘qpp_report’ to extract data from a specified form.
Shortcode: [qppreport]
Parameters
Here is a list of all possible qppreport shortcode parameters and attributes:
form
– Specifies the form to display the payment report for
Examples and Usage
Basic Example – A quick PayPal payment report can be generated using the shortcode ‘qppreport’ without any parameters. The shortcode will call the function ‘qpp_report’ which in turn calls the function ‘qpp_messagetable’ with default parameters.
[qppreport /]
Advanced Examples
Generate a quick PayPal payment report for a specific form by passing the form ID as a parameter. The shortcode ‘qppreport’ is used with the ‘form’ parameter set to the ID of the form.
[qppreport form="form1" /]
Generate a quick PayPal payment report for multiple forms by passing multiple form IDs as parameters. The shortcode ‘qppreport’ is used with the ‘form’ parameter set to the IDs of the forms separated by commas.
[qppreport form="form1, form2, form3" /]
Please note that the values ‘form1’, ‘form2’, and ‘form3’ are placeholders for the actual form IDs. Replace them with the IDs of the forms you want to generate a report for.
PHP Function Code
In case you have difficulties debugging what causing issues with [qppreport]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'qppreport', 'qpp_report' );
Shortcode PHP function:
function qpp_report( $atts )
{
extract( shortcode_atts( array(
'form' => '',
), $atts ) );
return qpp_messagetable( $form, '' );
}
Code file location:
quick-paypal-payments/quick-paypal-payments/legacy/quick-paypal-payments.php
Quick Paypal Payments [test] Shortcode
The Quick-PayPal-Payments shortcode is a function that triggers a specific action. It uses the ‘add_shortcode’ function to register a new shortcode ‘test’. This shortcode calls the ‘build_shortcode’ function. It creates a new instance of the User_Template_Loader class and sets template data. The ‘ob_start’ function is used to turn on output buffering. The ‘get_template_part’ method is then used to load a specific template part ‘test’. The ‘ob_get_clean’ function is used to get the current buffer contents and delete the output buffer, storing the HTML content. Finally, the HTML content is returned when the shortcode is used.
Shortcode: [test]
Examples and Usage
Basic example – A simple usage of the shortcode to display a predefined message.
[test]
Advanced examples
Using the shortcode to display a custom message by passing it as a parameter.
[test message="This is a custom message"]
Using the shortcode to display a message and also pass an additional parameter ‘color’ to change the color of the message.
[test message="This is a custom message" color="red"]
Note: These examples assume that the ‘build_shortcode’ function has been modified to accept and handle additional parameters.
PHP Function Code
In case you have difficulties debugging what causing issues with [test]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'test', array( $this, 'build_shortcode' ) );
Shortcode PHP function:
function build_shortcode( $atts ) {
$template_loader = new User_Template_Loader;
$template_loader->set_template_data( array( 'message' => 'test shortcode message etc' ) );
ob_start();
$template_loader->get_template_part( 'test' );
$html = ob_get_clean();
return $html;
}
Code file location:
quick-paypal-payments/quick-paypal-payments/ui/user/class-frontend.php
Conclusion
Now that you’ve learned how to embed the Quick Paypal Payments Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.
Leave a Reply