Categories
public static function sync_products() { $products = wc_get_products(['limit' => -1]); foreach ($products as $product) { $sku = $product->get_sku(); if (!$sku) continue; // GET CATEGORY TEXT $category_text = D15_Category::get_product_categories_text($product->get_id()); $description = $product->get_description(); // APPEND CATEGORY INFO if ($category_text) { $description .= "\n\n[Categories]\n" . $category_text; } $data = [ 'ref' => $sku, 'label' => $product->get_name(), 'price' => $product->get_price(), 'description' => $description ]; $response = D15_API::request('products', 'POST', $data); if (is_wp_error($response)) { D15_Log::add('Product ERROR: ' . $sku); continue; } D15_Log::add('Product synced (with categories): ' . $sku); } }