[Resolved] WooCommerce quantity buttons show even when product sold individually

Home Forums Support [Resolved] WooCommerce quantity buttons show even when product sold individually

Home Forums Support WooCommerce quantity buttons show even when product sold individually

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2561448
    Damien

    With GeneratePress 3.2.4 and GP Premium 2.2.2 and WooCommerce module enabled and ‘Display quantity buttons’ enabled, the quantity buttons show when the product is sold individually.

    https://imgur.com/pXI9R2J

    I think that the code should add a $product->is_sold_individually() check.
    I know that I can disable ‘Display quantity buttons’ but I would like to leave that enabled for regular products.

    Here’s my suggested patch for gp-premium/woocommerce/functions.php:

    --- woocommerce/functions/functions.orig.php    2021-10-26 19:49:48.000000000 +0100
    +++ woocommerce/functions/functions.php 2023-03-09 13:05:08.690854300 +0000
    @@ -155,7 +155,12 @@
                    }
            }
    
    -       if ( 'product' === get_post_type() || is_cart() ) {
    +       $sold_individually = false;
    +       if ( 'product' === get_post_type() ) {
    +               $product = wc_get_product( get_the_ID() );
    +               $sold_individually = $product->is_sold_individually();
    +       }
    +       if ( ( 'product' === get_post_type() && !$sold_individually ) || is_cart() ) {
                    if ( generatepress_wc_get_setting( 'quantity_buttons' ) ) {
                            $classes[] = 'do-quantity-buttons';
                    }
    
    #2561466
    David
    Staff
    Customer Support

    Hi there,

    thanks for reporting this, we are aware of the issue and there is a PR open to fix it.
    The issue arose through changes made in woo 7.4, for it was related to this:

    https://github.com/woocommerce/woocommerce/issues/36855#issuecomment-1434609352

    But there are other related issues we’re waiting for Woo to resolve as this will determine if/what we need to patch.

    A similar topic arose here, which may be of interest as the base for a temporary fix:

    https://generatepress.com/forums/topic/woocommerce-7-4-product-page-quantity-buttons/#post-2547284

    #2561533
    Damien

    Thanks for the update.
    Coincidentally I’ve just written code very similar to that which you suggested (I only checked for is_sold_individually).

    #2561707
    David
    Staff
    Customer Support

    Glad to hear that. And thanks again for reporting !

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.