Okay
  Public Ticket #1085825
Can't display SKU
Closed

Comments

  •  2
    Andrzej started the conversation

    Guys,

    I want to show (I need to, to be honnest) SKU number at every single product page. I can't find this option. I hope you might help.

  •  143
    Nico replied

    Hi there,

    There isn't a default option for that and you will have to do it as a customization, maybe these articles can help you:

    http://wordpress.stackexchange.com/questions/219410/how-to-show-product-sku-on-product-page

    https://www.skyverge.com/blog/output-woocommerce-sku/

  • Rob replied

    I managed to show this on Ocin theme by altering the following file;

    ../ocin/inc/theme-functions/woo commerce_support.php

    from line 468.

    /**
     * HTML wrap end for Single page summary
     */
    function ocin_single_product_wrap_end_summary(){
    global $product;

    if( $product->get_sku() ){
    ?>
    <p class="ocin_sku" style="display: none;"><?php echo esc_html__( 'SKU:', 'ocin' ) . ' ' . esc_html( $product->get_sku() ); ?></p>
    <?php }  ?>
    <div class="variations_button_entry">
                <?php woocommerce_template_single_add_to_cart(); ?>

    <!-- /ADDED BY RK -->

    <div class="product_meta">

    <?php do_action( 'woocommerce_product_meta_start' ); ?>

    <?php if ( wc_product_sku_enabled() && ( $product->get_sku() || $product->is_type( 'variable' ) ) ) : ?>

    <span class="sku_wrapper"><?php esc_html_e( 'SKU:', 'woocommerce' ); ?> <span class="sku"><?php echo ( $sku = $product->get_sku() ) ? $sku : esc_html__( 'N/A', 'woocommerce' ); ?></span></span>

    <?php endif; ?>

    <?php do_action( 'woocommerce_product_meta_end' ); ?>

    </div>

    <!-- /ADDED BY RK -->

    Added style to -->> class="ocin_sku" style="display: none;"

    Then added everything between my <!-- /ADDED BY RK --> tags.

    Seems to work ok.

    Trying to work out how to show the SKU in the cart now....  there goes another 5 hours of my life....

    Hope this helps you out!

    if you work out how to get the variant SKU to show in the cart and checkout area let me know!!!!!

    regards,

    Rob

    Attached files:  Screen Shot 2017-05-18 at 23.53.47.png

  • Rob replied

    ../wp-content/themes/ocin/woocommerce/cart/cart.php

    Show variant SKU in the cart with this code at line 62

    <div class="product_text">
    <div class="product_text_left">
                           <h3><?php
    if ( ! $product_permalink ) {
    echo apply_filters( 'woocommerce_cart_item_name', $_product->get_title(), $cart_item, $cart_item_key ) . ' ';
    } else {
    echo apply_filters( 'woocommerce_cart_item_name', sprintf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $_product->get_title() ), $cart_item, $cart_item_key );
    }
    ?></h3>

    <!-- ADDED RK -->
    <?php echo '<p>'.$_product->get_sku().'</p>'; ?>
    <!-- ADDED RK -->

    I only added the code between my <!-- /ADDED BY RK --> tags.

    Will need css styling though

    Regards,

    Rob

  • Rob replied

    works in mini-cart.php as well.

    ../wp-content/themes/ocin/woocommerce/cart/mini-cart.php

    Will need css styling though

    Regards,

    Rob

    Attached files:  Screen Shot 2017-05-19 at 00.44.59.png

  • Rob replied

    I will give the wishlist and other pages a crack tomorrow as it is 1am here now in England.

    Regards,

    Rob.

  • Rob replied

    hero colour change is done in this file:

    ../wp-content/themes/ocin/inc/scripts

    as the front end "customise" page doesn't always pick every link up.

  • Rob replied

    ..htdocs/wp-content/themes/ocin/inc/scripts/styles.php