Below, you’ll find a detailed guide on how to add the WordPress Bitcoin Payments – Blockonomics 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 WordPress Bitcoin Payments – Blockonomics Plugin shortcode not to show or not to work correctly.
Before starting, here is an overview of the WordPress Bitcoin Payments – Blockonomics Plugin and the shortcodes it provides:
"WordPress Bitcoin Payments – Blockonomics is a powerful plugin that integrates Bitcoin payment gateways into your WordPress site, enabling seamless cryptocurrency transactions."
- [blockonomics_payment]
Blockonomics [blockonomics_payment] Shortcode
The Blockonomics Bitcoin Payments shortcode is designed to facilitate cryptocurrency transactions on your website. The shortcode triggers a function which checks the current filter and ensures the page is rendered correctly. It sanitizes GET requests for order details and selected cryptocurrency. If no crypto is selected, it loads a template prompting the user to select one. If an order and crypto are chosen, it decrypts the order and loads the checkout template. If only crypto is selected, it loads the crypto options template.
Shortcode: [blockonomics_payment]
Examples and Usage
Basic example – Displaying the checkout page for a specific order using the ‘show_order’ and ‘crypto’ parameters.
[blockonomics_payment show_order="your_order_hash" crypto="btc"]
Advanced examples
Displaying the checkout page for a specific order using the ‘show_order’ and ‘crypto’ parameters, where the ‘crypto’ parameter is left empty. This will load the ‘no_crypto_selected’ template.
[blockonomics_payment show_order="your_order_hash" crypto="empty"]
Displaying the cryptocurrency options for a payment using the ‘select_crypto’ parameter.
[blockonomics_payment select_crypto="true"]
Remember to replace the ‘your_order_hash’ with your actual order hash. These shortcodes can be used anywhere in your WordPress site where shortcodes are supported, such as in posts, pages, widgets, etc.
PHP Function Code
In case you have difficulties debugging what causing issues with [blockonomics_payment]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('blockonomics_payment', 'add_payment_page_shortcode');
Shortcode PHP function:
function add_payment_page_shortcode() {
// This is to make sure we only run the shortcode when executed to render the page.
// Because the shortcode can be run multiple times by other plugin like All in One SEO.
// Where it tries to build SEO content from the shortcode and this could lead to checkout page not loading correctly.
$currentFilter = current_filter();
if ($currentFilter == 'wp_head'){
return;
}
$show_order = isset($_GET["show_order"]) ? sanitize_text_field(wp_unslash($_GET['show_order'])) : "";
$crypto = isset($_GET["crypto"]) ? sanitize_key($_GET['crypto']) : "";
$select_crypto = isset($_GET["select_crypto"]) ? sanitize_text_field(wp_unslash($_GET['select_crypto'])) : "";
$blockonomics = new Blockonomics;
if ($crypto === "empty") {
return $blockonomics->load_blockonomics_template('no_crypto_selected');
} else if ($show_order && $crypto) {
$order_id = $blockonomics->decrypt_hash($show_order);
return $blockonomics->load_checkout_template($order_id, $crypto);
} else if ($select_crypto) {
return $blockonomics->load_blockonomics_template('crypto_options');
}
}
Code file location:
blockonomics-bitcoin-payments/blockonomics-bitcoin-payments/blockonomics-woocommerce.php
Conclusion
Now that you’ve learned how to embed the WordPress Bitcoin Payments – Blockonomics 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