get_terms orderby numeric

You can use usort to sort the object $children. The function to sort after you got the $children object can be like this: usort( $children, function($a, $b) { $ai = filter_var($a->name, FILTER_SANITIZE_NUMBER_INT); $bi = filter_var($b->name, FILTER_SANITIZE_NUMBER_INT); if ($ai == $bi) { return 0; } return ($ai < $bi) ? -1 : 1; });

Limiting woocommerce line_total decimal length

Just round the decimal to two digit as per your requirement. $myID = 2859; $myorder = new WC_Order($myID); foreach ($myorder->get_items(‘line_item’) as $item) { $rounded_total = round($item[“line_total”],2);// allow 2 decimal and avoid further $Data = $Data.OrderLine($item[“name”], $rounded_total, $item[“line_tax”], $item[“qty”], “piece”, “x”); }

How to quickly reorder posts in the admin panel that will persist for the wp-api

Let’s assume it stores the custom order into the menu_order column in the wp_posts table. If you mean the hierarchical page post type (supports page-attributes) then one can order with the query variables: /wp-json/wp/v2/pages/?orderby=menu_order&order=asc If you mean the post post type with: /wp-json/wp/v2/posts/ there’s a way using the rest_{post_type}_query filter: /** * Set orderby to … Read more

Complex Orderby Parameters: How to query with multiple orderby parameters using meta_value_num?

Boohoo why did I start a bounty for that 😉 The answer is pretty simple – add ‘type’ => ‘numeric’ to the meta query. array(5) { [“posts_per_page”]=> int(6) [“orderby”]=> array(2) { [“uss_product_price”]=> string(4) “DESC” [“uss_product_weight”]=> string(4) “DESC” } [“meta_query”]=> array(3) { [“relation”]=> string(3) “AND” [“sortprimary_clause”]=> array(3) { [“key”]=> string(17) “uss_product_price” [“compare”]=> string(6) “EXISTS” [“type”]=> string(7) … Read more

Woocommerce: Add column to ORDERS admin page with items purchased

I have already manage to create a column thanks to this: // ADDING COLUMN TITLES add_filter( ‘manage_edit-shop_order_columns’, ‘custom_shop_order_column’,11); function custom_shop_order_column($columns) { //add columns $columns[‘my-column1’] = __( ‘Column Title’,’theme_slug’); return $columns; } // adding the data for each orders by column (example) add_action( ‘manage_shop_order_posts_custom_column’ , ‘custom_orders_list_column_content’, 10, 2 ); function custom_orders_list_column_content( $column ) { global $post, … Read more

Create WooCommerce new order with specific ID

Well.. You can add meta for original and cloned order. Just add +1 for it, each time when you will clone items. function create_order( $original_order_id, … try { $new_order = new WC_Order(); $new_order->set_props( array( … } $original_order = wc_get_order( $original_order_id ); $order_item_num = $original_order->get_meta(‘_order_items_num’); if($order_item_num >= 1) { $new_order->update_meta_data( ‘_order_item_num’, $order_item_num+1 ); $new_order->save(); $original_order->update_meta_data( ‘_order_items_num’, … Read more

WP_Query ordering numbers as letters

To evaluate a meta value as a number, use meta_value_num. Try: $args = array( “fields” => “ids”, “meta_key” => “jogador_oficial”, “meta_value” => true, “meta_query” => array( “relation” => “AND”, “query_one” => array( “key” => “quantidade_corretas” “orderby” => “meta_value_num”, “order” => “DESC” ), “query_two” => array( “key” => “tempo_total” “orderby” => “meta_value_num”, “order” => “ASC” ), … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)