/**
  * Sync a WC Product's inventory to Square
  *
  * @param WC_Product $wc_product
  */
 public function sync_inventory(WC_Product $wc_product)
 {
     $wc_variation_ids = WC_Square_Utils::get_stock_managed_wc_variation_ids($wc_product);
     $square_inventory = $this->connect->get_square_inventory();
     foreach ($wc_variation_ids as $wc_variation_id) {
         $square_variation_id = WC_Square_Utils::get_wc_variation_square_id($wc_variation_id);
         if ($square_variation_id && isset($square_inventory[$square_variation_id])) {
             $wc_stock = (int) get_post_meta($wc_variation_id, '_stock', true);
             $square_stock = (int) $square_inventory[$square_variation_id];
             $delta = $wc_stock - $square_stock;
             $result = $this->connect->update_square_inventory($square_variation_id, $delta);
             if (!$result) {
                 WC_Square_Sync_Logger::log(sprintf('[WC -> Square] Error syncing inventory for WC Product %d.', $wc_product->id));
             }
         }
     }
 }