I want to replace text in product short description in product page and in shop archive page with different view with custom text and information with shipping class, but not slug, I want to display name of the shipping class
I found some code on this forum, but it doesn't work on shop archive page, and it show slug of shipping class, but not the name
add_action( 'woocommerce_single_product_summary', 'custom_single_product_summary', 2 );
function custom_single_product_summary(){
global $product;
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
add_action( 'woocommerce_single_product_summary', 'custom_single_excerpt', 20 );
}
function custom_single_excerpt(){
global $post, $product;
$short_description = apply_filters( 'woocommerce_short_description', $post->post_excerpt );
if ( ! $short_description )
return;
// The custom text
$custom_text = ' <strong>Forma de pagamento</strong>
<ul class="fancy-bullet-points red">
<li>Boleto Bancario</li>
<li>Cartao de credito em ate 12 parcelas</li>
<li>Cartao de debito</li>
<li>PayPal</li>
</ul>';
$clase=$product->get_shipping_class();
?>
<div class="woocommerce-product-details__short-description">
<?php echo $short_description . $custom_text; // WPCS: XSS ok. ?>
<?php echo $short_description . $clase; // WPCS: XSS ok. ?>
</div>
<?php
}
add_filter( 'woocommerce_short_description', 'single_product_short_description', 10, 1 );
function single_product_short_description( $post_excerpt ){
global $product;
$product_id = method_exists( $product, 'get_id' ) ? $product->get_id() : $product->id;
if ( is_single( $product_id ) )
$post_excerpt = '<p class="some-class">' . __( "", "woocommerce" ) . '</p>';
return $post_excerpt;
}
I think this two code can be compiled