Astra_Woocommerce::maybe_add_quantity_buttons( array $args, WC_Product $product )

Hook quantity placeholder buttons based on product type and stock.


Description


Parameters

$args

(array) (Required) Quantity input arguments.

$product

(WC_Product) (Required) Product object.


Return

(array) Modified quantity input arguments.


Source

File: inc/compatibility/woocommerce/class-astra-woocommerce.php

		public function maybe_add_quantity_buttons( $args, $product ) {
			// Skip buttons for sold individually products.
			if ( $product->is_sold_individually() ) {
				return $args;
			}

			// Skip buttons for products with stock less than or equal to 1, only on single product pages.
			if ( is_product() && $product->managing_stock() && $product->get_stock_quantity() <= 1 ) {
				return $args;
			}

			add_action( 'woocommerce_before_quantity_input_field', array( $this, 'render_placeholder_minus_button' ), 5 );
			add_action( 'woocommerce_after_quantity_input_field', array( $this, 'render_placeholder_plus_button' ), 15 );

			return $args;
		}

Changelog

Changelog
Version Description
4.11.16 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.