
Pablo Borysenco(@pavlo_borysenco)
34,196 Posts
Quote from Pablo Borysenco on September 6, 2021, 12:42
Hello
I can suggest you next way:
- create new shortcode woocs_custom in file functions.php of the current wp theme and use it
- in that new shortcode using function as condition https://developer.wordpress.org/reference/functions/wp_is_mobile/ use usual shortcode AND set of images with links like '?currency=USD'
- Example:
add_shortcode('woocs_custom', function($args) {
if (wp_is_mobile()) {
global $WOOCS;
$currencies = $WOOCS->get_currencies();
foreach ($currencies as $currency) {
echo "<a href='?currency={$currency['name']}' class='woocs_custom_flags' title='{$currency['description']}'><img src='{$currency['flag']}' alt='{$currency['description']}'></a>";
}
} else {
echo do_shortcode('[woocs]');
}
}); - Using CSS class 'woocs_custom_flags' set your style
Hello
I can suggest you next way:
- create new shortcode woocs_custom in file functions.php of the current wp theme and use it
- in that new shortcode using function as condition https://developer.wordpress.org/reference/functions/wp_is_mobile/ use usual shortcode AND set of images with links like '?currency=USD'
- Example:
add_shortcode('woocs_custom', function($args) {
if (wp_is_mobile()) {
global $WOOCS;
$currencies = $WOOCS->get_currencies();
foreach ($currencies as $currency) {
echo"<a href='?currency={$currency['name']}' class='woocs_custom_flags' title='{$currency['description']}'><img src='{$currency['flag']}' alt='{$currency['description']}'></a>";
}
} else {
echo do_shortcode('[woocs]');
}
}); - Using CSS class 'woocs_custom_flags' set your style