Invoicing Shortcodes

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

Before starting, here is an overview of the Invoicing Plugin and the shortcodes it provides:

Plugin Icon
Payment forms, Buy now buttons and Invoicing System | GetPaid

"GetPaid is an efficient WordPress plugin that simplifies your e-commerce tasks. It features payment forms, 'Buy Now' buttons, and a robust invoicing system, making online transactions stress-free."

★★★★✩ (32) Active Installs: 5000+ Tested with: 6.3.2 PHP Version: 5.6
Included Shortcodes:
  • [getpaid_edit_address]
  • [wp_super_duper]

Invoicing [getpaid_edit_address] Shortcode

The ‘getpaid_edit_address’ shortcode from the Invoicing plugin is used to display an editable billing address form to logged-in users. It starts by checking if the user is logged in. If not, an error message is displayed. If the user is logged in, it displays a form with fields for the user’s address. Each field is generated dynamically based on the user’s current address. The form also includes a field for providing additional email addresses for payment notifications. The form ends with a ‘Save Address’ button.

Shortcode: [getpaid_edit_address]

Examples and Usage

Basic Example – The shortcode below displays the user’s address edit form if the user is logged in, otherwise, it will display an error message.

[getpaid_edit_address /]

Under the title ‘Advanced examples’, we can see how the shortcode can be used with different parameters:

Customizing the error message when the user is not logged in. In this case, the ‘error_message’ parameter is used to specify a custom error message.

[getpaid_edit_address error_message="You need to sign in to edit your address." /]

Displaying a custom label for the ‘Save Address’ button. In this case, the ‘submit_label’ parameter is used to specify a custom label for the button.

[getpaid_edit_address submit_label="Update Address" /]

Adding a custom class to the form. In this case, the ‘class’ parameter is used to add a custom class to the form.

[getpaid_edit_address class="my-custom-class" /]

Please note that these advanced examples are hypothetical and depend on the actual implementation of the shortcode and the parameters it supports.

PHP Function Code

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

Shortcode line:

add_shortcode( 'getpaid_edit_address', 'getpaid_display_address_edit_tab' );

Shortcode PHP function:

function getpaid_display_address_edit_tab() {

    if ( 0 === get_current_user_id() ) {
        return '<div class="bsui">' . aui()->alert(
            array(
                'type'        => 'error',
                'content'     => __( 'Your must be logged in to view this section', 'invoicing' ),
                'dismissible' => false,
            )
        ) . '</div>';
    }

    ob_start();
    ?>
        <div class="bsui">
            <?php wpinv_print_errors(); ?>
            <form method="post" class="getpaid-address-edit-form">

                <?php

                    foreach ( getpaid_user_address_fields() as $key => $label ) {

					// Display the country.
					if ( 'country' == $key ) {

						aui()->select(
							array(
								'options'     => wpinv_get_country_list(),
								'name'        => 'getpaid_address[' . esc_attr( $key ) . ']',
								'id'          => 'wpinv-' . sanitize_html_class( $key ),
								'value'       => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ),
								'placeholder' => $label,
								'label'       => wp_kses_post( $label ),
								'label_type'  => 'vertical',
								'class'       => 'getpaid-address-field',
                            ),
                            true
						);

					}

					// Display the state.
					elseif ( 'state' == $key ) {

						getpaid_get_states_select_markup(
							getpaid_get_user_address_field( get_current_user_id(), 'country' ),
							getpaid_get_user_address_field( get_current_user_id(), 'state' ),
							$label,
							$label,
							'',
							false,
							'',
							'getpaid_address[' . esc_attr( $key ) . ']',
                            true
						);

                        } else {

						aui()->input(
                            array(
                                'name'        => 'getpaid_address[' . esc_attr( $key ) . ']',
                                'id'          => 'wpinv-' . sanitize_html_class( $key ),
                                'placeholder' => $label,
                                'label'       => wp_kses_post( $label ),
                                'label_type'  => 'vertical',
                                'type'        => 'text',
                                'value'       => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ),
                                'class'       => 'getpaid-address-field',
                            ),
                            true
						);

                        }
                    }

                    aui()->input(
                        array(
                            'name'        => 'getpaid_address[email_cc]',
                            'id'          => 'wpinv-email_cc',
                            'placeholder' => 'email1@example.com, email2@example.com',
                            'label'       => __( 'Other email addresses', 'invoicing' ),
                            'label_type'  => 'vertical',
                            'type'        => 'text',
                            'value'       => sanitize_text_field( get_user_meta( get_current_user_id(), '_wpinv_email_cc', true ) ),
                            'class'       => 'getpaid-address-field',
                            'help_text'   => __( 'Optionally provide other email addresses where we should send payment notifications', 'invoicing' ),
                        ),
                        true
                    );

                    do_action( 'getpaid_display_address_edit_tab' );

                    aui()->input(
                        array(
                            'name'      => 'getpaid_profile_edit_submit_button',
                            'id'        => 'getpaid_profile_edit_submit_button',
                            'value'     => __( 'Save Address', 'invoicing' ),
                            'help_text' => __( 'New invoices will use this address as the billing address.', 'invoicing' ),
                            'type'      => 'submit',
                            'class'     => 'btn btn-primary btn-block submit-button',
                        ),
                        true
                    );

                    wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' );
                    getpaid_hidden_field( 'getpaid-action', 'edit_billing_details' );
                ?>

            </form>

        </div>
    <?php

    return ob_get_clean();
}

