5 Easy Steps to Show SKU on WooCommerce Product Page in Divi

Show SKU on WooCommerce Product Page Divi

Unveiling the enigma of displaying SKUs on WooCommerce product pages in Divi, we embark on an illuminating journey that can empower you to seamlessly showcase important product identifiers to your discerning clientele. By using this indispensable characteristic, you not solely improve the person expertise but in addition streamline your stock administration processes. Dive into the depths of this complete information and uncover the secrets and techniques to unlocking the complete potential of SKU visibility, propelling your WooCommerce retailer in direction of unparalleled heights.

To begin our odyssey, allow us to enterprise into the realm of the Divi Theme Customizer, a treasure trove of customization choices. Navigate to the hallowed halls of the “Product” tab, the place a plethora of settings await your command. Amidst the myriad of selections, search out the elusive “Superior” tab, a gateway to unlocking hidden powers inside your product pages. Therein lies the important thing to unleashing the SKU’s presence, granting you the power to effortlessly show this very important piece of knowledge.

But, our quest doesn’t finish right here. To additional refine the SKU’s presentation, we will delve into the realm of CSS (Cascading Fashion Sheets), the intricate language that governs the visible aesthetics of your web site. With a deft contact, compose a customized CSS snippet that can imbue the SKU with the specified styling, be it daring textual content, vibrant colours, or a refined but hanging look. Implement this snippet inside the Divi Theme Choices or straight modify your little one theme’s model.css file, granting you unparalleled management over the SKU’s visible attraction. As you weave your CSS magic, keep in mind to take care of a eager eye for element, making certain that the SKU’s visibility and readability harmoniously complement the general design of your product pages.

Modifying the WooCommerce Product Template

To entry the WooCommerce product template, navigate to “Look” > “Theme Editor” in your WordPress dashboard. Within the right-hand panel, find the “woocommerce” folder and broaden it. You will notice a listing of template recordsdata. To edit the product template, choose “single-product.php”.

3. Modifying the Template Code

Find the part of the template code the place the product data is displayed. That is sometimes inside a loop, and the product particulars are accessed utilizing variables comparable to “$product” or “$publish”. To show the SKU, you should utilize the next code snippet:

<?php echo $product->get_sku(); ?>

This code retrieves the SKU from the product object and outputs it on the web page. You may as well customise the show model by including HTML tags across the code, for instance:

<p>SKU: <?php echo $product->get_sku(); ?></p>

It will show the SKU inside a paragraph tag, with the textual content “SKU:” previous it.

Extra Customization Choices

You possibly can additional customise the show of the SKU by modifying the template code and including extra performance. For instance, you’ll be able to:

  • Add a label to the SKU discipline
  • Show the SKU in a particular location on the product web page
  • Conditionally show the SKU primarily based on sure standards

These customizations require information of HTML and PHP, however they supply loads of flexibility in the way you current the SKU to your prospects.

Fashion Code
SKU Label <p><sturdy>SKU:</sturdy> <?php echo $product->get_sku(); ?></p>
Particular Location <div id="product-sku"><?php echo $product->get_sku(); ?></div>
Conditional Show <?php if ($product->is_in_stock()) : ?><p>SKU: <?php echo $product->get_sku(); ?></p><?php endif; ?>

Utilizing a Customized Operate

This technique entails making a customized perform that can retrieve and show the SKU on the product web page. This is an in depth information on the way to do it:

1. Create a Baby Theme

Create a toddler theme on your Divi theme to keep away from modifying the unique Divi recordsdata. Seek advice from the Divi documentation for directions on creating a toddler theme.

2. Add the Customized Operate to the Features File

Open the capabilities.php file in your little one theme and add the next perform:


// Show SKU on product web page
add_action( 'woocommerce_single_product_summary', 'display_product_sku', 20 );
perform display_product_sku() {
international $product;
$sku = $product->get_sku();
if ( $sku ) {
echo '

SKU: ' . $sku . '

';
}
}

3. Fashion the SKU Show

To model the SKU show, add the next CSS to your little one theme’s model.css file or by the Customized CSS choice within the Divi Theme Customizer:


.sku {
font-size: 14px;
shade: #666;
}

4. Customise the SKU Show Place

By default, the SKU will probably be displayed after the product title. To vary the place, find the woocommerce_single_product_summary hook motion within the capabilities.php file and modify the precedence parameter within the add_action perform as follows:

Precedence Place
10 Earlier than the product title
20 After the product title (default)
30 After the product description
40 After the product value

For instance, to show the SKU earlier than the product title, change the precedence to 10:


add_action( 'woocommerce_single_product_summary', 'display_product_sku', 10 );

The right way to Present SKU on WooCommerce Product Web page Divi

To show the SKU (Inventory Retaining Unit) on the WooCommerce product web page utilizing Divi, observe these steps:

  1. Within the WordPress dashboard, navigate to Look > Customise.

  2. Click on on the “WooCommerce” tab.

  3. Develop the “Product Web page” part.

  4. Below the “Product Meta” tab, allow the “SKU” choice.

  5. Click on on the “Save & Publish” button.

After getting accomplished these steps, the SKU will probably be seen on the product web page under the product title.

Folks Additionally Ask About The right way to Present SKU on WooCommerce Product Web page Divi

The right way to show the SKU on the product archive web page?

To show the SKU on the product archive web page, you should utilize a WooCommerce hook. Add the next code to your theme’s capabilities.php file:


add_action( 'woocommerce_after_shop_loop_item_title', 'my_product_sku', 10 );

perform my_product_sku() {
international $product;
echo '' . $product->get_sku() . '';
}

The right way to change the SKU place on the product web page?

You should utilize CSS to alter the place of the SKU on the product web page. Add the next code to your theme’s customized CSS:


.sku {
place: absolute;
high: 10px;
proper: 10px;
}

The right way to cover the SKU on sure merchandise?

You should utilize conditional statements to cover the SKU on sure merchandise. For instance, to cover the SKU on merchandise within the “Electronics” class, you should utilize the next code:


add_filter( 'woocommerce_product_get_sku', 'my_hide_sku', 10, 2 );

perform my_hide_sku( $sku, $product ) {
if ( has_term( 'electronics', 'product_cat', $product->get_id() ) ) {
$sku = '';
}
return $sku;
}