/** * Update a Square Item Image for a WC Product * * @param WC_Product $wc_product * @param string $square_item_id * @return bool Success. */ public function update_product_image(WC_Product $wc_product, $square_item_id) { $image_id = get_post_thumbnail_id($wc_product->id); if (empty($image_id)) { WC_Square_Sync_Logger::log(sprintf('[WC -> Square] Update Product Image: No thumbnail ID for WC Product %d.', $wc_product->id)); return true; } $mime_type = get_post_field('post_mime_type', $image_id, 'raw'); $image_path = get_attached_file($image_id); $result = $this->connect->update_square_product_image($square_item_id, $mime_type, $image_path); if ($result && isset($result->id)) { WC_Square_Utils::update_wc_product_image_square_id($wc_product->id, $result->id); return true; } else { WC_Square_Sync_Logger::log(sprintf('[WC -> Square] Error updating Product Image for WC Product %d.', $wc_product->id)); return false; } }