Viewing 17 posts - 1 through 17 (of 17 total)
  • Author
    Posts
  • #1474208

    Hi ,

    I need to put my EAN and SKU field like this .

    EAN : xxx
    SKU : rrrrrrr

    Put them in strong text for all product.

    Best regards,

    #1474243

    Hi ,

    Please some one. could help me ?

    Best regards,

    #1474262

    Hi!

    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,
    Ismael

    #1474266

    Hi 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,

    #1474275

    Hi,

    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,
    Rikard

    #1474279

    Hi 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-EU

    Best regards,

    #1474285

    Hi,

    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,
    Ismael

    #1474290

    Hi 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,

    #1474389

    Hi,

    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,
    Ismael

    #1474397

    Hi 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 ?

    #1474422

    Hi,

    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,
    Ismael

    #1474433

    Hi 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 ?

    #1474449

    Hi,

    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,
    Ismael

    #1474454

    Hi Ismael,

    Where should I insert the above custom shortcode ?

    Best regards,
    Aubin

    #1474464

    Hi,

    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,
    Ismael

    #1474499

    Hi Ismael ,

    Thanks for your support.

    I got this
    EAN: 12340965433

    SKU: CP-6851-3PCC-K9=
    Please how to display them in online ?

    Like this
    EAN: 12340965433 SKU: CP-6851-3PCC-K9=

    Best regards,
    Aubin

    #1474509

    Hi,

    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

Viewing 17 posts - 1 through 17 (of 17 total)
  • You must be logged in to reply to this topic.