{"id":2633,"date":"2025-01-12T10:07:54","date_gmt":"2025-01-12T10:07:54","guid":{"rendered":"https:\/\/razmjoui.ir\/?p=2633"},"modified":"2025-01-12T13:12:12","modified_gmt":"2025-01-12T13:12:12","slug":"%d8%b1%d8%a7%d9%87%d9%86%d9%85%d8%a7%db%8c-%d8%ac%d8%a7%d9%85%d8%b9-%da%a9%d8%a7%d8%b1-%d8%a8%d8%a7-enhancedwoocommerceproductmanager","status":"publish","type":"post","link":"https:\/\/razmjoui.ir\/?p=2633","title":{"rendered":"\u0631\u0627\u0647\u0646\u0645\u0627\u06cc \u062c\u0627\u0645\u0639 \u06a9\u0627\u0631 \u0628\u0627 EnhancedWooCommerceProductManager"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u0645\u0639\u0631\u0641\u06cc<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u06a9\u0644\u0627\u0633 <code>EnhancedWooCommerceProductManager<\/code> \u06cc\u06a9 \u0627\u0628\u0632\u0627\u0631 \u0642\u062f\u0631\u062a\u0645\u0646\u062f \u0628\u0631\u0627\u06cc \u0645\u062f\u06cc\u0631\u06cc\u062a \u0648 \u062f\u0631\u06cc\u0627\u0641\u062a \u0645\u062d\u0635\u0648\u0644\u0627\u062a \u0648\u0648\u06a9\u0627\u0645\u0631\u0633 \u0627\u0633\u062a. \u0627\u06cc\u0646 \u06a9\u0644\u0627\u0633 \u0627\u0645\u06a9\u0627\u0646\u0627\u062a \u0632\u06cc\u0631 \u0631\u0627 \u062f\u0631 \u0627\u062e\u062a\u06cc\u0627\u0631 \u0634\u0645\u0627 \u0642\u0631\u0627\u0631 \u0645\u06cc\u200c\u062f\u0647\u062f:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u062f\u0631\u06cc\u0627\u0641\u062a \u0645\u062d\u0635\u0648\u0644\u0627\u062a \u0628\u0627 \u0641\u0631\u0645\u062a \u06cc\u06a9\u0633\u0627\u0646 \u0648 \u0627\u0633\u062a\u0627\u0646\u062f\u0627\u0631\u062f<\/li>\n\n\n\n<li>\u0645\u0631\u062a\u0628\u200c\u0633\u0627\u0632\u06cc \u0645\u062d\u0635\u0648\u0644\u0627\u062a \u0628\u0631\u0627\u0633\u0627\u0633 \u0645\u0639\u06cc\u0627\u0631\u0647\u0627\u06cc \u0645\u062e\u062a\u0644\u0641<\/li>\n\n\n\n<li>\u0641\u06cc\u0644\u062a\u0631 \u0645\u062d\u0635\u0648\u0644\u0627\u062a \u0628\u0631\u0627\u0633\u0627\u0633 \u062f\u0633\u062a\u0647\u200c\u0628\u0646\u062f\u06cc\u060c \u0628\u0631\u0686\u0633\u0628 \u0648 \u0628\u0631\u0646\u062f<\/li>\n\n\n\n<li>\u0645\u062f\u06cc\u0631\u06cc\u062a \u06a9\u0634 \u0628\u0631\u0627\u06cc \u0628\u0647\u0628\u0648\u062f \u0639\u0645\u0644\u06a9\u0631\u062f<\/li>\n\n\n\n<li>\u0645\u062f\u06cc\u0631\u06cc\u062a \u062e\u0637\u0627\u0647\u0627 \u0628\u0635\u0648\u0631\u062a \u062d\u0631\u0641\u0647\u200c\u0627\u06cc<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u0646\u0635\u0628 \u0648 \u0631\u0627\u0647\u200c\u0627\u0646\u062f\u0627\u0632\u06cc<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u0627\u0628\u062a\u062f\u0627 \u0641\u0627\u06cc\u0644 \u06a9\u0644\u0627\u0633 \u0631\u0627 \u062f\u0631 \u0645\u0633\u06cc\u0631 \u062a\u0645 \u06cc\u0627 \u0627\u0641\u0632\u0648\u0646\u0647 \u062e\u0648\u062f \u0642\u0631\u0627\u0631 \u062f\u0647\u06cc\u062f:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>require_once 'class-enhanced-woocommerce-product-manager.php';<\/code><\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u06cc\u06a9 \u0646\u0645\u0648\u0646\u0647 \u0627\u0632 \u06a9\u0644\u0627\u0633 \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>$productManager = new EnhancedWooCommerceProductManager(\n    posts_per_page: 12, \/\/ \u062a\u0639\u062f\u0627\u062f \u0645\u062d\u0635\u0648\u0644\u0627\u062a \u062f\u0631 \u0647\u0631 \u0635\u0641\u062d\u0647\n    paged: 1,          \/\/ \u0634\u0645\u0627\u0631\u0647 \u0635\u0641\u062d\u0647\n    enable_cache: true, \/\/ \u0641\u0639\u0627\u0644\u200c\u0633\u0627\u0632\u06cc \u06a9\u0634\n    cache_duration: HOUR_IN_SECONDS \/\/ \u0645\u062f\u062a \u0632\u0645\u0627\u0646 \u06a9\u0634\n);<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u0631\u0648\u0634\u200c\u0647\u0627\u06cc \u062f\u0631\u06cc\u0627\u0641\u062a \u0645\u062d\u0635\u0648\u0644\u0627\u062a<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u062f\u0631\u06cc\u0627\u0641\u062a \u0628\u0631\u0627\u0633\u0627\u0633 \u0634\u0646\u0627\u0633\u0647 \u0645\u062d\u0635\u0648\u0644<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u0628\u0631\u0627\u06cc \u062f\u0631\u06cc\u0627\u0641\u062a \u0645\u062d\u0635\u0648\u0644\u0627\u062a \u062e\u0627\u0635 \u0628\u0631\u0627\u0633\u0627\u0633 ID:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u062f\u0631\u06cc\u0627\u0641\u062a \u0645\u062d\u0635\u0648\u0644\u0627\u062a \u0628\u0627 ID \u0647\u0627\u06cc \u0645\u0634\u062e\u0635\n$products = $productManager-&gt;getFormattedProductsByIdsAndSort(\n    &#91;1, 2, 3], \/\/ \u0622\u0631\u0627\u06cc\u0647\u200c\u0627\u06cc \u0627\u0632 ID \u0647\u0627\u06cc \u0645\u062d\u0635\u0648\u0644\u0627\u062a\n    'price_low' \/\/ \u0646\u0648\u0639 \u0645\u0631\u062a\u0628\u200c\u0633\u0627\u0632\u06cc\n);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u062f\u0631\u06cc\u0627\u0641\u062a \u0628\u0631\u0627\u0633\u0627\u0633 \u062f\u0633\u062a\u0647\u200c\u0628\u0646\u062f\u06cc<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u0628\u0631\u0627\u06cc \u062f\u0631\u06cc\u0627\u0641\u062a \u0645\u062d\u0635\u0648\u0644\u0627\u062a \u06cc\u06a9 \u062f\u0633\u062a\u0647\u200c\u0628\u0646\u062f\u06cc:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u062f\u0631\u06cc\u0627\u0641\u062a \u0645\u062d\u0635\u0648\u0644\u0627\u062a \u06cc\u06a9 \u062f\u0633\u062a\u0647\u200c\u0628\u0646\u062f\u06cc\n$products = $productManager-&gt;getFormattedProductsByCategoryAndSort(\n    56, \/\/ \u0634\u0646\u0627\u0633\u0647 \u062f\u0633\u062a\u0647\u200c\u0628\u0646\u062f\u06cc\n    'price_low' \/\/ \u0646\u0648\u0639 \u0645\u0631\u062a\u0628\u200c\u0633\u0627\u0632\u06cc\n);\n\n\/\/ \u062f\u0631\u06cc\u0627\u0641\u062a \u0645\u062d\u0635\u0648\u0644\u0627\u062a \u0686\u0646\u062f \u062f\u0633\u062a\u0647\u200c\u0628\u0646\u062f\u06cc\n$products = $productManager-&gt;getFormattedProductsByMultipleCategoriesAndSort(\n    &#91;56, 57, 58], \/\/ \u0622\u0631\u0627\u06cc\u0647\u200c\u0627\u06cc \u0627\u0632 \u0634\u0646\u0627\u0633\u0647\u200c\u0647\u0627\u06cc \u062f\u0633\u062a\u0647\u200c\u0628\u0646\u062f\u06cc\n    'price_low'\n);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3. \u062f\u0631\u06cc\u0627\u0641\u062a \u0628\u0631\u0627\u0633\u0627\u0633 \u0628\u0631\u0686\u0633\u0628<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u062f\u0631\u06cc\u0627\u0641\u062a \u0645\u062d\u0635\u0648\u0644\u0627\u062a \u06cc\u06a9 \u0628\u0631\u0686\u0633\u0628\n$products = $productManager-&gt;getFormattedProductsByTagAndSort(\n    'sale', \/\/ \u0646\u0627\u0645 \u0628\u0631\u0686\u0633\u0628\n    'price_low'\n);\n\n\/\/ \u062f\u0631\u06cc\u0627\u0641\u062a \u0645\u062d\u0635\u0648\u0644\u0627\u062a \u0686\u0646\u062f \u0628\u0631\u0686\u0633\u0628\n$products = $productManager-&gt;getFormattedProductsByMultipleTagsAndSort(\n    &#91;'sale', 'new'],\n    'price_low'\n);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4. \u062f\u0631\u06cc\u0627\u0641\u062a \u0628\u0631\u0627\u0633\u0627\u0633 \u0628\u0631\u0646\u062f<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u062f\u0631\u06cc\u0627\u0641\u062a \u0645\u062d\u0635\u0648\u0644\u0627\u062a \u06cc\u06a9 \u0628\u0631\u0646\u062f\n$products = $productManager-&gt;getFormattedProductsByBrandAndSort(\n    'samsung',\n    'price_low'\n);\n\n\/\/ \u062f\u0631\u06cc\u0627\u0641\u062a \u0645\u062d\u0635\u0648\u0644\u0627\u062a \u0686\u0646\u062f \u0628\u0631\u0646\u062f\n$products = $productManager-&gt;getFormattedProductsByMultipleBrandsAndSort(\n    &#91;'samsung', 'apple'],\n    'price_low'\n);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">5. \u062f\u0631\u06cc\u0627\u0641\u062a \u0647\u0645\u0647 \u0645\u062d\u0635\u0648\u0644\u0627\u062a<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u062f\u0631\u06cc\u0627\u0641\u062a \u0647\u0645\u0647 \u0645\u062d\u0635\u0648\u0644\u0627\u062a \u0628\u0627 \u0645\u0631\u062a\u0628\u200c\u0633\u0627\u0632\u06cc\n$products = $productManager-&gt;getAllFormattedProductsAndSort('price_low');<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u0627\u0646\u0648\u0627\u0639 \u0645\u0631\u062a\u0628\u200c\u0633\u0627\u0632\u06cc<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u06cc\u062f \u0627\u0632 \u0627\u0646\u0648\u0627\u0639 \u0645\u0631\u062a\u0628\u200c\u0633\u0627\u0632\u06cc \u0632\u06cc\u0631 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>price_low<\/code>: \u0642\u06cc\u0645\u062a \u0627\u0632 \u06a9\u0645 \u0628\u0647 \u0632\u06cc\u0627\u062f<\/li>\n\n\n\n<li><code>price_high<\/code>: \u0642\u06cc\u0645\u062a \u0627\u0632 \u0632\u06cc\u0627\u062f \u0628\u0647 \u06a9\u0645<\/li>\n\n\n\n<li><code>newest<\/code>: \u062c\u062f\u06cc\u062f\u062a\u0631\u06cc\u0646 \u0645\u062d\u0635\u0648\u0644\u0627\u062a<\/li>\n\n\n\n<li><code>oldest<\/code>: \u0642\u062f\u06cc\u0645\u06cc\u200c\u062a\u0631\u06cc\u0646 \u0645\u062d\u0635\u0648\u0644\u0627\u062a<\/li>\n\n\n\n<li><code>popularity<\/code>: \u0645\u062d\u0628\u0648\u0628\u200c\u062a\u0631\u06cc\u0646 \u0645\u062d\u0635\u0648\u0644\u0627\u062a<\/li>\n\n\n\n<li><code>discount_high<\/code>: \u0628\u06cc\u0634\u062a\u0631\u06cc\u0646 \u062a\u062e\u0641\u06cc\u0641<\/li>\n\n\n\n<li><code>random<\/code>: \u0645\u0631\u062a\u0628\u200c\u0633\u0627\u0632\u06cc \u062a\u0635\u0627\u062f\u0641\u06cc<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u062a\u0646\u0638\u06cc\u0645\u0627\u062a \u0627\u0636\u0627\u0641\u06cc<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u06cc\u062f \u062a\u0646\u0638\u06cc\u0645\u0627\u062a \u0627\u0636\u0627\u0641\u06cc \u0631\u0627 \u0628\u0647 \u0647\u0645\u0647 \u0645\u062a\u062f\u0647\u0627 \u0627\u0631\u0633\u0627\u0644 \u06a9\u0646\u06cc\u062f:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$args = &#91;\n    'posts_per_page' =&gt; 20, \/\/ \u062a\u0639\u062f\u0627\u062f \u0645\u062d\u0635\u0648\u0644\u0627\u062a \u062f\u0631 \u0635\u0641\u062d\u0647\n    'paged' =&gt; get_query_var('paged', 1), \/\/ \u0634\u0645\u0627\u0631\u0647 \u0635\u0641\u062d\u0647\n    'meta_query' =&gt; &#91;\n        &#91;\n            'key' =&gt; '_stock_status',\n            'value' =&gt; 'instock' \/\/ \u0641\u0642\u0637 \u0645\u062d\u0635\u0648\u0644\u0627\u062a \u0645\u0648\u062c\u0648\u062f\n        ]\n    ]\n];\n\n$products = $productManager-&gt;getAllFormattedProductsAndSort('price_low', $args);<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u0633\u0627\u062e\u062a\u0627\u0631 \u062f\u0627\u062f\u0647\u200c\u0647\u0627\u06cc \u062e\u0631\u0648\u062c\u06cc<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u0647\u0631 \u0645\u062d\u0635\u0648\u0644 \u0634\u0627\u0645\u0644 \u0627\u0637\u0644\u0627\u0639\u0627\u062a \u0632\u06cc\u0631 \u0627\u0633\u062a:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;\n    'id' =&gt; 123, \/\/ \u0634\u0646\u0627\u0633\u0647 \u0645\u062d\u0635\u0648\u0644\n    'title' =&gt; '\u0646\u0627\u0645 \u0645\u062d\u0635\u0648\u0644',\n    'link' =&gt; '\u0644\u06cc\u0646\u06a9 \u0645\u062d\u0635\u0648\u0644',\n    'imageUrl' =&gt; '\u0622\u062f\u0631\u0633 \u062a\u0635\u0648\u06cc\u0631',\n    'imageSize' =&gt; &#91;\n        'width' =&gt; 800,\n        'height' =&gt; 600\n    ],\n    'original_price' =&gt; '100,000 \u062a\u0648\u0645\u0627\u0646',\n    'discounted_price' =&gt; '80,000 \u062a\u0648\u0645\u0627\u0646',\n    'discount_percentage' =&gt; 20,\n    'stock_status' =&gt; 'instock',\n    'categories' =&gt; &#91;\n        &#91;\n            'id' =&gt; 56,\n            'name' =&gt; '\u0627\u0644\u06a9\u062a\u0631\u0648\u0646\u06cc\u06a9',\n            'slug' =&gt; 'electronics'\n        ]\n    ],\n    'tags' =&gt; &#91;\n        &#91;\n            'id' =&gt; 12,\n            'name' =&gt; '\u062a\u062e\u0641\u06cc\u0641',\n            'slug' =&gt; 'sale'\n        ]\n    ],\n    'rating' =&gt; 4.5,\n    'review_count' =&gt; 10,\n    'sku' =&gt; 'ABC123',\n    'type' =&gt; 'simple',\n    'status' =&gt; 'publish'\n]<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u0645\u062f\u06cc\u0631\u06cc\u062a \u062e\u0637\u0627\u0647\u0627<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u0628\u0631\u0627\u06cc \u0645\u062f\u06cc\u0631\u06cc\u062a \u062e\u0637\u0627\u0647\u0627 \u0627\u0632 try-catch \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>try {\n    $products = $productManager-&gt;getFormattedProductsByCategoryAndSort(56, 'price_low');\n} catch (InvalidArgumentException $e) {\n    error_log($e-&gt;getMessage());\n    echo '\u062e\u0637\u0627 \u062f\u0631 \u062f\u0631\u06cc\u0627\u0641\u062a \u0645\u062d\u0635\u0648\u0644\u0627\u062a: ' . $e-&gt;getMessage();\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u0645\u062b\u0627\u0644\u200c\u0647\u0627\u06cc \u06a9\u0627\u0631\u0628\u0631\u062f\u06cc<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u0645\u062b\u0627\u0644 1: \u0646\u0645\u0627\u06cc\u0634 \u0645\u062d\u0635\u0648\u0644\u0627\u062a \u067e\u0631\u062a\u062e\u0641\u06cc\u0641<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u062f\u0631\u06cc\u0627\u0641\u062a 10 \u0645\u062d\u0635\u0648\u0644 \u0628\u0627 \u0628\u06cc\u0634\u062a\u0631\u06cc\u0646 \u062a\u062e\u0641\u06cc\u0641\n$args = &#91;'posts_per_page' =&gt; 10];\n$discounted_products = $productManager-&gt;getAllFormattedProductsAndSort('discount_high', $args);\n\nforeach ($discounted_products as $product) {\n    echo sprintf(\n        '&lt;div class=\"product\"&gt;\n            &lt;h3&gt;%s&lt;\/h3&gt;\n            &lt;img src=\"%s\" alt=\"%s\"&gt;\n            &lt;p&gt;\u0642\u06cc\u0645\u062a \u0627\u0635\u0644\u06cc: %s&lt;\/p&gt;\n            &lt;p&gt;\u0642\u06cc\u0645\u062a \u0628\u0627 \u062a\u062e\u0641\u06cc\u0641: %s&lt;\/p&gt;\n            &lt;p&gt;\u062f\u0631\u0635\u062f \u062a\u062e\u0641\u06cc\u0641: %s%%&lt;\/p&gt;\n        &lt;\/div&gt;',\n        $product&#91;'title'],\n        $product&#91;'imageUrl'],\n        $product&#91;'title'],\n        $product&#91;'original_price'],\n        $product&#91;'discounted_price'],\n        $product&#91;'discount_percentage']\n    );\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u0645\u062b\u0627\u0644 2: \u0641\u06cc\u0644\u062a\u0631 \u0645\u062d\u0635\u0648\u0644\u0627\u062a \u0645\u0648\u062c\u0648\u062f \u06cc\u06a9 \u062f\u0633\u062a\u0647\u200c\u0628\u0646\u062f\u06cc<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>$args = &#91;\n    'meta_query' =&gt; &#91;\n        &#91;\n            'key' =&gt; '_stock_status',\n            'value' =&gt; 'instock'\n        ]\n    ],\n    'posts_per_page' =&gt; 20\n];\n\n$category_products = $productManager-&gt;getFormattedProductsByCategoryAndSort(\n    56, \/\/ \u0634\u0646\u0627\u0633\u0647 \u062f\u0633\u062a\u0647\u200c\u0628\u0646\u062f\u06cc\n    'price_low',\n    $args\n);<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u0646\u06a9\u0627\u062a \u0645\u0647\u0645<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u06a9\u0634<\/strong>: \u0628\u0631\u0627\u06cc \u0628\u0647\u0628\u0648\u062f \u0639\u0645\u0644\u06a9\u0631\u062f\u060c \u0646\u062a\u0627\u06cc\u062c \u0628\u0635\u0648\u0631\u062a \u062e\u0648\u062f\u06a9\u0627\u0631 \u06a9\u0634 \u0645\u06cc\u200c\u0634\u0648\u0646\u062f. \u0628\u0631\u0627\u06cc \u067e\u0627\u06a9 \u06a9\u0631\u062f\u0646 \u06a9\u0634:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>$productManager-&gt;clearCache();<\/code><\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u0627\u0639\u062a\u0628\u0627\u0631\u0633\u0646\u062c\u06cc<\/strong>: \u062a\u0645\u0627\u0645 \u0648\u0631\u0648\u062f\u06cc\u200c\u0647\u0627 \u0627\u0639\u062a\u0628\u0627\u0631\u0633\u0646\u062c\u06cc \u0645\u06cc\u200c\u0634\u0648\u0646\u062f \u0648 \u062f\u0631 \u0635\u0648\u0631\u062a \u0646\u0627\u0645\u0639\u062a\u0628\u0631 \u0628\u0648\u062f\u0646 \u062e\u0637\u0627 \u0628\u0631\u0645\u06cc\u200c\u06af\u0631\u062f\u0627\u0646\u0646\u062f.<\/li>\n\n\n\n<li><strong>\u067e\u0631\u062f\u0627\u0632\u0634 \u062a\u0635\u0627\u0648\u06cc\u0631<\/strong>: \u0627\u0646\u062f\u0627\u0632\u0647 \u062a\u0635\u0627\u0648\u06cc\u0631 \u0628\u0635\u0648\u0631\u062a \u062e\u0648\u062f\u06a9\u0627\u0631 \u0645\u062d\u0627\u0633\u0628\u0647 \u0648 \u0628\u0631\u06af\u0631\u062f\u0627\u0646\u062f\u0647 \u0645\u06cc\u200c\u0634\u0648\u0646\u062f.<\/li>\n\n\n\n<li><strong>\u0642\u06cc\u0645\u062a\u200c\u0647\u0627<\/strong>: \u0642\u06cc\u0645\u062a\u200c\u0647\u0627 \u0628\u0627 \u0641\u0631\u0645\u062a \u067e\u0648\u0644\u06cc \u0648 \u0648\u0627\u062d\u062f \u067e\u0648\u0644 \u0633\u0627\u06cc\u062a \u0628\u0631\u06af\u0631\u062f\u0627\u0646\u062f\u0647 \u0645\u06cc\u200c\u0634\u0648\u0646\u062f.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">\u067e\u0634\u062a\u06cc\u0628\u0627\u0646\u06cc \u0648 \u062a\u0648\u0633\u0639\u0647<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u0627\u06cc\u0646 \u06a9\u0644\u0627\u0633 \u0628\u0635\u0648\u0631\u062a \u0645\u062f\u0627\u0648\u0645 \u062f\u0631 \u062d\u0627\u0644 \u0628\u0647\u0628\u0648\u062f \u0627\u0633\u062a. \u0627\u06af\u0631 \u0645\u0634\u06a9\u0644\u06cc \u067e\u06cc\u062f\u0627 \u06a9\u0631\u062f\u06cc\u062f \u06cc\u0627 \u067e\u06cc\u0634\u0646\u0647\u0627\u062f\u06cc \u0628\u0631\u0627\u06cc \u0628\u0647\u0628\u0648\u062f \u062f\u0627\u0631\u06cc\u062f\u060c \u0644\u0637\u0641\u0627\u064b \u0627\u0637\u0644\u0627\u0639 \u062f\u0647\u06cc\u062f.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0628\u0631\u0627\u06cc \u062f\u0631\u06cc\u0627\u0641\u062a \u0622\u062e\u0631\u06cc\u0646 \u0646\u0633\u062e\u0647 \u0648 \u06af\u0632\u0627\u0631\u0634 \u0645\u0634\u06a9\u0644\u0627\u062a \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u06cc\u062f \u0628\u0647 \u0645\u062e\u0632\u0646 \u06af\u06cc\u062a\u200c\u0647\u0627\u0628 \u0645\u0631\u0627\u062c\u0639\u0647 \u06a9\u0646\u06cc\u062f:<br>[\u0644\u06cc\u0646\u06a9 \u0645\u062e\u0632\u0646 \u06af\u06cc\u062a\u200c\u0647\u0627\u0628]<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u067e\u0631\u0633\u0634\u200c\u0647\u0627\u06cc \u0645\u062a\u062f\u0627\u0648\u0644<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u0686\u0631\u0627 \u0627\u0632 \u0627\u06cc\u0646 \u06a9\u0644\u0627\u0633 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u0645\u061f<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u0627\u0633\u062a\u0627\u0646\u062f\u0627\u0631\u062f\u200c\u0633\u0627\u0632\u06cc \u062e\u0631\u0648\u062c\u06cc \u0645\u062d\u0635\u0648\u0644\u0627\u062a<\/li>\n\n\n\n<li>\u0645\u062f\u06cc\u0631\u06cc\u062a \u0628\u0647\u062a\u0631 \u06a9\u0634<\/li>\n\n\n\n<li>\u06a9\u062f \u062a\u0645\u06cc\u0632\u062a\u0631 \u0648 \u0642\u0627\u0628\u0644 \u0646\u06af\u0647\u062f\u0627\u0631\u06cc<\/li>\n\n\n\n<li>\u0645\u062f\u06cc\u0631\u06cc\u062a \u062e\u0637\u0627\u0647\u0627\u06cc \u0628\u0647\u062a\u0631<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u0622\u06cc\u0627 \u0627\u06cc\u0646 \u06a9\u0644\u0627\u0633 \u0628\u0627 \u0646\u0633\u062e\u0647\u200c\u0647\u0627\u06cc \u0645\u062e\u062a\u0644\u0641 \u0648\u0648\u06a9\u0627\u0645\u0631\u0633 \u0633\u0627\u0632\u06af\u0627\u0631 \u0627\u0633\u062a\u061f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u0628\u0644\u0647\u060c \u0627\u06cc\u0646 \u06a9\u0644\u0627\u0633 \u0628\u0627 \u0646\u0633\u062e\u0647\u200c\u0647\u0627\u06cc \u0645\u062e\u062a\u0644\u0641 \u0648\u0648\u06a9\u0627\u0645\u0631\u0633 (\u0627\u0632 \u0646\u0633\u062e\u0647 3.0 \u0628\u0647 \u0628\u0627\u0644\u0627) \u0633\u0627\u0632\u06af\u0627\u0631 \u0627\u0633\u062a.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u0622\u06cc\u0627 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646 \u0627\u06cc\u0646 \u06a9\u0644\u0627\u0633 \u0631\u0627 \u06af\u0633\u062a\u0631\u0634 \u062f\u0627\u062f\u061f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u0628\u0644\u0647\u060c \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u06cc\u062f \u0628\u0627 \u0627\u0631\u062b\u200c\u0628\u0631\u06cc \u0627\u0632 \u0627\u06cc\u0646 \u06a9\u0644\u0627\u0633\u060c \u0645\u062a\u062f\u0647\u0627\u06cc \u062c\u062f\u06cc\u062f \u0627\u0636\u0627\u0641\u0647 \u06a9\u0646\u06cc\u062f \u06cc\u0627 \u0645\u062a\u062f\u0647\u0627\u06cc \u0645\u0648\u062c\u0648\u062f \u0631\u0627 \u062a\u063a\u06cc\u06cc\u0631 \u062f\u0647\u06cc\u062f.<br><br>\u06a9\u062f \u06a9\u0627\u0645\u0644 \u06a9\u0644\u0627\u0633:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\nnamespace App;\n\n\nuse Exception;\nuse InvalidArgumentException;\nuse WP_Query;\n\nclass EnhancedWooCommerceProductManager\n{\n    private bool $cache_enabled;\n    private int $posts_per_page;\n    private int $paged;\n    private int $cache_duration;\n    private array $valid_sort_types = &#91;\n        'newest',\n        'oldest',\n        'price_low',\n        'price_high',\n        'popularity',\n        'discount_high',\n        'random'\n    ];\n\n    public function __construct(\n        int $posts_per_page = 12,\n        int $paged = 1,\n        bool $enable_cache = true,\n        int $cache_duration = HOUR_IN_SECONDS\n    ) {\n        $this->cache_enabled = $enable_cache;\n        $this->posts_per_page = max(1, $posts_per_page);\n        $this->paged = max(1, $paged);\n        $this->cache_duration = $cache_duration;\n    }\n\n    \/**\n     * Get formatted products with all necessary data\n     * \n     * @param array $args Query arguments\n     * @return array\n     * @throws InvalidArgumentException\n     *\/\n    public function getFormattedProducts(array $args = &#91;]): array\n    {\n        try {\n            $raw_products = $this->getProducts($args);\n            return array_map(&#91;$this, 'formatProductData'], $raw_products);\n        } catch (Exception $e) {\n            error_log(\"Product formatting error: \" . $e->getMessage());\n            throw new InvalidArgumentException(\"Failed to format products: \" . $e->getMessage());\n        }\n    }\n\n    \/**\n     * Get formatted products by IDs\n     * \n     * @param array $product_ids Array of product IDs\n     * @return array\n     *\/\n    public function getFormattedProductsByIds(array $product_ids): array\n    {\n        if (empty($product_ids)) {\n            return &#91;];\n        }\n\n        $args = &#91;\n            'post__in' => array_map('absint', $product_ids),\n            'orderby' => 'post__in'\n        ];\n\n        return $this->getFormattedProducts($args);\n    }\n\n    \/**\n     * Get formatted products sorted by specified type\n     * \n     * @param string $sort_type Sort type\n     * @param array $args Additional arguments\n     * @return array\n     *\/\n    public function getFormattedProductsSortedBy(string $sort_type, array $args = &#91;]): array\n    {\n        return $this->getFormattedProducts(\n            $this->prepareSortArgs($sort_type, $args)\n        );\n    }\n\n    \/**\n     * Format single product data\n     * \n     * @param WP_Post $product_post\n     * @return array\n     *\/\n    private function formatProductData($product_post): array\n    {\n        try {\n            $product = wc_get_product($product_post->ID);\n\n            if (!$product) {\n                throw new Exception(\"Invalid product ID: {$product_post->ID}\");\n            }\n\n            return &#91;\n                'id' => $product->get_id(),\n                'title' => $product->get_name(),\n                'link' => get_permalink($product->get_id()),\n                'imageUrl' => $this->getProductImageUrl($product),\n                'imageSize' => $this->getProductImageSize($product),\n                'original_price' => $this->getFormattedPrice($product->get_regular_price()),\n                'discounted_price' => $this->getFormattedPrice($product->get_sale_price()),\n                'discount_percentage' => $this->calculateDiscount($product->get_id()),\n                'stock_status' => $product->get_stock_status(),\n                'categories' => $this->getProductCategories($product),\n                'tags' => $this->getProductTags($product),\n                'rating' => $product->get_average_rating(),\n                'review_count' => $product->get_review_count(),\n                'sku' => $product->get_sku(),\n                'type' => $product->get_type(),\n                'status' => $product->get_status()\n            ];\n        } catch (Exception $e) {\n            error_log(\"Product formatting error: \" . $e->getMessage());\n            return &#91;\n                'id' => $product_post->ID,\n                'error' => 'Failed to format product data'\n            ];\n        }\n    }\n\n    \/**\n     * Get product image URL with error handling\n     *\/\n    private function getProductImageUrl($product): ?string\n    {\n        try {\n            $image_id = $product->get_image_id();\n            if (!$image_id) {\n                return null;\n            }\n            return wp_get_attachment_image_url($image_id, 'full');\n        } catch (Exception $e) {\n            error_log(\"Error getting product image URL: \" . $e->getMessage());\n            return null;\n        }\n    }\n\n    \/**\n     * Get product image dimensions\n     *\/\n    private function getProductImageSize($product): array\n    {\n        try {\n            $image_id = $product->get_image_id();\n            if (!$image_id) {\n                return &#91;'width' => 0, 'height' => 0];\n            }\n            $metadata = wp_get_attachment_metadata($image_id);\n            return &#91;\n                'width' => $metadata&#91;'width'] ?? 0,\n                'height' => $metadata&#91;'height'] ?? 0\n            ];\n        } catch (Exception $e) {\n            error_log(\"Error getting image size: \" . $e->getMessage());\n            return &#91;'width' => 0, 'height' => 0];\n        }\n    }\n\n    \/**\n     * Format price with currency\n     *\/\n    private function getFormattedPrice(?string $price): ?string\n    {\n        if (empty($price)) {\n            return null;\n        }\n        return html_entity_decode(strip_tags(wc_price($price)));\n    }\n\n    \/**\n     * Get product categories\n     *\/\n    private function getProductCategories($product): array\n    {\n        try {\n            $categories = &#91;];\n            $terms = get_the_terms($product->get_id(), 'product_cat');\n\n            if (!empty($terms) &amp;&amp; !is_wp_error($terms)) {\n                foreach ($terms as $term) {\n                    $categories&#91;] = &#91;\n                        'id' => $term->term_id,\n                        'name' => $term->name,\n                        'slug' => $term->slug\n                    ];\n                }\n            }\n\n            return $categories;\n        } catch (Exception $e) {\n            error_log(\"Error getting product categories: \" . $e->getMessage());\n            return &#91;];\n        }\n    }\n\n    \/**\n     * Get product tags\n     *\/\n    private function getProductTags($product): array\n    {\n        try {\n            $tags = &#91;];\n            $terms = get_the_terms($product->get_id(), 'product_tag');\n\n            if (!empty($terms) &amp;&amp; !is_wp_error($terms)) {\n                foreach ($terms as $term) {\n                    $tags&#91;] = &#91;\n                        'id' => $term->term_id,\n                        'name' => $term->name,\n                        'slug' => $term->slug\n                    ];\n                }\n            }\n\n            return $tags;\n        } catch (Exception $e) {\n            error_log(\"Error getting product tags: \" . $e->getMessage());\n            return &#91;];\n        }\n    }\n\n    \/**\n     * Prepare sorting arguments\n     *\/\n    private function prepareSortArgs(string $sort_type, array $args = &#91;]): array\n    {\n        if (!in_array($sort_type, $this->valid_sort_types)) {\n            throw new InvalidArgumentException(\n                \"Invalid sort type. Valid types are: \" . implode(', ', $this->valid_sort_types)\n            );\n        }\n\n        $sort_options = $this->getSortOptions();\n        return array_merge($args, $sort_options&#91;$sort_type]);\n    }\n\n\n\n    \/**\n     * Get products based on provided arguments\n     * \n     * @param array $args Query arguments\n     * @return array\n     * @throws InvalidArgumentException\n     *\/\n    public function getProducts(array $args = &#91;]): array\n    {\n        try {\n            $args = $this->prepareQueryArgs($args);\n            $cache_key = $this->generateCacheKey($args);\n\n            if ($this->shouldUseCache($cache_key)) {\n                return $this->getFromCache($cache_key);\n            }\n\n            $products = $this->executeQuery($args);\n            $this->cacheResults($cache_key, $products);\n\n            return $products;\n        } catch (Exception $e) {\n            error_log(\"EnhancedWooCommerceProductManager Error: \" . $e->getMessage());\n            throw new InvalidArgumentException(\"Failed to fetch products: \" . $e->getMessage());\n        }\n    }\n\n    \/**\n     * Get products by category with validation\n     *\/\n    public function getProductsByCategory(string $category, array $args = &#91;]): array\n    {\n        if (empty($category)) {\n            throw new InvalidArgumentException(\"Category slug cannot be empty\");\n        }\n\n        if (!term_exists($category, 'product_cat')) {\n            throw new InvalidArgumentException(\"Invalid category slug: {$category}\");\n        }\n\n        $args&#91;'tax_query'] = &#91;&#91;\n            'taxonomy' => 'product_cat',\n            'field'    => 'slug',\n            'terms'    => $category,\n            'operator' => 'IN'\n        ]];\n\n        return $this->getProducts($args);\n    }\n\n    \/**\n     * Get products by tag with validation\n     *\/\n    public function getProductsByTag(string $tag, array $args = &#91;]): array\n    {\n        if (empty($tag)) {\n            throw new InvalidArgumentException(\"Tag slug cannot be empty\");\n        }\n\n        $args&#91;'tax_query'] = &#91;&#91;\n            'taxonomy' => 'product_tag',\n            'field'    => 'slug',\n            'terms'    => $tag,\n            'operator' => 'IN'\n        ]];\n\n        return $this->getProducts($args);\n    }\n\n    \/**\n     * Sort products with validation\n     *\/\n    public function sortBy(string $type, array $args = &#91;]): array\n    {\n        if (!in_array($type, $this->valid_sort_types)) {\n            throw new InvalidArgumentException(\n                \"Invalid sort type. Valid types are: \" . implode(', ', $this->valid_sort_types)\n            );\n        }\n\n        $sort_options = $this->getSortOptions();\n        return $this->getProducts(array_merge($args, $sort_options&#91;$type]));\n    }\n\n    \/**\n     * Get products with highest discount\n     *\/\n    public function getProductsByHighestDiscount(array $args = &#91;]): array\n    {\n        $products = $this->getProducts($args);\n\n        return $this->sortProductsByDiscount($products);\n    }\n\n    \/**\n     * Clear cache with specific patterns\n     *\/\n    public function clearCache(string $pattern = 'wc_products_'): bool\n    {\n        try {\n            global $wpdb;\n            $pattern = $wpdb->esc_like('_transient_' . $pattern);\n            $result = $wpdb->query(\n                $wpdb->prepare(\n                    \"DELETE FROM {$wpdb->options} WHERE option_name LIKE %s\",\n                    $pattern . '%'\n                )\n            );\n            wp_cache_flush();\n            return $result !== false;\n        } catch (Exception $e) {\n            error_log(\"Cache clearing failed: \" . $e->getMessage());\n            return false;\n        }\n    }\n\n    \/**\n     * Private helper methods\n     *\/\n    private function prepareQueryArgs(array $args): array\n    {\n        $default_args = &#91;\n            'post_type' => 'product',\n            'post_status' => 'publish',\n            'posts_per_page' => $this->posts_per_page,\n            'paged' => $this->paged,\n            'no_found_rows' => !$this->shouldPaginate($args)\n        ];\n\n        return wp_parse_args($args, $default_args);\n    }\n\n    private function generateCacheKey(array $args): string\n    {\n        return 'wc_products_' . md5(serialize($args) . $this->cache_duration);\n    }\n\n    private function shouldUseCache(string $cache_key): bool\n    {\n        return $this->cache_enabled &amp;&amp; get_transient($cache_key) !== false;\n    }\n\n    private function getFromCache(string $cache_key)\n    {\n        return get_transient($cache_key);\n    }\n\n    private function executeQuery(array $args): array\n    {\n        $query = new WP_Query($args);\n        return $query->posts;\n    }\n\n    private function cacheResults(string $cache_key, array $products): void\n    {\n        if ($this->cache_enabled) {\n            set_transient($cache_key, $products, $this->cache_duration);\n        }\n    }\n\n    private function calculateDiscount(int $product_id): float\n    {\n        $product = wc_get_product($product_id);\n\n        if (!$product || !$product->is_on_sale()) {\n            return 0.0;\n        }\n\n        $regular_price = (float) $product->get_regular_price();\n        $sale_price = (float) $product->get_sale_price();\n\n        if ($regular_price &lt;= 0) {\n            return 0.0;\n        }\n\n        return round((($regular_price - $sale_price) \/ $regular_price) * 100, 2);\n    }\n\n    private function sortProductsByDiscount(array $products): array\n    {\n        usort($products, function ($a, $b) {\n            $discount_a = $this->calculateDiscount($a->ID);\n            $discount_b = $this->calculateDiscount($b->ID);\n            return $discount_b &lt;=> $discount_a;\n        });\n\n        return $products;\n    }\n\n    private function getSortOptions(): array\n    {\n        return &#91;\n            'newest' => &#91;\n                'orderby' => 'date',\n                'order' => 'DESC'\n            ],\n            'oldest' => &#91;\n                'orderby' => 'date',\n                'order' => 'ASC'\n            ],\n            'price_low' => &#91;\n                'orderby' => 'meta_value_num',\n                'meta_key' => '_price',\n                'order' => 'ASC'\n            ],\n            'price_high' => &#91;\n                'orderby' => 'meta_value_num',\n                'meta_key' => '_price',\n                'order' => 'DESC'\n            ],\n            'popularity' => &#91;\n                'orderby' => 'meta_value_num',\n                'meta_key' => 'total_sales',\n                'order' => 'DESC'\n            ],\n            'discount_high' => &#91;\n                'orderby' => 'meta_value_num',\n                'meta_key' => '_sale_price',\n                'order' => 'ASC'\n            ],\n            'random' => &#91;\n                'orderby' => 'rand'\n            ]\n        ];\n    }\n\n    private function shouldPaginate(array $args): bool\n    {\n        return !isset($args&#91;'no_found_rows']) || $args&#91;'no_found_rows'] === false;\n    }\n    public function sortFormattedProducts(array $products, string $sort_type): array\n    {\n        if (empty($products)) {\n            return &#91;];\n        }\n\n        switch ($sort_type) {\n            case 'price_low':\n                usort($products, function ($a, $b) {\n                    $price_a = $this->getPriceForSorting($a);\n                    $price_b = $this->getPriceForSorting($b);\n                    return $price_a &lt;=> $price_b;\n                });\n                break;\n\n            case 'price_high':\n                usort($products, function ($a, $b) {\n                    $price_a = $this->getPriceForSorting($a);\n                    $price_b = $this->getPriceForSorting($b);\n                    return $price_b &lt;=> $price_a;\n                });\n                break;\n\n            case 'discount_high':\n                usort($products, function ($a, $b) {\n                    return $b&#91;'discount_percentage'] &lt;=> $a&#91;'discount_percentage'];\n                });\n                break;\n\n            case 'newest':\n                usort($products, function ($a, $b) {\n                    return $b&#91;'id'] &lt;=> $a&#91;'id'];\n                });\n                break;\n\n            case 'oldest':\n                usort($products, function ($a, $b) {\n                    return $a&#91;'id'] &lt;=> $b&#91;'id'];\n                });\n                break;\n        }\n\n        return $products;\n    }\n    public function getFormattedProductsByIdsAndSort(array $product_ids, string $sort_type = 'price_low'): array\n    {\n        $products = $this->getFormattedProductsByIds($product_ids);\n        return $this->sortFormattedProducts($products, $sort_type);\n    }\n    private function getPriceForSorting(array $product): float\n    {\n        $price = $product&#91;'discounted_price'] ?? $product&#91;'original_price'] ?? '0';\n        return (float) preg_replace('\/&#91;^0-9.]\/', '', $price);\n    }\n\n    public function getFormattedProductsByTagAndSort(\n        string $tag,\n        string $sort_type = 'price_low',\n        array $args = &#91;]\n    ): array {\n        if (empty($tag)) {\n            throw new InvalidArgumentException(\"Tag slug cannot be empty\");\n        }\n\n        $args&#91;'tax_query'] = &#91;&#91;\n            'taxonomy' => 'product_tag',\n            'field'    => 'slug',\n            'terms'    => $tag,\n            'operator' => 'IN'\n        ]];\n\n        $products = $this->getFormattedProducts($args);\n        return $this->sortFormattedProducts($products, $sort_type);\n    }\n\n    public function getFormattedProductsByMultipleTagsAndSort(\n        array $tags,\n        string $sort_type = 'price_low',\n        array $args = &#91;]\n    ): array {\n        if (empty($tags)) {\n            throw new InvalidArgumentException(\"Tags array cannot be empty\");\n        }\n\n        $args&#91;'tax_query'] = &#91;&#91;\n            'taxonomy' => 'product_tag',\n            'field'    => 'slug',\n            'terms'    => $tags,\n            'operator' => 'IN'\n        ]];\n\n        $products = $this->getFormattedProducts($args);\n        return $this->sortFormattedProducts($products, $sort_type);\n    }\n\n\n\n    public function getAllFormattedProductsAndSort(string $sort_type = 'price_low', array $args = &#91;]): array\n    {\n        $default_args = &#91;\n            'post_type' => 'product',\n            'post_status' => 'publish',\n            'posts_per_page' => $this->posts_per_page,\n            'paged' => $this->paged\n        ];\n\n        $query_args = wp_parse_args($args, $default_args);\n        $products = $this->getFormattedProducts($query_args);\n        return $this->sortFormattedProducts($products, $sort_type);\n    }\n\n\n    public function getFormattedProductsByBrandAndSort(string $brand, string $sort_type = 'price_low', array $args = &#91;]): array\n    {\n        if (empty($brand)) {\n            throw new InvalidArgumentException(\"Brand slug cannot be empty\");\n        }\n\n        $args&#91;'tax_query'] = &#91;&#91;\n            'taxonomy' => 'product_brand', \/\/ \u06cc\u0627 \u0646\u0627\u0645 \u062a\u06a9\u0633\u0648\u0646\u0648\u0645\u06cc \u0628\u0631\u0646\u062f \u0634\u0645\u0627\n            'field'    => 'slug',\n            'terms'    => $brand,\n            'operator' => 'IN'\n        ]];\n\n        $products = $this->getFormattedProducts($args);\n        return $this->sortFormattedProducts($products, $sort_type);\n    }\n\n\n    public function getFormattedProductsByMultipleBrandsAndSort(array $brands, string $sort_type = 'price_low', array $args = &#91;]): array\n    {\n        if (empty($brands)) {\n            throw new InvalidArgumentException(\"Brands array cannot be empty\");\n        }\n\n        $args&#91;'tax_query'] = &#91;&#91;\n            'taxonomy' => 'product_brand', \/\/ \u06cc\u0627 \u0646\u0627\u0645 \u062a\u06a9\u0633\u0648\u0646\u0648\u0645\u06cc \u0628\u0631\u0646\u062f \u0634\u0645\u0627\n            'field'    => 'slug',\n            'terms'    => $brands,\n            'operator' => 'IN'\n        ]];\n\n        $products = $this->getFormattedProducts($args);\n        return $this->sortFormattedProducts($products, $sort_type);\n    }\n\n\n\n    public function getFormattedProductsByCategoryAndSort($category_id, string $sort_type = 'price_low', array $args = &#91;]): array\n    {\n        if (empty($category_id)) {\n            throw new InvalidArgumentException(\"Category ID cannot be empty\");\n        }\n\n        \/\/ Convert to integer and validate\n        $category_id = (int) $category_id;\n        $term = get_term($category_id, 'product_cat');\n\n        if (!$term || is_wp_error($term)) {\n            throw new InvalidArgumentException(\"Invalid category ID: {$category_id}\");\n        }\n\n        $args&#91;'tax_query'] = &#91;&#91;\n            'taxonomy' => 'product_cat',\n            'field'    => 'term_id',\n            'terms'    => $category_id,\n            'operator' => 'IN'\n        ]];\n\n        $products = $this->getFormattedProducts($args);\n        return $this->sortFormattedProducts($products, $sort_type);\n    }\n\n    \/**\n     * Get formatted products by multiple category IDs with sorting\n     * \n     * @param array $category_ids Array of category IDs\n     * @param string $sort_type Sort type\n     * @param array $args Additional arguments\n     * @return array\n     *\/\n    public function getFormattedProductsByMultipleCategoriesAndSort(array $category_ids, string $sort_type = 'price_low', array $args = &#91;]): array\n    {\n        if (empty($category_ids)) {\n            throw new InvalidArgumentException(\"Category IDs array cannot be empty\");\n        }\n\n        \/\/ Convert all IDs to integers\n        $category_ids = array_map('intval', $category_ids);\n\n        \/\/ Validate all category IDs\n        foreach ($category_ids as $id) {\n            $term = get_term($id, 'product_cat');\n            if (!$term || is_wp_error($term)) {\n                throw new InvalidArgumentException(\"Invalid category ID: {$id}\");\n            }\n        }\n\n        $args&#91;'tax_query'] = &#91;&#91;\n            'taxonomy' => 'product_cat',\n            'field'    => 'term_id',\n            'terms'    => $category_ids,\n            'operator' => 'IN'\n        ]];\n\n        $products = $this->getFormattedProducts($args);\n        return $this->sortFormattedProducts($products, $sort_type);\n    }\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0645\u0639\u0631\u0641\u06cc \u06a9\u0644\u0627\u0633 EnhancedWooCommerceProductManager \u06cc\u06a9 \u0627\u0628\u0632\u0627\u0631 \u0642\u062f\u0631\u062a\u0645\u0646\u062f \u0628\u0631\u0627\u06cc \u0645\u062f\u06cc\u0631\u06cc\u062a \u0648 \u062f\u0631\u06cc\u0627\u0641\u062a \u0645\u062d\u0635\u0648\u0644\u0627\u062a \u0648\u0648\u06a9\u0627\u0645\u0631\u0633 \u0627\u0633\u062a. \u0627\u06cc\u0646 \u06a9\u0644\u0627\u0633 \u0627\u0645\u06a9\u0627\u0646\u0627\u062a \u0632\u06cc\u0631 \u0631\u0627 \u062f\u0631 \u0627\u062e\u062a\u06cc\u0627\u0631&#8230;<\/p>\n","protected":false},"author":1,"featured_media":2550,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2633","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/razmjoui.ir\/index.php?rest_route=\/wp\/v2\/posts\/2633","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/razmjoui.ir\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/razmjoui.ir\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/razmjoui.ir\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/razmjoui.ir\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2633"}],"version-history":[{"count":6,"href":"https:\/\/razmjoui.ir\/index.php?rest_route=\/wp\/v2\/posts\/2633\/revisions"}],"predecessor-version":[{"id":2644,"href":"https:\/\/razmjoui.ir\/index.php?rest_route=\/wp\/v2\/posts\/2633\/revisions\/2644"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/razmjoui.ir\/index.php?rest_route=\/wp\/v2\/media\/2550"}],"wp:attachment":[{"href":"https:\/\/razmjoui.ir\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2633"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/razmjoui.ir\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2633"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/razmjoui.ir\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2633"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}