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 may empower you to seamlessly showcase important product identifiers to your discerning clientele. By using this indispensable characteristic, you not solely improve the consumer 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 total potential of SKU visibility, propelling your WooCommerce retailer in the 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, hunt down 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 important piece of data.

But, our quest doesn’t finish right here. To additional refine the SKU’s presentation, we will delve into the realm of CSS (Cascading Model Sheets), the intricate language that governs the visible aesthetics of your web site. With a deft contact, compose a customized CSS snippet that may imbue the SKU with the specified styling, be it daring textual content, vibrant colours, or a delicate but putting look. Implement this snippet inside the Divi Theme Choices or instantly modify your baby theme’s type.css file, granting you unparalleled management over the SKU’s visible attraction. As you weave your CSS magic, keep in mind to keep up 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 increase it. You will note 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 info is displayed. That is usually inside a loop, and the product particulars are accessed utilizing variables equivalent to “$product” or “$publish”. To show the SKU, you should use 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 type by including HTML tags across the code, for instance:

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

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

Extra Customization Choices

You may 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 selected location on the product web page
  • Conditionally show the SKU primarily based on sure standards

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

Model 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 methodology includes making a customized perform that may retrieve and show the SKU on the product web page. Here is an in depth information on easy methods to do it:

1. Create a Little one Theme

Create a toddler theme in 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 features.php file in your baby 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() {
world $product;
$sku = $product->get_sku();
if ( $sku ) {
echo '

SKU: ' . $sku . '

';
}
}

3. Model the SKU Show

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


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

4. Customise the SKU Show Place

By default, the SKU will probably be displayed after the product title. To alter the place, find the woocommerce_single_product_summary hook motion within the features.php file and alter 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 );

Methods to Present SKU on WooCommerce Product Web page Divi

To show the SKU (Inventory Maintaining 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. Increase the “Product Web page” part.

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

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

After you have accomplished these steps, the SKU will probably be seen on the product web page beneath the product title.

Individuals Additionally Ask About Methods to Present SKU on WooCommerce Product Web page Divi

Methods to show the SKU on the product archive web page?

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


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

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

Methods to change the SKU place on the product web page?

You need to use 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;
prime: 10px;
proper: 10px;
}

Methods to conceal the SKU on sure merchandise?

You need to use conditional statements to cover the SKU on sure merchandise. For instance, to cover the SKU on merchandise within the “Electronics” class, you should use 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;
}