Need Variation SKU to be Product EAN + variation ID

Top WooCommerce & WordPress Plugins Forums EAN and Barcodes for WooCommerce Need Variation SKU to be Product EAN + variation ID

Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #127427
    Nanette
    Participant

    Hi! I have tried multiple options to accomplish what I need, but have not been successful.  Currently, my variable products produce a SKU that is the EAN for the variation. However, I need for the variation to be the main product group EAN+variation ID.  For example:

    Main Product:  XYZ Body Scrub (WooCommerce ID: 1186; EAN – 067000011894)

    • Variation 1:  Scent A (WooCommerce ID: 3425; EAN:  067000034251)
      • SKU is the EAN of this variation
    • Variation 2:  Scent B (WooCommerce ID: 3424; EAN:  067000034244)
      • SKU is the EAN of this variation

    What I need the variation SKUs to reflect:

    • Variation 1:  067000011894_3425 (Main Product EAN_Variation WC ID)
    • Variation 2:  067000011894_3424 (Main Product EAN_Variation WC ID)

    What setting am I missing to correct this??

    Thanks so much!

    #127548
    Moshtafizur
    Moderator
    Plugin Support

    Hi  Nanette,

    I am really sorry to know you are experiencing problems.

    I have escalated this with our development team. They will get back to you as soon as they can.

    Kind regards,

    Moshtafizur

    #127575
    Tom Anbinder
    Moderator
    Plugin Support

    Hi, Nanette,

    I believe we can solve your task with this PHP snippet:

    add_filter( 'woocommerce_product_variation_get_sku', function ( $sku, $variation ) {
        $parent = wc_get_product( $variation->get_parent_id() );
        return $parent->get_meta( '_alg_ean' ) . '_' . $variation->get_id();
    }, 10, 2 );

    Please give it a try and let me know what you think.

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