Wishlist - How to display for user the total price of all product in list
If you want to display for user the total price of all product in list you shoud add the following code in funtions.php of your theme:
if ( ! function_exists( 'yith_wcwl_items_total' ) ) {
function yith_wcwl_items_total( $args ) {
/**
* @var $wishlist YITH_WCWL_Wishlist
*/
$wishlist = isset( $args['wishlist'] ) ? $args['wishlist'] : false;
if ( ! $wishlist || ! $wishlist instanceof YITH_WCWL_Wishlist ) {
return;
}
$total = 0;
if ( $wishlist->has_items() ) {
foreach ( $wishlist->get_items() as $item ) {
$total += $item->get_product_price();
}
}
if ( $total ) {
echo '<p><b>Total:</b> ' . wc_price( $total ) . '</p>';
}
}
}
add_action( 'yith_wcwl_wishlist_after_wishlist_content', 'yith_wcwl_items_total', 5, 1 );
This should be the final result: