I want to display product shipping class label(character) instead its id(number). I mean, as seen in the image below, I wnat to chage 0 to Free or flat-rage etc. How or where do I have to edit under the relevant code below? Can I be helped by anybody professional? enter image description here
The relevant code is
if ($sale_carousel_items_content) {
$carousel_items .= '<ul class="products" style="background:yellow; border:none; padding-left:50px;">';
enter code here
foreach ($sale_carousel_items_content as $item) {
if ( isset( $item['product_id'] ) ) {
$product = new WC_Product( $item['product_id'] );
if ( $product->is_on_sale() ) {
$countdown_container_id = uniqid('countdown',false);
$target = explode("-", $item['target_date']);
$carousel_items .= '<li class="row"><div class="img-wrapper col-xs-12 col-md-6">';
$carousel_items .= '<a href="'.esc_url($product->get_permalink()).'" class="link-to-product">'.$product->get_image( 'shop_catalog' ).'</a>';
$carousel_items .= '<h6>'.$product->get_shipping_class_id().'</h6></div>';
$carousel_items .= '<div class="counter-wrapper col-xs-12 col-md-6"><h6>'.$product->get_name().'</h6>';
// Short Description
$carousel_items .= '<div class="woocommerce-product-details__short-description"><h6>'.$product->get_short_description().'</h6>';
// Sale value in percents
$percentage = round( ( ( $product->get_regular_price() - $product->get_sale_price() ) / $product->get_regular_price() ) * 100 );
$carousel_items .= '<span class="sale-value" style="background:orange;"><font style="font-size:15px;">특판가 </font>-'.$percentage.'% </span>';
$carousel_items .= '<div><h5></h5>';
$carousel_items .= '<div class="price-wrapper"><h5>남은수량: '.$product->get_stock_quantity().'개</h5>';
//$carousel_items .= '<div class="countdown-wrapper">';
if ( $item['pre_countdown_text'] && $item['pre_countdown_text'] != '' ) {
$carousel_items .= '<p>'.esc_attr($item['pre_countdown_text']).'</p>';
}
//$carousel_items .= '<div id="'.$countdown_container_id.'"></div></div>';
//$carousel_items .= '<div class="price-wrapper">'.do_shortcode('[add_to_cart id="'.$item['product_id'].'"]').'</div>';
if ( $target && $target!='' ) {
$carousel_items .='
<script type="text/javascript">
(function($) {
$(document).ready(function() {
var container = $("#'.$countdown_container_id.'");
var newDate = new Date('.$target[0].', '.$target[1].'-1, '.$target[2].');
container.countdown({
until: newDate,
});
});
})(jQuery);
</script>';
}
$carousel_items .= '</div></li>';
}
}
}
$carousel_items .= '</ul>';
}
Final update
Use the following to get the term name (label name) from a product shipping class Id:
So in your code replace the line
by the following code block:
Tested and works.