Display shipping class in single product page woocommerce

Question

I need to show shipping class in single product page. I’ve used this script that I found in this site:

add_action('woocommerce_single_product_summary', 'display_specific_shipping_class', 15 );
function display_specific_shipping_class(){
    global $product;

    // HERE define your targeted shipping class name
    $defined_shipping_class = "Spedito in 1 o 2 giorni lavorativi. Se ci fossero problemi con la disponibilità verrai avvisato quanto prima";

    // Get the product shipping class WP_Term Object
    $term = get_term_by( 'slug', $product->get_shipping_class(), 'product_shipping_class' );

    if( is_a($term, 'WP_Term') && $term->name == $defined_shipping_class ){
        echo '<p class="product-shipping-class">' . $term->name . '</p>';
    }
}

I have 3 shipping class. How can I indicate in this script the other 2 shipping class?

The other class I have are “Spedito in 5 o 7 giorni lavorativi. Se ci fossero problemi con la disponibilità verrai avvisato quanto prima” and the last class “NON ordinabile”

0
Fabrizio 4 years 2020-03-05T03:50:50-05:00 0 Answers 98 views 0

Leave an answer

Browse
Browse