I am using a plugin (developed by someone else) which is outputting a shortcode [wof_wheel id="1111"]
. I am using this shortcode on a page.
I am trying to apply conditional logic to the shortcode to only display/run the shortcode IF the number of items in the cart is greater than 4.
I know how to get and then check the cart item count with WC()->cart->get_cart_contents_count()
but not sure if its possible to implement the shortcode display/run logic.
function do_shortcode() {
$items_count = WC()->cart->get_cart_contents_count();
if ($items_count > 4) {
DISPLAY/RUN SHORTCODE
} else if ($items_count < 4)
{
DO NOT DISPLAY/RUN SHORTCODE
}
}
Is this type of conditional logic possible with shortcodes?