WP EasyPay – Square for WordPress Shortcode

Below, you’ll find a detailed guide on how to add the WP EasyPay – Square for WordPress Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the WP EasyPay – Square for WordPress Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the WP EasyPay – Square for WordPress Plugin and the shortcodes it provides:

Plugin Icon
WP EasyPay – Square for WordPress

"WP EasyPay – Square for WordPress is an efficient tool that seamlessly integrates Square payment gateway with your WordPress site. The plugin is perfect for simple transactions and donations."

★★★☆✩ (35) Active Installs: 2000+ Tested with: 6.3.2 PHP Version: 7.0
Included Shortcodes:
  • [wpep-form]

WP EasyPay – Square for WordPress [wpep-form] Shortcode

The WP Easy Pay shortcode is a tool that renders a payment form on your site. It checks if the site has HTTPS enabled and if the form exists in the database. If these conditions are met, it fetches the form’s data, including a square token for payment processing. If the form is trashed or doesn’t exist, it informs the user. If no form ‘id’ is provided, it prompts for one. If HTTPS is not enabled, it warns about the lack of SSL.

Shortcode: [wpep-form]

Parameters

Here is a list of all possible wpep-form shortcode parameters and attributes:

  • id – The specific identifier of the payment form.

Examples and Usage

Basic example – Use the shortcode to display a payment form by referencing the ID of the form.

[wpep-form id=1 /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'wpep-form', 'wpep_render_payment_form' );

Shortcode PHP function:

function wpep_render_payment_form( $atts ) {

	if ( isset( $_SERVER['HTTPS'] ) && 'on' === $_SERVER['HTTPS'] ) {

		if ( ! is_admin() ) {

			if ( isset( $atts['id'] ) ) {

				$form_post            = get_post( $atts['id'] );
				$wpep_current_form_id = $atts['id'];

				if ( null !== $form_post && 'trash' === $form_post->post_status ) {

					return 'This form has been trashed by the admin';
				}

				if ( null === $form_post ) {

					return 'Form does not exist';
				}

				$square_token = wpep_get_square_token( $wpep_current_form_id );

				if ( ! isset( $square_token ) || empty( $square_token ) ) {

					ob_start();

					require WPEP_ROOT_PATH . 'views/frontend/no-square-setup.php';
					return ob_get_clean();

				}

				ob_start();
				$payment_type = get_post_meta( $wpep_current_form_id, 'wpep_square_payment_type', true );
				require WPEP_ROOT_PATH . 'views/frontend/parent-view.php';

				return ob_get_clean();

			} else {

				return "Please provide 'id' in shortcode to display the respective form";

			}
		}
	}

	if ( ! isset( $_SERVER['HTTPS'] ) || 'on' !== $_SERVER['HTTPS'] ) {

		ob_start();

		require WPEP_ROOT_PATH . 'views/frontend/no-ssl.php';
		return ob_get_clean();

	}
}

Code file location:

wp-easy-pay/wp-easy-pay/modules/render_forms/form-render-shortcode.php

Conclusion

Now that you’ve learned how to embed the WP EasyPay – Square for WordPress Plugin shortcode, 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 *