@@ -123,8 +123,7 @@ public function delete( &$order, $args = array() ) {
123123 * Read order data.
124124 *
125125 * @param WC_Order $order The order object, passed by reference.
126- * @param object $post_object
127- * @since 1.0.0
126+ * @param object $post_object The post object.
128127 */
129128 protected function read_order_data ( &$ order , $ post_object ) {
130129 global $ wpdb ;
@@ -258,8 +257,9 @@ protected function update_post_meta( &$order ) {
258257 /**
259258 * Excerpt for post.
260259 *
261- * @param WC_Order $order
262- * @return string
260+ * @param WC_Order $order The order object.
261+ *
262+ * @return string The post excerpt.
263263 */
264264 protected function get_post_excerpt ( $ order ) {
265265 return $ order ->get_customer_note ();
@@ -268,8 +268,11 @@ protected function get_post_excerpt( $order ) {
268268 /**
269269 * Get amount already refunded.
270270 *
271- * @param WC_Order
272- * @return string
271+ * @global $wpdb
272+ *
273+ * @param WC_Order $order The order object.
274+ *
275+ * @return string The refund amount.
273276 */
274277 public function get_total_refunded ( $ order ) {
275278 global $ wpdb ;
@@ -288,8 +291,11 @@ public function get_total_refunded( $order ) {
288291 /**
289292 * Get the total tax refunded.
290293 *
291- * @param WC_Order
292- * @return float
294+ * @global $wpdb
295+ *
296+ * @param WC_Order $order The order object.
297+ *
298+ * @return float The total refunded tax.
293299 */
294300 public function get_total_tax_refunded ( $ order ) {
295301 global $ wpdb ;
@@ -309,8 +315,11 @@ public function get_total_tax_refunded( $order ) {
309315 /**
310316 * Get the total shipping refunded.
311317 *
312- * @param WC_Order
313- * @return float
318+ * @global $wpdb
319+ *
320+ * @param WC_Order $order The order object.
321+ *
322+ * @return float The total refunded shipping.
314323 */
315324 public function get_total_shipping_refunded ( $ order ) {
316325 global $ wpdb ;
@@ -328,40 +337,58 @@ public function get_total_shipping_refunded( $order ) {
328337 }
329338
330339 /**
331- * Finds an Order ID based on an order key.
340+ * Finds an order ID based on its order key.
341+ *
342+ * @param string $order_key The order key.
332343 *
333- * @param string $order_key An order key has generated by
334344 * @return int The ID of an order, or 0 if the order could not be found
335345 */
336346 public function get_order_id_by_order_key ( $ order_key ) {
337347 global $ wpdb ;
338- return $ wpdb ->get_var ( $ wpdb ->prepare ( "SELECT order_id FROM {$ wpdb ->prefix }woocommerce_orders WHERE order_key = %s " , $ order_key ) );
348+
349+ return $ wpdb ->get_var ( $ wpdb ->prepare (
350+ "SELECT order_id FROM {$ wpdb ->prefix }woocommerce_orders WHERE order_key = %s " ,
351+ $ order_key
352+ ) );
339353 }
340354
341355 /**
342356 * Return count of orders with a specific status.
343357 *
344- * @param string $status
345- * @return int
358+ * @global $wpdb
359+ *
360+ * @param string $status The post_status to filter orders by.
361+ *
362+ * @return int The number of orders with that status.
346363 */
347364 public function get_order_count ( $ status ) {
348365 global $ wpdb ;
349- return absint ( $ wpdb ->get_var ( $ wpdb ->prepare ( "SELECT COUNT( * ) FROM {$ wpdb ->posts } WHERE post_type = 'shop_order' AND post_status = %s " , $ status ) ) );
366+
367+ return absint ( $ wpdb ->get_var ( $ wpdb ->prepare (
368+ "SELECT COUNT(*) FROM {$ wpdb ->posts } WHERE post_type = 'shop_order' AND post_status = %s " ,
369+ $ status
370+ ) ) );
350371 }
351372
352373 /**
353374 * Get all orders matching the passed in args.
354375 *
355- * @see wc_get_orders()
356- * @param array $args
376+ * @see wc_get_orders()
377+ *
378+ * @param array $args {
379+ * Query arguments. All arguments are optional.
380+ *
381+ * @var string $type The post type. Default is 'shop_order'.
382+ * @var
383+ * }
357384 * @return object|array array of orders
358385 */
359386 public function get_orders ( $ args = array () ) {
360387 /**
361388 * Generate WP_Query args. This logic will change if orders are moved to
362389 * custom tables in the future.
363390 */
364- $ wp_query_args = array (
391+ $ wp_query_args = array (
365392 'post_type ' => $ args ['type ' ] ? $ args ['type ' ] : 'shop_order ' ,
366393 'post_status ' => $ args ['status ' ],
367394 'posts_per_page ' => $ args ['limit ' ],
@@ -370,10 +397,6 @@ public function get_orders( $args = array() ) {
370397 'orderby ' => $ args ['orderby ' ],
371398 'order ' => $ args ['order ' ],
372399 );
373-
374- /**
375- * wc_customer_query
376- */
377400 $ wc_customer_query = array ();
378401
379402 if ( ! empty ( $ args ['customer ' ] ) ) {
@@ -449,9 +472,10 @@ public function get_orders( $args = array() ) {
449472 /**
450473 * Generate meta query for wc_get_orders.
451474 *
452- * @param array $values
453- * @param string $relation
454- * @return array
475+ * @param array $values Values to populate the meta query.
476+ * @param string $relation Optional The query relationship, either "and" or "or". Default is "or".
477+ *
478+ * @return array An array suitable for passing to WP_Query's meta_query argument.
455479 */
456480 private function get_orders_generate_customer_meta_query ( $ values , $ relation = 'or ' ) {
457481 $ meta_query = array (
@@ -492,10 +516,11 @@ private function get_orders_generate_customer_meta_query( $values, $relation = '
492516 }
493517
494518 /**
495- * Get unpaid orders after a certain date,
519+ * Get unpaid orders after a certain date.
496520 *
497- * @param int timestamp $date
498- * @return array
521+ * @param int $date The Unix timestamp used for date filtering.
522+ *
523+ * @return array An array of unpaid orders.
499524 */
500525 public function get_unpaid_orders ( $ date ) {
501526 global $ wpdb ;
@@ -514,8 +539,9 @@ public function get_unpaid_orders( $date ) {
514539 /**
515540 * Search order data for a term and return ids.
516541 *
517- * @param string $term
518- * @return array of ids
542+ * @param string $term The search term.
543+ *
544+ * @return array An array of order IDs.
519545 */
520546 public function search_orders ( $ term ) {
521547 global $ wpdb ;
@@ -526,13 +552,12 @@ public function search_orders( $term ) {
526552 $ order_ids [] = absint ( $ term );
527553 }
528554
529- // @todo add order search capability
530-
531555 /**
532556 * Searches on meta data can be slow - this lets you choose what fields to search.
533- * 2.7.0 added _billing_address and _shipping_address meta which contains all address data to make this faster.
534- * This however won't work on older orders unless updated, so search a few others (expand this using the filter if needed).
535- * @var array
557+ *
558+ * WooCommerce 2.7.0 added _billing_address and _shipping_address meta which contains all
559+ * address data to make this faster. However, this won't work on older orders unless they
560+ * are updated, so search a few others (expand this using the filter if needed).
536561 */
537562 $ meta_search_fields = array_map ( 'wc_clean ' , apply_filters ( 'woocommerce_shop_order_search_fields ' , array (
538563 // While we are searching the custom table, we will also search meta when filtered for backwards compatibility.
@@ -560,7 +585,8 @@ public function search_orders( $term ) {
560585 /**
561586 * Gets information about whether permissions were generated yet.
562587 *
563- * @param WC_Order|int $order
588+ * @param WC_Order|int $order The order object or ID.
589+ *
564590 * @return bool
565591 */
566592 public function get_download_permissions_granted ( $ order ) {
@@ -572,8 +598,8 @@ public function get_download_permissions_granted( $order ) {
572598 /**
573599 * Stores information about whether permissions were generated yet.
574600 *
575- * @param WC_Order|int $order
576- * @param bool $set
601+ * @param WC_Order|int $order The order object or ID.
602+ * @param bool $set Whether or not the permissions have been generated.
577603 */
578604 public function set_download_permissions_granted ( $ order , $ set ) {
579605 $ order_id = WC_Order_Factory::get_order_id ( $ order );
@@ -584,7 +610,8 @@ public function set_download_permissions_granted( $order, $set ) {
584610 /**
585611 * Gets information about whether sales were recorded.
586612 *
587- * @param WC_Order|int $order
613+ * @param WC_Order|int $order The order object or ID.
614+ *
588615 * @return bool
589616 */
590617 public function get_recorded_sales ( $ order ) {
@@ -596,8 +623,8 @@ public function get_recorded_sales( $order ) {
596623 /**
597624 * Stores information about whether sales were recorded.
598625 *
599- * @param WC_Order|int $order
600- * @param bool $set
626+ * @param WC_Order|int $order The order object or ID.
627+ * @param bool $set Whether or not the sales have been recorded.
601628 */
602629 public function set_recorded_sales ( $ order , $ set ) {
603630 $ order_id = WC_Order_Factory::get_order_id ( $ order );
@@ -608,7 +635,8 @@ public function set_recorded_sales( $order, $set ) {
608635 /**
609636 * Gets information about whether coupon counts were updated.
610637 *
611- * @param WC_Order|int $order
638+ * @param WC_Order|int $order The order object or ID.
639+ *
612640 * @return bool
613641 */
614642 public function get_recorded_coupon_usage_counts ( $ order ) {
@@ -621,7 +649,7 @@ public function get_recorded_coupon_usage_counts( $order ) {
621649 * Stores information about whether coupon counts were updated.
622650 *
623651 * @param WC_Order|int $order The order object or ID.
624- * @param bool $set Have coupon counts been updated?
652+ * @param bool $set Whether or not the coupon counts have been updated.
625653 */
626654 public function set_recorded_coupon_usage_counts ( $ order , $ set ) {
627655 $ order_id = WC_Order_Factory::get_order_id ( $ order );
@@ -632,7 +660,8 @@ public function set_recorded_coupon_usage_counts( $order, $set ) {
632660 /**
633661 * Gets information about whether stock was reduced.
634662 *
635- * @param WC_Order|int $order
663+ * @param WC_Order|int $order The order object or ID.
664+ *
636665 * @return bool
637666 */
638667 public function get_stock_reduced ( $ order ) {
@@ -645,7 +674,8 @@ public function get_stock_reduced( $order ) {
645674 * Stores information about whether stock was reduced.
646675 *
647676 * @param WC_Order|int $order The order object or ID.
648- * @param bool $set Has the stock been reduced?
677+ *
678+ * @param bool $set Whether or not stock has been reduced.
649679 */
650680 public function set_stock_reduced ( $ order , $ set ) {
651681 $ order_id = WC_Order_Factory::get_order_id ( $ order );
@@ -656,9 +686,9 @@ public function set_stock_reduced( $order, $set ) {
656686 /**
657687 * Get the order type based on Order ID.
658688 *
659- * @since 1.0.0
660- * @param int $order_id
661- * @return string
689+ * @param int $order_id The order ID.
690+ *
691+ * @return string The order post type.
662692 */
663693 public function get_order_type ( $ order_id ) {
664694 return get_post_type ( $ order_id );
@@ -667,10 +697,13 @@ public function get_order_type( $order_id ) {
667697 /**
668698 * Populate custom table with data from postmeta, for migrations.
669699 *
670- * @since 1.0.0
671- * @param bool $save
672- * @param bool $delete
673- * @return bool
700+ * @param WC_Order $order The order object, passed by reference.
701+ * @param bool $save Optional. Whether or not the post meta should be updated. Default
702+ * is true.
703+ * @param bool $delete Optional. Whether or not the post meta should be deleted. Default
704+ * is false.
705+ *
706+ * @return WC_Order the order object.
674707 */
675708 public function populate_from_meta ( &$ order , $ save = true , $ delete = false ) {
676709 $ table_data = $ this ->get_order_data_from_table ( $ order );
@@ -688,6 +721,7 @@ public function populate_from_meta( &$order, $save = true, $delete = false ) {
688721 case 'prices_include_tax ' :
689722 $ order ->set_prices_include_tax ( 'yes ' === $ meta );
690723 break ;
724+
691725 default :
692726 $ order ->{"set_ {$ column }" }( $ meta );
693727 }
@@ -712,8 +746,7 @@ public function populate_from_meta( &$order, $save = true, $delete = false ) {
712746 /**
713747 * Populate order postmeta from a custom table, for rolling back.
714748 *
715- * @since 1.0.0
716- * @return void
749+ * @param WC_Order $order The order object, passed by reference.
717750 */
718751 public function backfill_postmeta ( &$ order ) {
719752 $ data = $ this ->get_order_data_from_table ( $ order );
@@ -732,9 +765,7 @@ public function backfill_postmeta( &$order ) {
732765 /**
733766 * Query for Orders matching specific criteria.
734767 *
735- * @since 3.1.0
736- *
737- * @param array $query_vars query vars from a WC_Order_Query
768+ * @param array $query_vars Query arguments from a WC_Order_Query.
738769 *
739770 * @return array|object
740771 */
0 commit comments