Woo Swish e-commerce Shortcode

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

Before starting, here is an overview of the Woo Swish e-commerce Plugin and the shortcodes it provides:

Plugin Icon
Woo Swish e-commerce

"Woo Swish e-commerce is a dynamic WordPress plugin designed to streamline online transactions. It effortlessly integrates with your WooCommerce store, enabling seamless Swish payments."

★★★★☆ (18) Active Installs: 2000+ Tested with: 6.3.2 PHP Version: 7.0
Included Shortcodes:
  • [bjorntech_swish_wait_page]

Woo Swish e-commerce [bjorntech_swish_wait_page] Shortcode

The Woo-Swish-E-Commerce shortcode handles the display of the Swish payment waiting page. It fetches the order ID and loads the Swish logo and status message. The shortcode then generates the Swish Thankyou page content, which is returned as the wait page content.

Shortcode: [bjorntech_swish_wait_page]

Examples and Usage

Basic example – The shortcode displays the Swish wait page for the order specified by the ‘bt_swish_order_id’ parameter.

[bjorntech_swish_wait_page bt_swish_order_id=1 /]

Advanced examples

Using the shortcode to display the Swish wait page for the order specified by the ‘bt_swish_order_id’ parameter, and applying a custom filter to modify the HTML content of the page. The ‘swish_custom_filter’ function is defined in the theme’s functions.php file.

function swish_custom_filter($content, $order_id) {
    // ... custom code here ...
    return $content;
}
add_filter('swish_thankyou_page_html_content', 'swish_custom_filter', 10, 2);

[bjorntech_swish_wait_page bt_swish_order_id=1 /]

Using the shortcode to display the Swish wait page for the order specified by the ‘bt_swish_order_id’ parameter, and overriding the standard checkout page with a custom page template. The ‘swish_custom_template’ function is defined in the theme’s functions.php file.

function swish_custom_template($template) {
    // ... custom code here ...
    return $template;
}
add_filter('template_include', 'swish_custom_template');

[bjorntech_swish_wait_page bt_swish_order_id=1 /]

PHP Function Code

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

Shortcode line:

add_shortcode('bjorntech_swish_wait_page', array($this, 'swish_wait_page_content'));

Shortcode PHP function:

function swish_wait_page_content($atts)
        {
            $order_id = isset($_GET['bt_swish_order_id']) ? intval($_GET['bt_swish_order_id']) : 0;

            WC_SEC()->logger->add('Using standard checkout page for internal wait page - order ' . $order_id);
            $swish_logo_text = plugin_dir_url(__FILE__) . 'assets/images/Swish_Logo_Text.png';
            $swish_circle = plugin_dir_url(__FILE__) . 'assets/images/Swish_Logo_Circle.png';
            $swish_status = __('Start your Swish App and authorize the payment', 'woo-swish-e-commerce');

            ob_start();

            require_once WCSW_PATH . 'views/swish-thankyou-separate-internal.php';
            $swish_thankyou_code = ob_get_clean();

            // Return the Swish Thankyou code as the content of the wait page
            return apply_filters('swish_thankyou_page_html_content', $swish_thankyou_code, $order_id);
        }

Code file location:

woo-swish-e-commerce/woo-swish-e-commerce/woo-swish-e-commerce.php

Conclusion

Now that you’ve learned how to embed the Woo Swish e-commerce 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 *