@arafat24bd Please use the bellow attached code in the theme function.php file for the shortcode terawallet-cashback
.
add_shortcode('terawallet-cashback', 'terawallet_cashback_callback');
function terawallet_cashback_callback() {
$product = wc_get_product(get_the_ID());
if ($product->has_child()) {
$product = wc_get_product(current($product->get_children()));
}
$cashback_amount = 0;
if ('product' === woo_wallet()->settings_api->get_option('cashback_rule', '_wallet_settings_credit', 'cart')) {
$cashback_amount = woo_wallet()->cashback->get_product_cashback_amount($product);
} else if ('product_cat' === woo_wallet()->settings_api->get_option('cashback_rule', '_wallet_settings_credit', 'cart')) {
$cashback_amount = woo_wallet()->cashback->get_product_category_wise_cashback_amount($product);
}
$cashback_amount = apply_filters('woo_wallet_product_cashback_amount', $cashback_amount, get_the_ID());
ob_start();
if ($cashback_amount) {
echo '<span class="on-woo-wallet-cashback">' . wc_price($cashback_amount, woo_wallet_wc_price_args()) . __(' Cashback', 'woo-wallet') . '</span>';
} else {
echo '<span class="on-woo-wallet-cashback" style="display:none;"></span>';
}
return ob_get_clean();
}