Product::out_of_stock( int $variant_id )

Summary

Checks if a product is out of stock. If a variant ID is given and the product uses variant-level inventory tracking, then it will be checked against the specific variant.


Parameters

$variant_id

(int) (Required)


Return

(bool) If the product is out of stock


Source

File: src/BigCommerce/Post_Types/Product/Product.php

	public function out_of_stock( $variant_id = 0 ) {
		if ( has_term( Flag::OUT_OF_STOCK, Flag::NAME, $this->post_id ) ) {
			return true;
		}
		$inventory_level = $this->get_inventory_level( $variant_id );
		if ( $inventory_level === 0 ) {
			return true;
		}

		return false;
	}


User Contributed Notes

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