WooCommerce Confirm Payment Shortcodes

Below, you’ll find a detailed guide on how to add the WooCommerce Confirm Payment 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 WooCommerce Confirm Payment Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the WooCommerce Confirm Payment Plugin and the shortcodes it provides:

Plugin Icon
WooCommerce Confirm Payment

"WooCommerce Confirm Payment is an essential plugin that adds a confirmation step to the payment process in your WooCommerce store, enhancing transaction security."

★★★★★ (11) Active Installs: 3000+ Tested with: 5.5.13 PHP Version: false
Included Shortcodes:
  • [wcp_confirm_payment_form]
  • [wcp_confirm_payment_button]

WooCommerce Confirm Payment [wcp_confirm_payment_form] Shortcode

The wc-confirm-payment plugin shortcode is used to display a payment confirmation form. It’s designed to streamline the checkout process in WooCommerce. This shortcode triggers the ‘print_confirm_payment_form’ function. It includes a PHP file that contains the form layout and returns it as HTML. This makes it easy to insert the form anywhere on your site using the shortcode.

Shortcode: [wcp_confirm_payment_form]

Examples and Usage

Basic example – The simplest way to use this shortcode is to place it in your posts or pages without any parameters. This will display the default payment confirmation form.

[wcp_confirm_payment_form /]

Advanced examples

While the basic shortcode usage is quite straightforward, you can also utilize additional parameters to customize the behavior of the payment confirmation form. Here are a few examples:

1. Display a custom message on the form:

[wcp_confirm_payment_form message="Your payment is being processed. Please wait a moment." /]

2. Specify a return URL where users will be redirected after confirming their payment:

[wcp_confirm_payment_form return_url="https://yourwebsite.com/thank-you/" /]

3. Combine multiple parameters to create a more customized experience:

[wcp_confirm_payment_form message="Your payment is being processed. Please wait a moment." return_url="https://yourwebsite.com/thank-you/" /]

Remember, the values given to the parameters in these examples are just placeholders. You should replace them with your own message and URL.

PHP Function Code

In case you have difficulties debugging what causing issues with [wcp_confirm_payment_form] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wcp_confirm_payment_form', array( $this, 'print_confirm_payment_form' ) );

Shortcode PHP function:

                    function print_confirm_payment_form( $atts, $content = '' ) {

    ob_start();

    include( 'partials/woocommerce-confirm-payment-confirm-form.php' );

    $html = ob_get_contents();
    ob_end_clean();

    return $html;

  }
                    

Code file location:

wc-confirm-payment/wc-confirm-payment/public/class-woocommerce-confirm-payment-public.php

WooCommerce Confirm Payment [wcp_confirm_payment_button] Shortcode

The ‘wcp_confirm_payment_button’ shortcode from the wc-confirm-payment plugin is used to generate a payment confirmation button. The shortcode triggers the ‘print_confirm_payment_button’ function. This function returns a clickable button. If an ‘order_id’ attribute is provided, the button links to a specific confirmation payment URL. Otherwise, it links to a general confirmation payment URL.

Shortcode: [wcp_confirm_payment_button]

Parameters

Here is a list of all possible wcp_confirm_payment_button shortcode parameters and attributes:

  • order_id – The unique identifier of the specific order

Examples and Usage

Basic Example – A simple usage of the wc-confirm-payment plugin shortcode. This will display a “Confirm Payment” button. The order ID is not specified, so the button will link to the default confirm payment URL.

[wcp_confirm_payment_button /]

Advanced Examples

Specifying an order ID – This example demonstrates how to use the shortcode with an order ID parameter. The “Confirm Payment” button will link to the confirm payment URL for the specified order.

[wcp_confirm_payment_button order_id=123 /]

Using the shortcode within a text – This example shows how to use the shortcode within a text. The “Confirm Payment” button will be part of the paragraph. The order ID is specified, so the button will link to the confirm payment URL for that order.

<p>Please click on the following button to confirm your payment: [wcp_confirm_payment_button order_id=123 /]</p>

PHP Function Code

In case you have difficulties debugging what causing issues with [wcp_confirm_payment_button] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wcp_confirm_payment_button', array( $this, 'print_confirm_payment_button' ) );

Shortcode PHP function:

                    function print_confirm_payment_button( $atts, $content = '' ) {

    return sprintf(
      '<a href="%s" class="button wcp-button-confirm">%s</button>',
      empty( $atts['order_id'] ) ? wcp_get_confirm_payment_url() : wcp_get_confirm_payment_url( $atts['order_id'] ),
      __( 'Confirm payment', 'woocommerce-confirm-payment' )
    );

  }
                    

Code file location:

wc-confirm-payment/wc-confirm-payment/public/class-woocommerce-confirm-payment-public.php

Conclusion

Now that you’ve learned how to embed the WooCommerce Confirm Payment 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.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *