-
AuthorPosts
-
December 23, 2024 at 11:38 pm #1474208
Hi ,
I need to put my EAN and SKU field like this .
EAN : xxx
SKU : rrrrrrrPut them in strong text for all product.
Best regards,
December 24, 2024 at 11:38 pm #1474243Hi ,
Please some one. could help me ?
Best regards,
December 26, 2024 at 11:06 am #1474262Hi!
Thank you for the inquiry.
The products should have an SKU field by default. How did you add the EAN? Please check this link: https://yoast.com/help/how-to-add-sku-to-products-in-woocommerce/
If the EAN was added as a custom field, you can try this hook in the functions.php file:
add_action( 'woocommerce_after_shop_loop_item_title', 'ava_display_sku_and_ean', 15 ); function ava_display_sku_and_ean() { global $product; $sku = $product->get_sku(); $ean = get_post_meta( $product->get_id(), 'ean', true ); if ( $ean || $sku ) { echo '<div class="product-meta">'; if ( $ean ) { echo '<p><strong>EAN:</strong> ' . esc_html( $ean ) . '</p>'; } if ( $sku ) { echo '<p><strong>SKU:</strong> ' . esc_html( $sku ) . '</p>'; } echo '</div>'; } }
Best regards,
IsmaelDecember 26, 2024 at 11:15 am #1474266Hi Ismael ,
thanks for your support.
When I put the EAN in yoast , it did not display (it did not work). I installed an application that display the EAN.I don’t know why it did appear when I used yoast to write the EAN.
Best regards,
December 26, 2024 at 10:18 pm #1474275Hi,
Thanks for the update. Please let us know if you should need any further help on the topic, or if we can close it.
Best regards,
RikardDecember 26, 2024 at 10:35 pm #1474279Hi Rikard,
My request was about EAN number Like EAN: 12345666 the value 12345666 should be zoomed or in strong test.
Example:
EAN: 0810979018100 SKU: MA‑INJ‑4-EUBest regards,
December 27, 2024 at 8:04 am #1474285Hi,
Thank you for the update.
How did you add the EAN using Yoast? Did you try the ava_display_sku_and_ean function mentioned above? There is no default field for EAN, only the SKU field, so you may need to add the EAN as a custom field.
Best regards,
IsmaelDecember 27, 2024 at 11:10 am #1474290Hi Ismael,
To add EAN I used the API called “EAN for WooCommerce”. Yes I did with ava_display_sku_and_ean but nothing change.
How to add custom field please ?
Best regards,
December 30, 2024 at 6:22 am #1474389Hi,
Thank you for the info.
Would you mind providing a link to the plugin page? You may need to contact the plugin author for additional assistance on displaying the EAN info on the frontend. For more details on adding custom fields to products, please refer to this documentation: https://woocommerce.com/document/custom-product-fields/
Best regards,
IsmaelDecember 30, 2024 at 11:03 am #1474397Hi Ismael ,
I followed the step of added custom product fields https://woocommerce.com/document/custom-product-fields/ and display it with https://developer.woocommerce.com/docs/displaying-custom-fields-in-your-theme-or-site/?_gl=1*1hrrkjn*_ga*NjI0MTU1ODk1LjE3MzU1NTE0OTg.*_ga_98K30SHWB2*MTczNTU1MTQ5Ny4xLjEuMTczNTU1MTUyMC4wLjAuMA..
Nothing appear on my web page ?
I used this product to make a test
Could you check it please ?
December 31, 2024 at 5:51 am #1474422Hi,
Thank you for the update.
The SKU and EAN seem to be displaying correctly now — located below the Add to Cart button. Did you figure it out?
<div class="product_meta"> <span class="sku_wrapper ean_wrapper">EAN: <span class="ean">0889728068338</span></span> <span class="sku_wrapper">SKU: <span class="sku">CP-6851-3PCC-K9=</span></span> <span class="posted_in">Category: <a href="https://www.nodem-it.com/product-category/reseau/cisco-meraki/cisco-telephonie/" rel="tag">Cisco Téléphonie</a></span> <span class="tagged_as">Tag: <a href="https://www.nodem-it.com/product-tag/cisco-telephone/" rel="tag">Cisco telephone</a></span></div>
Best regards,
IsmaelDecember 31, 2024 at 12:20 pm #1474433Hi Ismael ,
No . The EAN and SKU located below the add to Cart button are the old one. I created a custom field caller EAN1 with the value 12340965433 .
Nothing appear with the new value .
Please could you check ?
January 1, 2025 at 12:21 pm #1474449Hi,
Looks like you’re using the Advanced Layout Builder (ALB) for the products. Please note that the template hook (ava_display_sku_and_ean) above will not work if ALB is active. To use it, you’ll need to switch to the default editor.
You can also create a custom shortcode:
function ava_shortcode_sku_and_ean( $atts ) { $atts = shortcode_atts( array( 'id' => '', ), $atts ); $product_id = !empty( $atts['id'] ) ? intval( $atts['id'] ) : get_the_ID(); if ( !$product_id ) { return ''; } $product = wc_get_product( $product_id ); if ( !$product ) { return ''; } $sku = $product->get_sku(); $ean = get_post_meta( $product->get_id(), 'EAN1', true ); $output = ''; if ( $ean || $sku ) { $output .= '<div class="product-meta">'; if ( $ean ) { $output .= '<p><strong>EAN:</strong> ' . esc_html( $ean ) . '</p>'; } if ( $sku ) { $output .= '<p><strong>SKU:</strong> ' . esc_html( $sku ) . '</p>'; } $output .= '</div>'; } return $output; } add_shortcode( 'av_sku_ean', 'ava_shortcode_sku_and_ean' );
In a Text or Code Block, insert this shortcode:
[av_sku_ean]
Best regards,
IsmaelJanuary 1, 2025 at 2:07 pm #1474454Hi Ismael,
Where should I insert the above custom shortcode ?
Best regards,
AubinJanuary 2, 2025 at 5:17 am #1474464Hi,
You have to insert the custom shortcode ava_shortcode_sku_and_ean in the functions.php file and the actual shortcode in a Text or Code Block element.
Best regards,
IsmaelJanuary 3, 2025 at 2:10 am #1474499Hi Ismael ,
Thanks for your support.
I got this
EAN: 12340965433SKU: CP-6851-3PCC-K9=
Please how to display them in online ?Like this
EAN: 12340965433 SKU: CP-6851-3PCC-K9=Best regards,
AubinJanuary 3, 2025 at 6:12 am #1474509Hi,
Try to update the ava_shortcode_sku_and_ean function with this:
function ava_shortcode_sku_and_ean( $atts ) { $atts = shortcode_atts( array( 'id' => '', ), $atts ); $product_id = !empty( $atts['id'] ) ? intval( $atts['id'] ) : get_the_ID(); if ( !$product_id ) { return ''; } $product = wc_get_product( $product_id ); if ( !$product ) { return ''; } $sku = $product->get_sku(); $ean = get_post_meta( $product->get_id(), 'EAN1', true ); $output = ''; if ( $ean || $sku ) { $output .= '<div class="av-product-meta av-product-meta-sku av-product-meta-ean">'; if ( $ean ) { $output .= '<span><strong>EAN:</strong> ' . esc_html( $ean ) . '</span>'; } if ( $sku ) { $output .= '<span><strong>SKU:</strong> ' . esc_html( $sku ) . '</span>'; } $output .= '</div>'; } return $output; } add_shortcode( 'av_sku_ean', 'ava_shortcode_sku_and_ean' );
If you need to apply more space between them, add this css code:
.av-product-meta-sku.av-product-meta-ean span { margin-right: 20px; }
Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.