• Hi,

    I am running a snippet that adds a product table to the single product page in woocommerce (see link to product), however I would like to disbale this snippet when viewing the single products on a mobile device and reverts back to the standard woocommerce add to cart button, is this possible?

    Thanks in advance

    The snippet I am using is this

    function barn2media_product_table_after_short_desc($short_description) {
        global $product;
        if (!is_single() || !is_callable(array($product, 'get_id'))) {
            return $short_description;
        }
        $product_id = $product->get_id();
        $shortcode = "[product_table include='{$product_id}' variations='separate' lazy_load='false' columns='sku,name,price,add-to-cart' description_length='15'  column_breakpoints='default, desktop, all, default'  cart_button='checkbox' show_quantity='true' links='none' page_length='false' search_box='false' reset_button='false' totals='false' ]";
        return $short_description . $shortcode;
    }	
     
    add_filter( 'woocommerce_short_description', 'barn2media_product_table_after_short_desc', 1 );

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    It’s not always easy to tell if the current device is a mobile, but WordPress does provide the wp_is_mobile() function which makes a good guess. Should be easy to just add that into your existing snippet:

        if (!is_single() || wp_is_mobile() || !is_callable(array($product, 'get_id'))) {
            return $short_description;
        }
Viewing 1 replies (of 1 total)
  • The topic ‘Disable Snippet on mobile devices’ is closed to new replies.