• marseem

    (@waseemsannib)


    Hi everyone,

    Actually, I’m struggling to fix an issue on my website. I need to hid the add to cart button and stock message on quickview for a specific category coming (.product_cat-coming). The product in this category is already in the stock but in process, so customers can’t buy it yet because it is in progressing. I already hid the add to cart button and stock message on the single pages. Why I can’t hide them the same on quickview info? Is there any method you can recommend to us to fix this issue?

    Thanks in advance

    Screenshot: https://ibb.co/Q3N0JGvh

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hey @waseemsannib,

    I took a quick look a your site, were you able to fix the issue?

    The add to cart button and the stock message are not present while quickview is open for the coming category on my end.

    Thread Starter marseem

    (@waseemsannib)

    Hi @r1k0,

    Thanks much for your support in advance. Actually, I’m working on it and i hope it works. Currently, I’m using this block:

    // WooCommerce PHP Filters
    // ————————-

    // Categories where products are not purchasable (completely blocked)
    add_filter(‘woocommerce_is_purchasable’, function($is_purchasable, $product) {
    $blocked_categories = array(‘teaser’,’waiting’,’coming’,’adoption’); // fully blocked
    if (has_term($blocked_categories, ‘product_cat’, $product->get_id())) {
    return false; // disables Add to Cart completely
    }
    return $is_purchasable;
    }, 10, 2);

    // Hide stock info for fully blocked categories
    add_filter(‘woocommerce_get_stock_html’, function($html, $product) {
    $blocked_categories = array(‘teaser’,’waiting’,’coming’,’adoption’); // fully blocked
    if (has_term($blocked_categories, ‘product_cat’, $product->get_id())) {
    return ”; // hides stock
    }
    return $html; // stock visible for other categories
    }, 10, 2);

    // Disable Add to Cart button for ‘one-shot’, ‘send-offer’, ‘guess-value’ everywhere (greyed out)
    add_filter(‘woocommerce_loop_add_to_cart_link’, function($button, $product) {
    $disabled_categories = array(‘one-shot’,’send-offer’,’guess-value’);
    if (has_term($disabled_categories, ‘product_cat’, $product->get_id())) {
    $button = ‘‘ . __(‘Add to cart’, ‘woocommerce’) . ‘‘;
    }
    return $button;
    }, 10, 2);

    // QuickView / Single Page: Disable Add to Cart button for ‘one-shot’, ‘send-offer’, ‘guess-value’
    add_action(‘woocommerce_before_add_to_cart_button’, function() {
    global $product;
    $disabled_categories = array(‘one-shot’,’send-offer’,’guess-value’);
    if (has_term($disabled_categories, ‘product_cat’, $product->get_id())) {
    echo ”;
    }
    });
    // Hide Send Offer form in QuickView for ‘send-offer’ category
    add_action(‘wp_head’, function() {
    if ( is_admin() ) return; // Only for front-end

    global $product;
    
    // Make sure $product is set (QuickView often sets it)
    if ( isset($product) && has_term('send-offer', 'product_cat', $product->get_id()) ) {
        echo '<style>
            .quickview-wrapper .woocommerce .send-offer-wrapper { 
                display: none !important; 
            }
        </style>';
    }

    }); – If you have a simple and clean snippet to hide the stock message and add to cart button on quickview I will be much appreciated. All work good on single page, but if i deleted the snippet block it will revert and will be shown on the specific categories.

    Best regards

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.