WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WC_Cart::set_quantity() public WC 1.0

Set the quantity for an item in the cart using it's key.

Это метод класса: WC_Cart{}

Возвращает

true/false.

Использование

$WC_Cart = new WC_Cart();
$WC_Cart->set_quantity( $cart_item_key, $quantity, $refresh_totals );
$cart_item_key(строка) (обязательный)
contains the id of the cart item.
$quantity(число)
contains the quantity of the item.
По умолчанию: 1
$refresh_totals(true/false)
whether or not to calculate totals after setting the new qty. Can be used to defer calculations if setting quantities in bulk.
По умолчанию: true

Код WC_Cart::set_quantity() WC 4.5.2

woocommerce/includes/class-wc-cart.php
<?php
public function set_quantity( $cart_item_key, $quantity = 1, $refresh_totals = true ) {
	if ( 0 === $quantity || $quantity < 0 ) {
		wc_do_deprecated_action( 'woocommerce_before_cart_item_quantity_zero', array( $cart_item_key, $this ), '3.7.0', 'woocommerce_remove_cart_item' );
		// If we're setting qty to 0 we're removing the item from the cart.
		return $this->remove_cart_item( $cart_item_key );
	}

	// Update qty.
	$old_quantity                                      = $this->cart_contents[ $cart_item_key ]['quantity'];
	$this->cart_contents[ $cart_item_key ]['quantity'] = $quantity;

	do_action( 'woocommerce_after_cart_item_quantity_update', $cart_item_key, $quantity, $old_quantity, $this );

	if ( $refresh_totals ) {
		$this->calculate_totals();
	}

	/**
	 * Fired after qty has been changed.
	 *
	 * @since 3.6.0
	 * @param string  $cart_item_key contains the id of the cart item. This may be empty if the cart item does not exist any more.
	 * @param int     $quantity contains the quantity of the item.
	 * @param WC_Cart $this Cart class.
	 */
	do_action( 'woocommerce_cart_item_set_quantity', $cart_item_key, $quantity, $this );

	return true;
}