public function getProduct() { if (is_null($this->product)) { $this->product = Product::init($this->getProductId()); if (!isset($this->product->ID) || !$this->product->ID) { $this->product = new ProductBase(); } } return $this->product; }
/** * To Verify the stock to make reliable product management. * @param $pro_id * @param $quantity * @return bool */ public static function verifyStock($pro_id, $quantity) { $product = Product::init($pro_id); $product->processProduct(); $stock = $product->meta->stock; $status = false; $quantity = (int) $quantity; //Verify Overall Stock Restriction if ((int) $stock->qty > $quantity) { //Verify Max Sale Restriction if ((int) $stock->min <= $quantity) { //Verify Min Sale Restriction if ((int) $stock->max >= $quantity) { $status = true; } } } return $status; }