• Resolved kvotsapp

    (@kvotsapp)


    i want to add product sku to actual product title. for example, if product name is “Dress design” & product sku is “2790” the new product title should be “Dress design – 2790”.

    i had tried following code. but this code replaces the product title by the product SKU on single product pages.

    
    add_action( 'woocommerce_single_product_summary', 'replace_product_title_by_product_sku', 4 );
    function replace_product_title_by_product_sku() {
        global $product;
    
        if ( $product->get_sku() ) {
            remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
            add_action( 'woocommerce_single_product_summary', 'display_product_sku_as_title', 5 );
        }
    }
    
    function display_product_sku_as_title() {
        global $product;
    
        echo '<h1 class="product_title entry-title">' . esc_html( $product->get_sku() ) . '</h1>';
    }

    but i want “product title + Sku”, & i want to display it on single product page & shop page & checkout page & cart page.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add Product SKU to Product Title in Woocommerce single product page & shop page’ is closed to new replies.