Below, you’ll find a detailed guide on how to add the TeraWallet 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 TeraWallet Plugin shortcodes not to show or not to work correctly.
Before starting, here is an overview of the TeraWallet Plugin and the shortcodes it provides:
"TeraWallet is a superior WooCommerce Wallet System offering Cashback Rewards, Partial Payment, and Wallet Refunds. Enhance your e-commerce site with TeraWallet and offer your customers a seamless shopping experience."
- [tw-sell-content]
- [woo-wallet]
- [mini-wallet]
TeraWallet [tw-sell-content] Shortcode
The Woo-Wallet plugin shortcode ‘tw-sell-content’ is designed to manage the selling of content on your website. It checks the user’s wallet balance and if they have sufficient funds, it allows them to purchase the content. If the user doesn’t have enough funds, it displays an ‘insufficient funds’ message. If the user is not logged in, it prompts them to do so. The shortcode also acknowledges the content owner and administrators, allowing them to access the content without payment.
Shortcode: [tw-sell-content]
Parameters
Here is a list of all possible tw-sell-content shortcode parameters and attributes:
amount
– The cost that users need to pay to view the content.id
– A unique identifier for the shortcode instance.
Examples and Usage
Basic example – The shortcode is used to sell content on a post or page. The default amount is set in the plugin settings.
[tw-sell-content /]
Advanced examples
1. In the following example, the shortcode is used with a custom amount attribute. This will override the default amount set in the plugin settings. The amount is the price of the content in the post or page.
[tw-sell-content amount=10 /]
2. In this example, the shortcode is used with a custom id attribute. The id can be used to differentiate between different pieces of content on the same post or page. If the id is not specified, the default id ‘tw-sell-content’ is used.
[tw-sell-content id="custom-id" /]
3. In the final example, the shortcode is used with both custom amount and id attributes. This allows for the most control over the content being sold.
[tw-sell-content amount=20 id="custom-id2" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [tw-sell-content]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'tw-sell-content', array( $this, 'tw_sell_content_shortcode_callback' ) );
Shortcode PHP function:
function tw_sell_content_shortcode_callback( $atts, $content = null ) {
global $post;
$user_id = get_current_user_id();
$atts = shortcode_atts(
array(
'amount' => floatval( $this->settings['default_amount'] ),
'id' => 'tw-sell-content',
),
$atts,
'tw-sell-content'
);
$amount = floatval( $atts['amount'] );
if ( ! $amount ) {
return do_shortcode( $content );
}
$is_owner = ( (int) $post->post_author === $user_id ) ? true : false;
if ( $is_owner || self::is_user_administrator() ) {
return do_shortcode( $content );
}
if ( ! is_user_logged_in() ) {
return $this->render_settings_template( 'visitors_template', $amount, $atts['id'] );
}
if ( ! $this->has_paid( $amount, $atts['id'] ) ) {
if ( woo_wallet()->wallet->get_wallet_balance( get_current_user_id(), 'edit' ) >= $amount ) {
return $this->render_settings_template( 'purchase_template', $amount, $atts['id'] );
} else {
return $this->render_settings_template( 'insufficient_funds_template', $amount, $atts['id'] );
}
}
return do_shortcode( $content );
}
Code file location:
woo-wallet/woo-wallet/includes/actions/class-woo-wallet-action-sell-content.php
TeraWallet [woo-wallet] Shortcode
The Woo Wallet shortcode allows users to display their wallet balance on any part of their website. It calls the ‘woo_wallet_shortcode_output’ function to return the wallet balance.
Shortcode: [woo-wallet]
Examples and Usage
Basic example – A simple usage of the ‘woo-wallet’ shortcode without any parameters or attributes.
[woo-wallet /]
PHP Function Code
In case you have difficulties debugging what causing issues with [woo-wallet]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'woo-wallet', __CLASS__ . '::woo_wallet_shortcode_callback' );
Shortcode PHP function:
function woo_wallet_shortcode_callback( $atts ) {
return self::shortcode_wrapper( array( 'Woo_Wallet_Frontend', 'woo_wallet_shortcode_output' ), $atts );
}
Code file location:
woo-wallet/woo-wallet/includes/class-woo-wallet-frontend.php
TeraWallet [mini-wallet] Shortcode
The Woo-Wallet shortcode ‘mini-wallet’ is designed to display a mini wallet on your page. It’s a convenient way to show users their current wallet balance. This shortcode calls the ‘mini_wallet_shortcode_callback’ function, which in turn calls the ‘shortcode_wrapper’ function. This function finally calls the ‘mini_wallet_shortcode_output’ function to display the mini wallet.
Shortcode: [mini-wallet]
Examples and Usage
Basic example – Showcases the usage of the ‘mini-wallet’ shortcode without any additional parameters.
[mini-wallet /]
PHP Function Code
In case you have difficulties debugging what causing issues with [mini-wallet]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'mini-wallet', __CLASS__ . '::mini_wallet_shortcode_callback' );
Shortcode PHP function:
function mini_wallet_shortcode_callback( $atts ) {
return self::shortcode_wrapper( array( 'Woo_Wallet_Frontend', 'mini_wallet_shortcode_output' ), $atts );
}
Code file location:
woo-wallet/woo-wallet/includes/class-woo-wallet-frontend.php
Conclusion
Now that you’ve learned how to embed the TeraWallet 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.
Leave a Reply