Comment afficher le SKU du produit sur la page du produit
2 réponses
- votes
-
- 2016-03-01
Ajoutez ceci à votrefunctions.php
add_action( 'woocommerce_single_product_summary', 'dev_designs_show_sku', 5 ); function dev_designs_show_sku(){ global $product; echo 'SKU: ' . $product->get_sku(); }
Cela affichera le SKU duproduit sous letitre duproduit.Voir l'image ci-dessous.Le SKU duproduitest VERTEX-SLVR.
Add this to your functions.php
add_action( 'woocommerce_single_product_summary', 'dev_designs_show_sku', 5 ); function dev_designs_show_sku(){ global $product; echo 'SKU: ' . $product->get_sku(); }
This will output the product SKU below the product title. See image below. The product SKU is VERTEX-SLVR.
-
ENFIN!!!JE VOUS REMERCIE!!!! Avez-vous desidées sur lafaçon d'ajouter lemot "SKU:" devant lenuméro de SKU?AT LAST!!! THANK YOU!!!! Any ideas on how to add the word "SKU:" in front of the SKU number?
- 0
- 2016-03-01
- CreationP
-
NP,j'aimis àjour le code d'originepour ajouter «SKU:» avant le SKU duproduit.Pouvez-vousmarquerma réponse comme acceptée?Je vous remercie!NP, I updated the original code to add 'SKU:' before the Product SKU. Could you mark my answer as accepted? Thank you!
- 0
- 2016-03-01
- Joe Dooley
-
Bien sûr.Mercibeaucoup!!!M'a sauvé des heures d'ennuis !!Of course. Thank you very much!!! Saved me hours of trouble!!
- 0
- 2016-03-01
- CreationP
-
- 2016-08-24
Ajoutez le code suivant dans le
functions.php
de votrethème (enfant):function visupporti_get_product_quantity( $atts ) { global $product; $atts = shortcode_atts( array( 'id' => ”, ), $atts ); // If no id, we’re probably on a product page already if ( empty( $atts['id'] ) ) { $sku = $product->get_stock_quantity( ); } else { //get which product from ID we should display a SKU for $product = wc_get_product( $atts['id'] ); $sku = $product->get_stock_quantity( ); } ob_start(); // Only echo if there is a SKU if ( !empty( $sku ) ) { echo $sku; } return ob_get_clean(); } add_shortcode( 'wc_sku', 'visupporti_get_product_quantity' );
En savoirplus sur comment afficher le SKU sur le site .
Add the following code in your (child) theme's
functions.php
:function visupporti_get_product_quantity( $atts ) { global $product; $atts = shortcode_atts( array( 'id' => ”, ), $atts ); // If no id, we’re probably on a product page already if ( empty( $atts['id'] ) ) { $sku = $product->get_stock_quantity( ); } else { //get which product from ID we should display a SKU for $product = wc_get_product( $atts['id'] ); $sku = $product->get_stock_quantity( ); } ob_start(); // Only echo if there is a SKU if ( !empty( $sku ) ) { echo $sku; } return ob_get_clean(); } add_shortcode( 'wc_sku', 'visupporti_get_product_quantity' );
See more details on how to display SKU on the site.
-
Queltype d'éditeur avez-vous utilisépourinsérer ces citations?Ils doivent être remplacéspar de vraisguillemets simplesWhat kind of editor did you use to insert those quotes? They have to be replaced with real single ' quotes
- 0
- 2019-02-13
- Svetoslav Marinov
Je crée un site Webet il semble que la référence duproduit soitmasquée sur lapage duproduit. J'aitrouvé comment l'ajouter à lapage du catalogue (boutique)maisj'en aibesoinpour l'afficher dans lapage duproduit.
Jusqu'àprésent,en modifiant le single-product.php,j'ai réussi à l'ajouteren fin depage (ce quenousne voulonspas) ou avant letitreen haut àgauche de lapage (ce quenousne faisonspasnonplus voulez).
Jen'aitrouvé aucunmoyen de l'ajouter avant leprixet sous letitre duproduit.
Le code du single-product.php desthèmes:
J'ai ajouté la dernière ligne.
Cependant,sur lethème/woocommerce/single-product/meta.phpje peux voir que le sku devrait être affiché,ce quin'estpas:
Avez-vous desidées sur lamanière d'afficher lenuméro SKU duproduit dans lapage duproduit?
Merci d'avance.