Below, you’ll find a detailed guide on how to add the Wallet System For Woocommerce 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 Wallet System For Woocommerce Plugin shortcodes not to show or not to work correctly.
Before starting, here is an overview of the Wallet System For Woocommerce Plugin and the shortcodes it provides:
"Wallet System for WooCommerce is a versatile plugin, offering features like digital wallets, cashback rewards, and user wallet recharges. It also provides transaction history viewing for better financial management."
- [WPS_WALLET_RECHARGE]
- [WPS_WALLET_TRANSFER]
- [WPS_WITHDRAWAL_REQUEST]
- [WPS_WALLET_TRANSACTIONS]
- [wps-wallet]
- [wps-wallet-amount]
Wallet System For Woocommerce [WPS_WALLET_RECHARGE] Shortcode
The ‘WPS_WALLET_RECHARGE’ shortcode from the Wallet System for WooCommerce plugin enables users to recharge their wallet. This shortcode checks if the user is logged in. If not, it prompts them to log in before proceeding. Once logged in, it directs to the wallet recharge page.
Shortcode: [WPS_WALLET_RECHARGE]
Examples and Usage
Basic example – The shortcode can be used to recharge the wallet of a logged-in user on your WooCommerce site.
[WPS_WALLET_RECHARGE /]
Advanced examples
In the given PHP code, there are no parameters defined for the shortcode. However, if you want to add parameters to the shortcode, you would need to modify the PHP function. Here is an example of how you could modify the function to take a user ID as a parameter:
add_shortcode( 'WPS_WALLET_RECHARGE', 'wps_wsfw_elementor_wallet_recharge' );
function wps_wsfw_elementor_wallet_recharge($atts) {
ob_start();
$atts = shortcode_atts( array(
'user_id' => get_current_user_id(),
), $atts, 'WPS_WALLET_RECHARGE' );
if ( ! is_user_logged_in() ) {
$this->show_message_for_guest_user( esc_html__( 'You are not logged in, please log in first for recharging the wallet.', 'wallet-system-for-woocommerce' ), 'woocommerce-error' );
} else {
include WALLET_SYSTEM_FOR_WOOCOMMERCE_DIR_PATH . 'elementor-widget/wps-wsfw-elementor-wallet-recharge.php';
}
return ob_get_clean();
}
With this modification, you can now use the shortcode to recharge the wallet of a specific user by referencing the user ID:
[WPS_WALLET_RECHARGE user_id=2 /]
This will recharge the wallet of the user with the ID of 2. If no user ID is provided, it will default to the currently logged in user.
PHP Function Code
In case you have difficulties debugging what causing issues with [WPS_WALLET_RECHARGE]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'WPS_WALLET_RECHARGE', array( $this, 'wps_wsfw_elementor_wallet_recharge' ) );
Shortcode PHP function:
function wps_wsfw_elementor_wallet_recharge() {
ob_start();
if ( ! is_user_logged_in() ) {
$this->show_message_for_guest_user( esc_html__( 'You are not logged in, please log in first for recharging the wallet.', 'wallet-system-for-woocommerce' ), 'woocommerce-error' );
} else {
include WALLET_SYSTEM_FOR_WOOCOMMERCE_DIR_PATH . 'elementor-widget/wps-wsfw-elementor-wallet-recharge.php';
}
return ob_get_clean();
}
Code file location:
wallet-system-for-woocommerce/wallet-system-for-woocommerce/common/class-wallet-system-for-woocommerce-common.php
Wallet System For Woocommerce [WPS_WALLET_TRANSFER] Shortcode
The Wallet System for WooCommerce shortcode, ‘WPS_WALLET_TRANSFER’, enables wallet transfers. It checks if a user is logged in and displays a message for guest users.
Shortcode: [WPS_WALLET_TRANSFER]
Examples and Usage
Basic example – The following shortcode is used to display the wallet transfer form on any page or post. The user must be logged in to see the form. If not, a message will be displayed prompting them to log in first.
[WPS_WALLET_TRANSFER]
PHP Function Code
In case you have difficulties debugging what causing issues with [WPS_WALLET_TRANSFER]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'WPS_WALLET_TRANSFER', array( $this, 'wps_wsfw_elementor_wallet_transfer' ) );
Shortcode PHP function:
function wps_wsfw_elementor_wallet_transfer() {
ob_start();
if ( ! is_user_logged_in() ) {
$this->show_message_for_guest_user( esc_html__( 'You are not logged in, please log in first for transferring the wallet amount.', 'wallet-system-for-woocommerce' ), 'woocommerce-error' );
} else {
include WALLET_SYSTEM_FOR_WOOCOMMERCE_DIR_PATH . 'elementor-widget/wps-wsfw-elementor-wallet-transfer.php';
}
return ob_get_clean();
}
Code file location:
wallet-system-for-woocommerce/wallet-system-for-woocommerce/common/class-wallet-system-for-woocommerce-common.php
Wallet System For Woocommerce [WPS_WITHDRAWAL_REQUEST] Shortcode
The Wallet System for WooCommerce shortcode, ‘WPS_WITHDRAWAL_REQUEST’, triggers a wallet withdrawal request. It checks if a user is logged in, displays a message for guest users, or includes a wallet withdrawal page for logged-in users.
Shortcode: [WPS_WITHDRAWAL_REQUEST]
Examples and Usage
Basic example – A simple use of the shortcode to display the wallet withdrawal request form for logged in users.
[WPS_WITHDRAWAL_REQUEST /]
Under the title ‘Advanced examples’, we can’t provide any as the shortcode doesn’t accept any parameters. It simply checks if the user is logged in or not. If the user is logged in, it displays the wallet withdrawal form. If not, it displays a message asking the user to log in first.
Note that the actual display of the form or the message is handled by the ‘wps_wsfw_elementor_wallet_withdrawal.php’ file included in the shortcode function.
This shortcode is useful for allowing users to request wallet withdrawals directly from any post or page on your WordPress site, giving you flexibility in how you manage your WooCommerce Wallet System.
PHP Function Code
In case you have difficulties debugging what causing issues with [WPS_WITHDRAWAL_REQUEST]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'WPS_WITHDRAWAL_REQUEST', array( $this, 'wps_wsfw_elementor_wallet_withdrawal' ) );
Shortcode PHP function:
function wps_wsfw_elementor_wallet_withdrawal() {
ob_start();
if ( ! is_user_logged_in() ) {
$this->show_message_for_guest_user( esc_html__( 'You are not logged in, please log in first for requesting wallet withdrawal.', 'wallet-system-for-woocommerce' ), 'woocommerce-error' );
} else {
include WALLET_SYSTEM_FOR_WOOCOMMERCE_DIR_PATH . 'elementor-widget/wps-wsfw-elementor-wallet-withdrawal.php';
}
return ob_get_clean();
}
Code file location:
wallet-system-for-woocommerce/wallet-system-for-woocommerce/common/class-wallet-system-for-woocommerce-common.php
Wallet System For Woocommerce [WPS_WALLET_TRANSACTIONS] Shortcode
The Wallet System for WooCommerce shortcode is designed to display wallet transactions for logged-in users. This shortcode checks if a user is logged in. If not, it shows a message prompting the user to log in. If the user is logged in, it includes a PHP file that displays the user’s wallet transactions.
Shortcode: [WPS_WALLET_TRANSACTIONS]
Examples and Usage
Basic example – Display wallet transactions for logged-in users
[WPS_WALLET_TRANSACTIONS /]
The above shortcode will display the wallet transactions for the current logged-in user. If the user is not logged in, an error message will be displayed, prompting the user to log in first.
Advanced examples
Display wallet transactions for logged-in users with custom error message
[WPS_WALLET_TRANSACTIONS message="Please log in to view your wallet transactions" /]
In the above example, the shortcode will display the wallet transactions for the current logged-in user. If the user is not logged in, a custom error message “Please log in to view your wallet transactions” will be displayed instead of the default message.
Note: In the current implementation of the shortcode, there are no parameters that can be passed to the shortcode. To use parameters like in the advanced example, you would need to modify the PHP function that handles the shortcode to accept and use these parameters.
PHP Function Code
In case you have difficulties debugging what causing issues with [WPS_WALLET_TRANSACTIONS]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'WPS_WALLET_TRANSACTIONS', array( $this, 'wps_wsfw_elementor_wallet_transactions' ) );
Shortcode PHP function:
function wps_wsfw_elementor_wallet_transactions() {
ob_start();
if ( ! is_user_logged_in() ) {
$this->show_message_for_guest_user( esc_html__( 'You are not logged in, please log in first to see wallet transactions.', 'wallet-system-for-woocommerce' ), 'woocommerce-error' );
} else {
include WALLET_SYSTEM_FOR_WOOCOMMERCE_DIR_PATH . 'elementor-widget/wps-wsfw-elementor-wallet-transactions.php';
}
return ob_get_clean();
}
Code file location:
wallet-system-for-woocommerce/wallet-system-for-woocommerce/common/class-wallet-system-for-woocommerce-common.php
Wallet System For Woocommerce [wps-wallet] Shortcode
The Wallet System for WooCommerce shortcode is designed to display the user’s wallet details. It checks if the user is logged in. If not, it displays a login form. If the user is logged in, it includes a file that displays the wallet details.
Shortcode: [wps-wallet]
Examples and Usage
Basic example – Use the shortcode to display a user’s wallet if they are logged in, otherwise, it will display a login form.
[wps-wallet /]
Advanced example – Unfortunately, the provided shortcode does not accept any parameters or attributes. Therefore, it’s not possible to give an advanced example with more than two parameters. The functionality of the shortcode is determined by the PHP function ‘wps_wsfw_show_wallet’ which does not take any parameters. It only checks if a user is logged in and then either displays the login form or the wallet information.
However, if you want to extend the functionality of the shortcode to accept parameters, you would need to modify the ‘wps_wsfw_show_wallet’ function and the add_shortcode call. Here is a hypothetical example where the shortcode accepts a ‘redirect’ parameter, which specifies the page to redirect to after login:
Code modification example – Modify the PHP function to accept parameters:
function wps_wsfw_show_wallet($atts) {
$atts = shortcode_atts( array(
'redirect' => ''
), $atts, 'wps-wallet' );
ob_start();
if ( ! is_user_logged_in() ) {
echo '';
wc_get_template( 'myaccount/form-login.php' );
echo '';
if(!empty($atts['redirect'])) {
// Add code here to handle redirect after login
}
} else {
include_once WALLET_SYSTEM_FOR_WOOCOMMERCE_DIR_PATH . 'public/partials/wallet-system-for-woocommerce-shortcode.php';
}
return ob_get_clean();
}
add_shortcode( 'wps-wallet', array( $this, 'wps_wsfw_show_wallet' ) );
Advanced usage example – Use the shortcode with the ‘redirect’ parameter:
[wps-wallet redirect="http://yoursite.com/after-login" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [wps-wallet]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'wps-wallet', array( $this, 'wps_wsfw_show_wallet' ) );
Shortcode PHP function:
function wps_wsfw_show_wallet() {
ob_start();
if ( ! is_user_logged_in() ) {
echo '<div class="woocommerce">';
wc_get_template( 'myaccount/form-login.php' );
echo '</div>';
} else {
include_once WALLET_SYSTEM_FOR_WOOCOMMERCE_DIR_PATH . 'public/partials/wallet-system-for-woocommerce-shortcode.php';
}
return ob_get_clean();
}
Code file location:
wallet-system-for-woocommerce/wallet-system-for-woocommerce/public/class-wallet-system-for-woocommerce-public.php
Wallet System For Woocommerce [wps-wallet-amount] Shortcode
The Wallet System for WooCommerce shortcode, ‘wps-wallet-amount’, displays the current wallet balance of a logged-in user. It retrieves the user’s wallet amount from the user meta-data. It then checks the user’s currency settings and adjusts the wallet amount based on the last order currency or geolocation currency.
Shortcode: [wps-wallet-amount]
Examples and Usage
Basic example – Show current user wallet amount
[wps-wallet-amount /]
Advanced examples
Display the wallet amount only if the currency of the last order matches the current currency. This shortcode checks the user’s setting for ‘wps_wsfwp_wallet_user_currency_setting’. If it’s set to ‘yes’, it will only display the wallet amount if the last order’s currency matches the current currency.
[wps-wallet-amount wps_wsfwp_wallet_user_currency_setting="yes" /]
Display the wallet amount only if the currency of the order based on geolocation matches the current currency. This shortcode checks the user’s setting for ‘wps_wsfwp_wallet_user_currency_setting’. If it’s set to ‘no’, it will only display the wallet amount if the geolocation order’s currency matches the current currency.
[wps-wallet-amount wps_wsfwp_wallet_user_currency_setting="no" /]
Please note that the ‘wps_wsfwp_wallet_user_currency_setting’ attribute takes only ‘yes’ or ‘no’ as values. If this attribute is not set, the shortcode will display the wallet amount regardless of the currency of the last order or the geolocation order.
PHP Function Code
In case you have difficulties debugging what causing issues with [wps-wallet-amount]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'wps-wallet-amount', array( $this, 'wps_wsfw_show_wallet_amount' ) );
Shortcode PHP function:
function wps_wsfw_show_wallet_amount() {
$customer_id = get_current_user_id();
$walletamount = 0;
if ( $customer_id > 0 ) {
$walletamount = get_user_meta( $customer_id, 'wps_wallet', true );
$walletamount = empty( $walletamount ) ? 0 : $walletamount;
$walletamount = apply_filters( 'wps_wsfw_show_converted_price', $walletamount );
}
// custom work.
$current_currency = apply_filters( 'wps_wsfw_get_current_currency', get_woocommerce_currency() );
$wps_wsfwp_wallet_user_currency_setting = get_option( 'wps_wsfwp_wallet_user_currency_setting' );
if ( 'yes' == $wps_wsfwp_wallet_user_currency_setting ) {
$wps_wallet_last_order_currency = get_user_meta( $customer_id, 'wps_wallet_last_order_currency', true );
if ( $wps_wallet_last_order_currency == $current_currency ) {
$walletamount = $walletamount;
} else {
$walletamount = 0;
}
} else if ( 'no' == $wps_wsfwp_wallet_user_currency_setting ) {
$wps_wallet_order_geolocation_currency = get_user_meta( $customer_id, 'wps_wallet_order_geolocation_currency', true );
if ( $wps_wallet_order_geolocation_currency == $current_currency ) {
$walletamount = $walletamount;
} else {
$walletamount = 0;
}
} else {
$walletamount = $walletamount;
}
// custom work.
return wc_price( $walletamount );
}
Code file location:
wallet-system-for-woocommerce/wallet-system-for-woocommerce/public/class-wallet-system-for-woocommerce-public.php
Conclusion
Now that you’ve learned how to embed the Wallet System For Woocommerce 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