Booking System Shortcode

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

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

Plugin Icon
Pinpoint Booking System – #1 WordPress Booking Plugin

"Pinpoint Booking System is a top-tier WordPress Booking Plugin. With this, effortlessly manage and customize your bookings. Fast, reliable, and easy to use – it's your ultimate booking assistant."

★★★☆✩ (179) Active Installs: 5000+ Tested with: 6.3.2 PHP Version: false
Included Shortcodes:
  • [dopbs]

Booking System [dopbs] Shortcode

The ‘dopbs’ shortcode is a powerful tool from the booking-system plugin. It allows you to display a booking calendar with customizable language, view, and WooCommerce integration. The shortcode extracts the attributes and checks if they are set. If not, it assigns default values. It handles language settings, including compatibility with ICL_LANGUAGE_CODE. It also manages WooCommerce integration, with options to add to cart, set position, and link with a specific product. The shortcode ends by displaying the booking calendar with the defined settings.

Shortcode: [dopbs]

Parameters

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

  • class – Defines the class name of the booking system
  • lang – Sets the language for the booking system interface
  • id – Specifies the unique identifier of the booking system
  • view – Determines if the booking system is viewable or not
  • woocommerce – Activates the WooCommerce compatibility mode
  • woocommerce_add_to_cart – Enables or disables the add-to-cart feature in WooCommerce
  • woocommerce_position – Sets the position of the booking system in the WooCommerce layout
  • woocommerce_product_id – Assigns the booking system to a specific WooCommerce product

Examples and Usage

Basic example – Displaying the booking system with default settings.

[dopbs /]

Advanced examples

Displaying the booking system with a specific language (for example, English) and a specific id (for example, 2).

[dopbs lang='en' id=2 /]

Displaying the booking system with a specific view (for example, true) and a specific WooCommerce product id (for example, 3).

[dopbs view='true' woocommerce_product_id=3 /]

Displaying the booking system with a specific WooCommerce position (for example, summary) and a specific WooCommerce add to cart option (for example, true).

[dopbs woocommerce_position='summary' woocommerce_add_to_cart='true' /]

Displaying the booking system with a specific WooCommerce option (for example, true) and a specific language (for example, French).

[dopbs woocommerce='true' lang='fr' /]

PHP Function Code

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

Shortcode line:

add_shortcode('dopbs', array(&$this, 'shortcode'));

Shortcode PHP function:

function shortcode($atts){
                global $DOPBSP;
                global $post;
                
                extract(shortcode_atts(array('class' => 'dopbsp'), $atts));
                        
                if(isset($atts)) {
                    
                    if (is_array($atts)) {
                        
                        if (!array_key_exists('lang', $atts)){
                            $atts['lang'] = DOPBSP_CONFIG_TRANSLATION_DEFAULT_LANGUAGE;
                        }
                        
                        if(defined('ICL_LANGUAGE_CODE')) {
                            $atts['lang'] = ICL_LANGUAGE_CODE;
                            $atts['lang'] = str_replace('pt-br', 'pt', $atts['lang']);
                            $atts['lang'] = str_replace('pt-pt', 'pt', $atts['lang']);
                            $atts['lang'] = str_replace('nb', 'no', $atts['lang']);
                            $atts['lang'] = str_replace('zh-hans', 'zh', $atts['lang']);
                        }
                                
                        if (!array_key_exists('id', $atts)){
                            $atts['id'] = 1;
                        } 
                                
                        if (!array_key_exists('view', $atts)){
                            $atts['view'] = 'false';
                        } 

                        if (!array_key_exists('woocommerce', $atts)){
                            $atts['woocommerce'] = 'false';
                        }

                        if (!array_key_exists('woocommerce_add_to_cart', $atts)){
                            $atts['woocommerce_add_to_cart'] = 'false';
                        }

                        if (!array_key_exists('woocommerce_position', $atts)){
                            $atts['woocommerce_position'] = 'summary';
                        }

                        if (!array_key_exists('woocommerce_product_id', $atts)){
                            $atts['woocommerce_product_id'] = 0;
                        }
                    } else {
                        $atts['lang'] = DOPBSP_CONFIG_TRANSLATION_DEFAULT_LANGUAGE;
                        $atts['id'] = 1;
                        $atts['view'] = 'false';
                    }
                
                } else {
                    $atts['lang'] = DOPBSP_CONFIG_TRANSLATION_DEFAULT_LANGUAGE;        
                    $atts['id'] = 1;
                    $atts['view'] = 'false';
                }
                
                $atts['lang'] = get_post_meta($post->ID, 'dopbsp_woocommerce_language', true) == '' ? $atts['lang']:get_post_meta($post->ID, 'dopbsp_woocommerce_language', true);
                $content = $DOPBSP->classes->frontend_calendar->display($atts);
                
                return $content;
            }

Code file location:

booking-system/booking-system/includes/class-frontend.php

Conclusion

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