Below, you’ll find a detailed guide on how to add the WooCommerce Single Page Checkout 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 WooCommerce Single Page Checkout Plugin shortcode not to show or not to work correctly.
Before starting, here is an overview of the WooCommerce Single Page Checkout Plugin and the shortcodes it provides:
"WooCommerce Single Page Checkout is a user-friendly WordPress plugin that simplifies the checkout process by allowing customers to complete purchases on one page, enhancing their shopping experience."
- [rg108_woocommerce_single_page_checkout]
[rg108_woocommerce_single_page_checkout] Shortcode
The ‘rg108_woocommerce_single_page_checkout’ shortcode is designed to display both the WooCommerce cart and checkout on the same page. This shortcode helps to streamline the checkout process, making it more user-friendly. This shortcode retrieves the ‘cart_colum’ option and based on its value, assigns a bootstrap class to set the column width. It then uses this class to display the cart and checkout sections in a responsive layout.
Shortcode: [rg108_woocommerce_single_page_checkout]
Examples and Usage
Basic example – The basic usage of the shortcode ‘rg108_woocommerce_single_page_checkout’ to display the WooCommerce cart and checkout on the same page.
[rg108_woocommerce_single_page_checkout]
PHP Function Code
In case you have difficulties debugging what causing issues with [rg108_woocommerce_single_page_checkout]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('rg108_woocommerce_single_page_checkout', 'rg108_single_page_checkout');
Shortcode PHP function:
function rg108_single_page_checkout( $atts ) {
$colum_option = get_option('cart_colum');
if($colum_option=="2"){
$colum_option_class='col-md-6';
}else{
$colum_option_class='col-md-12';
}
?>
<div class="row">
<div class="<?php echo $colum_option_class; ?>">
<?php echo do_shortcode ('[woocommerce_cart]') ?>
</div>
<div class="<?php echo $colum_option_class; ?>">
<?php echo do_shortcode ('[woocommerce_checkout]') ?>
</div>
</div>
<?php
}
Code file location:
woo-single-page-checkout/woo-single-page-checkout/includes/functions.php
Conclusion
Now that you’ve learned how to embed the WooCommerce Single Page Checkout 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