/** * Find the Square Item that corresponds to the given WC Product. * * First searches for a Square Item ID in the WC Product metadata, * then compares all WC Product SKUs against all Square Items. * * @param WC_Product $wc_product * @return object|bool Square Item object on success, boolean false if no Square Item found. */ public function get_square_item_for_wc_product(WC_Product $wc_product) { $product_id = $wc_product->id; if ('variation' === $wc_product->product_type) { $product_id = $wc_product->variation_id; } if ($square_item_id = WC_Square_Utils::get_wc_product_square_id($product_id)) { return $this->connect->get_square_product($square_item_id); } $wc_product_skus = WC_Square_Utils::get_wc_product_skus($wc_product); return $this->connect->square_product_exists($wc_product_skus); }