Below, you’ll find a detailed guide on how to add the Order on Mobile for Wocoommerce 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 Order on Mobile for Wocoommerce Plugin shortcode not to show or not to work correctly.
Before starting, here is an overview of the Order on Mobile for Wocoommerce Plugin and the shortcodes it provides:
"Order on Mobile for Woocommerce is a user-friendly plugin that allows customers to place their orders through WhatsApp. It simplifies the ordering process, making online shopping more convenient."
- [woo-order-on-whatsapp]
Order on Mobile for Wocoommerce [woo-order-on-whatsapp] Shortcode
The ‘woo-order-on-whatsapp’ shortcode is a key feature of the WooCommerce Order on WhatsApp plugin. It generates a button on the product page, allowing customers to place orders via WhatsApp. Upon activation, the shortcode checks if the cart has items. If true, it retrieves cart contents, creates a shared text, generates a WhatsApp link, and finally creates the order button.
Shortcode: [woo-order-on-whatsapp]
Examples and Usage
Basic example – A simple usage of the shortcode to add the ‘Order on Whatsapp’ button on the product page.
[woo-order-on-whatsapp]
PHP Function Code
In case you have difficulties debugging what causing issues with [woo-order-on-whatsapp]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'woo-order-on-whatsapp', [ $button_product_page, 'output_btn' ] );
Shortcode PHP function:
function output_btn() {
if ( is_cart() ) {
$this->cart_items = WC()->cart->get_cart_contents();
$shared_text = $this->create_shared_text();
$whatsapp_link = $this->create_whatsapp_link( $shared_text );
$this->create_button( $whatsapp_link, $this->target, $this->button_text );
}
}
Code file location:
woo-order-on-whatsapp/woo-order-on-whatsapp/includes/class-omw-plugin.php
Conclusion
Now that you’ve learned how to embed the Order on Mobile for Wocoommerce 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.
Leave a Reply