从产品WooCommerce发货类别ID

问题描述

我想显示产品运输类别标签(字符)而不是其ID(编号)。我的意思是,如下图所示,我想将0更改为Free或flat-rage等。如何在下面的相关代码下进行编辑?有人可以帮助我吗? enter image description here

相关代码是

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>';
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)