Top WooCommerce & WordPress Plugins › Forums › EAN and Barcodes for WooCommerce › Need Variation SKU to be Product EAN + variation ID
- Support forum for the EAN and Barcodes for WooCommerce.
Tagged: Variation SKU
- This topic has 2 replies, 3 voices, and was last updated 3 weeks, 4 days ago by
Tom Anbinder.
- AuthorPosts
-
November 6, 2023 at 10:38 pm #127427
Nanette
ParticipantHi! 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!
November 8, 2023 at 1:02 pm #127548Hi 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
November 9, 2023 at 9:03 am #127575Hi, 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.
- Variation 1: Scent A (WooCommerce ID: 3425; EAN: 067000034251)
- AuthorPosts
- You must be logged in to reply to this topic.