Сейчас оно выводится как Название товара,Цвет,размер в строчку.
Нужно, чтобы было так:
Название
Цвет:
Размер:
Нашел такое решение для КОРЗИНЫ:
function custom_product_variation_title($should_include_attributes, $product){
$should_include_attributes = false;
return $should_include_attributes;
}
add_filter( 'woocommerce_product_variation_title_include_attributes', 'custom_product_variation_title', 10, 2 );
Но для цикла orders оно не применяется. Вот мой сам кастомный цикл:
<section class="order">
<?php
$orders = wc_get_orders( array(
'numberposts' => -1,
'orderby' => 'date',
'order' => 'DESC',
'customer_id' => get_current_user_id(),
'status' => array('completed'),
) );
//* Loop through each WC_Order object
foreach( $orders as $order ){?>
<div class="order-wrapper product d-flex col-12">
<?php
$order_data = $order->get_data(); // The Order data
$order_id = $order_data['id'];
$order_currency = $order_data['currency'];
$order_status = $order_data['status'];
?>
<div class="order-number">#<?php echo $order_id;?></div>
<div class="order-inner">
<div class="order-inner-top">
<?php
foreach ($order->get_items() as $key => $lineItem) {
$product_id = $lineItem['product_id'];
$product = wc_get_product( $product_id );
$item_meta_data = $lineItem->get_meta_data();
$colormeta = $lineItem->get_meta( 'pa_color', true );
$sizemeta = $lineItem->get_meta( 'pa_size', true ); ?>
<div class="order-inner-top-inner">
<div class="order-slider-inner">
<div class="order-inner-left">
<div class="order-image">
<?php echo $product->get_image(['322', '304']);?>
</div>
</div>
<div class="order-inner-right">
<div class="order-info-item order-info-item-name">
<?php echo $lineItem['name'] ?>
</div>
<div class="order-info-item order-info-item ">
<span class="order-price"><?php echo $lineItem['total'] . $order_currency?></span>
</div>
<div class="order-item-quantity"><?php esc_html_e( 'Quantity', 'woocommerce' )?>: <?php echo $lineItem['qty']?></div>
</div>
</div>
</div>
<?php } ?>
</div>
<div class="order-inner-bottom">
<div class="d-flex justify-content-center">
<button class="order-total"><?php echo get_theme_mod('orders_total_button');?></button>
</div>
<div class="totals-toggle">
<div class="order-info-item bottom"> <span> <?php esc_html_e( 'Price', 'woocommerce' )?>:</span><span class="order-total-price"> <?php echo $order->get_total() . ' ' . $order_currency; ?></span></div>
<div class="order-info-item bottom"> <span> <?php esc_html_e( 'Quantity', 'woocommerce' )?>:</span> <?php echo $order->get_item_count(); ?></div>
<div class="order-info-item bottom"> <span><?php esc_html_e( 'Status', 'woocommerce' )?>:</span> <?php
if( 'completed'== $order->get_status() ) {
echo _x( 'Completed', 'Order status', 'woocommerce' );
} ?></div>
<div class="order-info-item bottom"> <span><?php esc_html_e( 'Order Date', 'woocommerce' )?></span> <?php
if( $date_created = $order->get_date_created() ){
// Display the localized formatted date
$formated_date_created = $date_created->date_i18n('d.m.Y ');
echo $formated_date_created;
}
?></div>
<div class="order-info-item bottom"> <span><?php echo get_theme_mod('delivery_date_text')?>: </span>
<?php
// The orders date
$date_created = $order->get_date_created();
$date_created = $date_created->date('d.m.Y');
// The order date + 5 days
$delivery_date = date_i18n( 'd.m.Y', strtotime( $date_created . ' +21 days' ));
echo $delivery_date;
?>
</div>
</div>
</div>
</div>
</div>
<?php }?>
</section>
Как отформатировать <?php echo $lineItem['name'] ?> в нужный вид?