تابع wc_products_array_orderby ترتیب بندی و sort محصولات بر اساس فیلد مورد نظر

تابع ووکامرسی wc_products_array_orderby – ترتیب بندی و sort محصولات بر اساس فیلد مورد نظر
Syntax – سینتکس
(array) wc_products_array_orderby( (array) $products, (string) $orderby = 'date', (string) $order = 'desc' );
Parameters – پارامتر ها (3)
- 1- $products (array)
- 2- $orderby (string)
- 3- $order (string)
Usage – نحوه استفاده
if ( !function_exists( 'wc_products_array_orderby' ) ) { require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-product-functions.php'; } // The products. $products = array(); // The orderby. $orderby = 'date'; // The order. $order = 'desc'; // NOTICE! Understand what this does before running. $result = wc_products_array_orderby($products, $orderby, $order);
Defined – محل تعریف
/includes/wc-product-functions.php
function wc_products_array_orderby( $products, $orderby = 'date', $order = 'desc' ) { $orderby = strtolower( $orderby ); $order = strtolower( $order ); switch ( $orderby ) { case 'title' : case 'id' : case 'date' : case 'modified' : case 'menu_order' : case 'price' : usort( $products, 'wc_products_array_orderby_' . $orderby ); break; default : shuffle( $products ); break; } if ( 'desc' === $order ) { $products = array_reverse( $products ); } return $products; }
versions – نسخه ها
از نسخه : 3.0.0
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر