Tribe__Tickets_Plus__Commerce__EDD__Stock_Control::increment_units( int $product_id, int $increment_by = 1 )

Increments the inventory of the specified product by 1 (or by the optional $increment_by value if provided).


Parameters

$product_id

(int) (Required)

$increment_by

(int) (Optional)

Default value: 1


Top ↑

Return

(bool) true|false according to whether the update was successful or not


Top ↑

Source

File: src/Tribe/Commerce/EDD/Stock_Control.php

	public function increment_units( $product_id, $increment_by = 1 ) {
		$ticket = tribe( 'tickets-plus.commerce.edd' )->get_ticket( null, $product_id );

		if ( ! $ticket || ! $ticket->managing_stock() ) {
			return false;
		}

		$stock = get_post_meta( $product_id, '_stock', true );

		if ( Tribe__Tickets_Plus__Commerce__EDD__Main::UNLIMITED === $stock  ) {
			return false;
		}

		return (bool) update_post_meta( $product_id, '_stock', (int) $stock + $increment_by );
	}