OneClick Chat to Order Shortcodes

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

Before starting, here is an overview of the OneClick Chat to Order Plugin and the shortcodes it provides:

Plugin Icon
OneClick Chat to Order

"OneClick Chat to Order is a dynamic WordPress plugin that streamlines the ordering process by enabling direct WhatsApp communication with customers for quick, one-click orders."

★★★★☆ (69) Active Installs: 30000+ Tested with: 6.1.4 PHP Version: 5.6
Included Shortcodes:
  • [donate]
  • [wa-order]
  • [waorder]
  • [gdpr_link]

OneClick Chat to Order [donate] Shortcode

The OneClick-WhatsApp-Order plugin shortcode ‘donate’ creates a centered donation button. It encourages users to support the plugin’s development by buying the developer a coffee. The shortcode triggers a function that returns a styled HTML block. This block contains a heartfelt message and a PayPal donation link. The ‘Buy Me a Coffee’ button redirects users to the donation page.

Shortcode: [donate]

Examples and Usage

Basic Usage Example – Utilizing the shortcode to display a donation request

[donate /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'donate', 'wa_order_donate_button_shortcode' );

Shortcode PHP function:

function wa_order_donate_button_shortcode( $atts , $content = null ) {
  return '<center>
<div class="donate-container">
<p>To keep this plugin free, I spent cups of coffee building it. If you love and find it really useful for your business, you can always</p>
<a href="https://www.paypal.me/WalterPinem" target="_blank">
<button class="donatebutton">
  ☕ Buy Me a Coffee
  </button>
</a>
</div>
</center>';
}

Code file location:

oneclick-whatsapp-order/oneclick-whatsapp-order/admin/wa-admin-page.php

OneClick Chat to Order [wa-order] Shortcode

The OneClick-WhatsApp-Order shortcode enables a WordPress site to create a WhatsApp order button. It retrieves the user’s device type and adjusts the WhatsApp base URL accordingly. The shortcode also fetches a predefined phone number and message from the settings. It uses these details to construct a WhatsApp chat link. If the target setting is ‘_blank’, the chat opens in a new tab. The button text is customizable. If it’s not set, a default style is applied.

Shortcode: [wa-order]

Examples and Usage

Basic example – The shortcode ‘wa-order’ can be used to create a WhatsApp order button with predefined settings.

[wa-order /]

PHP Function Code

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

Shortcode line:

add_shortcode('wa-order', 'wa_order_shortcode_button');

Shortcode PHP function:

function wa_order_shortcode_button( $atts, $content = null ) {
		global $post;
        // WA Number from Setting
        $wanumberpage = get_option( 'wa_order_selected_wa_number_shortcode' );
        $postid = get_page_by_path( $wanumberpage, '', 'wa-order-numbers');
        if( empty( $postid) ) {
            $pid = 0;
        } else {
            $pid = $postid->ID;;
        }
        $phonenumb = get_post_meta($pid, 'wa_order_phone_number_input', true);

        $target_blank = get_option('wa_order_shortcode_target');
        $custom_message = get_option('wa_order_shortcode_message');

        //Check if it's mobile or desktop
        // Default WhatsApp base URL
        $iphone     = strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone' );
        $android    = strpos($_SERVER['HTTP_USER_AGENT'], 'Android' );
        $berry      = strpos($_SERVER['HTTP_USER_AGENT'], 'BlackBerry' );
        $ipod       = strpos($_SERVER['HTTP_USER_AGENT'], 'iPod' );
        $ipad       = strpos($_SERVER['HTTP_USER_AGENT'], 'iPad' );
        $webOS      = strpos($_SERVER['HTTP_USER_AGENT'], 'webOS' );
        $silk       = strpos($_SERVER['HTTP_USER_AGENT'], 'Silk/' );
        $kindle     = strpos($_SERVER['HTTP_USER_AGENT'], 'Kindle' );
        $opera      = strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mini' );
        $mobi       = strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mobi' );
        if ($iphone || $android || $berry || $ipod || $ipad || $webOS || $silk || $kindle || $opera || $mobi !== false ) {
          $wa_base = 'api';  
        } else {
            if ( get_option('wa_order_whatsapp_base_url') == 'api') {
               $wa_base_url = 'api'; 
            } else {
               $wa_base_url = 'web'; 
            }
           $wa_base = $wa_base_url; 
        }

        // Define shortcode button click target
        if ( $target_blank === '_blank' ) {
            $blank = 'target="_blank"';
        } else {
            $blank = '';
        }
   	 	if ( $button_text = get_option(sanitize_text_field('wa_order_shortcode_text_button')) )
 		//Check text button is filled or not
    	$out = "<a id=\"sendbtn\" class=\"shortcode_wa_button\" href=\"https://".$wa_base.".whatsapp.com/send?phone=" .$phonenumb. "&text=" . esc_html($custom_message) . "\" ".$blank."><span>" .do_shortcode($content). "$button_text</span></a>";
    	else
    	$out = "<a id=\"sendbtn\" class=\"shortcode_wa_button_nt\" href=\"https://".$wa_base.".whatsapp.com/send?phone=" .$phonenumb. "&text=" . esc_html($custom_message) . "\" ".$blank."><span>" .do_shortcode($content). "</span></a>";
    	return $out;
}

