wc_format_list_of_items( array $items )
Comma separate a list of item names, and replace final comma with ‘and’.
Description Description
Parameters Parameters
- $items
-
(Required) Cart items.
Return Return
(string)
Source Source
File: includes/wc-cart-functions.php
function wc_format_list_of_items( $items ) { $item_string = ''; foreach ( $items as $key => $item ) { $item_string .= $item; if ( count( $items ) === $key + 2 ) { $item_string .= ' ' . __( 'and', 'woocommerce' ) . ' '; } elseif ( count( $items ) !== $key + 1 ) { $item_string .= ', '; } } return $item_string; }