Code file location:

invoicing/invoicing/includes/user-functions.php

Invoicing [wp_super_duper] Shortcode

The WP Super Duper shortcode is a powerful tool that generates widget output. It takes arguments, processes them, and if content is present, it adds it to a special `html` argument. The shortcode also applies filters to widget settings, ensuring the output is as required. If the output is empty during preview, a placeholder is shown. The shortcode can be wrapped in a div with the same class as the widget, or not, based on the ‘no_wrap’ setting.

Shortcode: [wp_super_duper]

Parameters

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

  • args – Array of arguments to control the shortcode’s output
  • content – Enclosed content to be added to the `html` argument
  • html – Argument to hold enclosed content
  • widget_ops – An array to set widget options
  • classname – Sets the CSS class for the output div
  • no_wrap – If true, main content won’t be wrapped in a div
  • title – Argument to set the title of the output

Examples and Usage

Basic example – Displays the output of the shortcode with default parameters

[shortcode]

Advanced examples

Displaying the output of the shortcode with a custom HTML content

[shortcode html="Custom HTML content goes here"]

Displaying the output of the shortcode with a custom class name for the widget

[shortcode widget_ops_classname="custom-class-name"]

Displaying the output of the shortcode without wrapping it in a div

[shortcode no_wrap="true"]

Displaying the output of the shortcode with a custom title

[shortcode title="Custom Title"]

PHP Function Code

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

Shortcode line:

add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );

Shortcode PHP function:

function shortcode_output( $args = array(), $content = '' ) {
			$_instance = $args;

			$args = $this->argument_values( $args );

			// add extra argument so we know its a output to gutenberg
			//$args
			$args = $this->string_to_bool( $args );

			// if we have a enclosed shortcode we add it to the special `html` argument
			if ( ! empty( $content ) ) {
				$args['html'] = $content;
			}

			if ( ! $this->is_preview() ) {
				/**
				 * Filters the settings for a particular widget args.
				 *
				 * @param array          $args      The current widget instance's settings.
				 * @param WP_Super_Duper $widget    The current widget settings.
				 * @param array          $_instance An array of default widget arguments.
				 *
				 *@since 1.0.28
				 *
				 */
				$args = apply_filters( 'wp_super_duper_widget_display_callback', $args, $this, $_instance );

				if ( ! is_array( $args ) ) {
					return $args;
				}
			}

			$class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : '';
			$class .= " sdel-".$this->get_instance_hash();

			$class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
			$class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );

			$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
			$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );

			$shortcode_args = array();
			$output         = '';
			$no_wrap        = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
			if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) {
				$no_wrap = true;
			}
			$main_content = $this->output( $args, $shortcode_args, $content );
			if ( $main_content && ! $no_wrap ) {
				// wrap the shortcode in a div with the same class as the widget
				$output .= '<div class="' . $class . '" ' . $attrs . '>';
				if ( ! empty( $args['title'] ) ) {
					// if its a shortcode and there is a title try to grab the title wrappers
					$shortcode_args = array( 'before_title' => '', 'after_title' => '' );
					if ( empty( $instance ) ) {
						global $wp_registered_sidebars;
						if ( ! empty( $wp_registered_sidebars ) ) {
							foreach ( $wp_registered_sidebars as $sidebar ) {
								if ( ! empty( $sidebar['before_title'] ) ) {
									$shortcode_args['before_title'] = $sidebar['before_title'];
									$shortcode_args['after_title']  = $sidebar['after_title'];
									break;
								}
							}
						}
					}
					$output .= $this->output_title( $shortcode_args, $args );
				}
				$output .= $main_content;
				$output .= '</div>';
			} elseif ( $main_content && $no_wrap ) {
				$output .= $main_content;
			}

			// if preview show a placeholder if empty
			if ( $this->is_preview() && $output == '' ) {
				$output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
			}

			return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this );
		}

Code file location:

invoicing/invoicing/vendor/ayecode/wp-super-duper/wp-super-duper.php

Conclusion

Now that you’ve learned how to embed the Invoicing 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 *