Code file location:

oneclick-whatsapp-order/oneclick-whatsapp-order/includes/wa-button.php

OneClick Chat to Order [waorder] Shortcode

The Oneclick-WhatsApp-Order plugin shortcode allows users to generate a customizable WhatsApp order button. Shortcode Name: ‘waorder’ shortcode is designed to create a WhatsApp button that directs users to a pre-filled WhatsApp chat when clicked. It uses device detection to ensure compatibility.

Shortcode: [waorder]

Parameters

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

  • phone – The recipient’s WhatsApp phone number
  • button – Text displayed on the button
  • message – Pre-filled text for the WhatsApp message
  • target – Determines if link opens in a new tab

Examples and Usage

Basic example – A simple way to use the shortcode to generate a WhatsApp order button with a specified phone number and button text.

[waorder phone="1234567890" button="Order Now"]

Advanced examples

Using the shortcode to generate a WhatsApp order button with a specified phone number, button text, and a pre-written message that will be sent when the button is clicked.

[waorder phone="1234567890" button="Order Now" message="I would like to place an order."]

Using the shortcode to generate a WhatsApp order button with a specified phone number, button text, pre-written message, and a target parameter set to open the WhatsApp application in a new tab or window.

[waorder phone="1234567890" button="Order Now" message="I would like to place an order." target="yes"]

Note: The ‘phone’ parameter should be the phone number where the order will be sent. The ‘button’ parameter is the text that will be displayed on the button. The ‘message’ parameter is the pre-written text that will be sent when the button is clicked. The ‘target’ parameter, when set to ‘yes’, will open the WhatsApp application in a new tab or window.

PHP Function Code

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

Shortcode line:

add_shortcode( 'waorder', 'wa_order_shortcode_generator_button' );

Shortcode PHP function:

function wa_order_shortcode_generator_button($atts, $content = null) {
    $atts = shortcode_atts(
        array(
            'phone'     => '',
            'button'    => '',
            'message'   => '',
            'target'    => '',
        ),
        $atts,
        'waorder'
    );
    $phone      = $atts['phone'];
    $button     = $atts['button'];
    $message    = $atts['message'];
    $target     = $atts['target'];
    //Check if it's mobile or desktop
    // Default WhatsApp base URL
    $iphone     = strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone' );
    $android    = strpos($_SERVER['HTTP_USER_AGENT'], 'Android' );
    $berry      = strpos($_SERVER['HTTP_USER_AGENT'], 'BlackBerry' );
    $ipod       = strpos($_SERVER['HTTP_USER_AGENT'], 'iPod' );
    $ipad       = strpos($_SERVER['HTTP_USER_AGENT'], 'iPad' );
    $webOS      = strpos($_SERVER['HTTP_USER_AGENT'], 'webOS' );
    $silk       = strpos($_SERVER['HTTP_USER_AGENT'], 'Silk/' );
    $kindle     = strpos($_SERVER['HTTP_USER_AGENT'], 'Kindle' );
    $opera      = strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mini' );
    $mobi       = strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mobi' );
    if ($iphone || $android || $berry || $ipod || $ipad || $webOS || $silk || $kindle || $opera || $mobi !== false ) {
      $wa_base = 'api';  
    } else {
        if ( get_option('wa_order_whatsapp_base_url') == 'api') {
           $wa_base_url = 'api'; 
        } else {
           $wa_base_url = 'web'; 
        }
       $wa_base = $wa_base_url; 
    }
    // Define shortcode button click target
    if ( 'yes' == $atts['target']) {
        $blank = 'target="_blank"';
    } else {
        $blank = '';
    }
    // Build the output
    $output     = "<a id=\"sendbtn\" class=\"shortcode_wa_button\" href=\"https://".$wa_base.".whatsapp.com/send?phone=" .$phone. "&text=" . esc_html($message) . "\" ".$blank."><span>" .do_shortcode($content). "$button</span></a>";
    return $output;
}

Code file location:

oneclick-whatsapp-order/oneclick-whatsapp-order/includes/wa-button.php

OneClick Chat to Order [gdpr_link] Shortcode

The OneClick-WhatsApp-Order plugin shortcode, ‘gdpr_link’, generates a hyperlink to the GDPR privacy page. This shortcode retrieves the page slug of the GDPR privacy page, fetches the page details, and returns a clickable link. The link, when clicked, opens the GDPR privacy page in a new tab.

Shortcode: [gdpr_link]

Examples and Usage

Basic example – The shortcode [gdpr_link] can be used to display a link to the GDPR privacy page. This is useful for adding a quick and easy GDPR compliance link to your website or online store.

[gdpr_link /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'gdpr_link', array( $this, 'get_gdpr_link' ) );

Shortcode PHP function:

function get_gdpr_link() {

			$page_slug 			= get_option( 'wa_order_gdpr_privacy_page' );
			$page 				= get_page_by_path( $page_slug );
			$page_title 		= get_the_title( $page );
			$page_permalink 	= site_url( '/'.$page_slug.'/' );

			return "<a href='$page_permalink' target='_blank'><strong>$page_title</strong></a>";
		}

Code file location:

oneclick-whatsapp-order/oneclick-whatsapp-order/includes/wa-gdpr.php

Conclusion

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