“Invalid or duplicated GTIN, UPC, EAN or ISBN” in WooCommerce: the two checks, and what is never checked
WooCommerce checks two things about a product's barcode: that no other product has it, and that an X only appears as the last character. It doesn't check the length or the check digit, so most wrong barcodes save without a word.
In this article13 sections
The field WooCommerce labels GTIN, UPC, EAN, or ISBN holds one barcode per product or variation, and no two can share one. This message means the code you entered already belongs to another product or variation. Its sibling, the message about the letter X, means the code has an X somewhere other than the last position.
Those are the only two checks. WooCommerce doesn’t know what a real barcode looks like: it doesn’t test the length, the type or the check digit. So a code can be wrong in a dozen ways and still save, and the code you’re being refused for might not even be the one you typed, because WooCommerce cleans it first.
The exact message#
Invalid or duplicated GTIN, UPC, EAN or ISBN.
The same failure can also read:
- Invalid GTIN, UPC, EAN, or ISBN. The letter X is only valid as the final ISBN-10 check digit.
- Enter only numbers and hyphens (-). The letter X is allowed only as the final ISBN-10 check digit.
Who sees it: Store owners and developers. In the classic product editor it appears as a notice at the top of the screen after Update or Publish, or in the Variations tab after Save changes; the “Enter only numbers and hyphens” wording is a tip that pops up under the field while you type. The REST API returns error code product_invalid_global_unique_id (or product_invalid_global_unique_id_format for the X rule) with status 400, and the CSV importer lists the row as failed.
What WooCommerce checks#
When a GTIN is set through WooCommerce, by the editor, the REST API or an import, it is processed in this order:
- Cleaning. Every character except digits, hyphens and the letter X (either case) is removed without a warning. Spaces, letters and punctuation disappear.
- The X rule. If an X is left anywhere except at the end, the code is refused with Invalid GTIN, UPC, EAN, or ISBN. The letter X is only valid as the final ISBN-10 check digit.
- Uniqueness. If another product or variation, in any status except Trash, has exactly the same cleaned code, it is refused with this message.
Codes are compared as plain text. 036000291452 and 0036000291452 are two different codes to WooCommerce, and so are 978-0-306-40615-7 and 9780306406157.
In the editor, the rest of the product is saved and the GTIN keeps its previous value. While you type, the field shows the tip Enter only numbers and hyphens (-)…, and when you leave it, the browser removes the same characters, plus any hyphens at the start and end of the code. Through the REST API the whole request is refused, and in a CSV import the whole row fails.
Causes and how to fix each one#
1. Another product or variation already has the code#
The direct case: the same barcode is on two products, often a product and one of its variations, or a draft you forgot. A variation can’t reuse its parent’s code either. Each one needs its own, or none.
Check: Type the code into the search box on Products > All Products. The search matches GTINs too, including drafts and variations, which show up as their parent product.
Fix: Remove the code from the product that shouldn’t have it, then save the other one again.
2. Two different codes became the same after cleaning#
Because letters are removed silently, anything that isn’t a pure barcode can collide. Supplier part numbers AB-1001 and CD-1001 are both stored as -1001, so the second one is refused. Spreadsheet damage does the same: a 13-digit code shown as 4.00638E+12 is cleaned to 40063812, and every other code that the spreadsheet rounded the same way collides with it.
Check: Open the product that was accepted and look at its GTIN field. If it holds a shortened or stripped version of what you typed, this is the cause.
Fix: Put only real barcodes in this field, and keep part numbers in the SKU. In a spreadsheet, format the column as Text before pasting the codes, so they’re saved in full.
3. There’s an X in the middle of the code#
X is kept because it’s a legal last character of an ISBN-10. Anywhere else it’s refused. Text that wasn’t meant to be a barcode often contains one: 10x20, 2 x 500ml (cleaned to 2x500) or Box 12 (cleaned to x12).
Check: Look at the value you entered or the cell in your file. Any x or X before the last character triggers the X-rule message.
Fix: Enter the barcode alone. If the X is an ISBN-10 check digit, it belongs at the very end.
4. The wrong column is mapped to the barcode field on import#
A column headed GTIN, UPC, EAN, or ISBN isn’t mapped automatically by the importer, so the field is usually chosen by hand on the mapping screen. Picking the wrong column there (a model number, a size, a supplier code) produces exactly the collisions and X errors above, on every row.
Check: Start the import again and look at the Map CSV fields to products screen. The Sample under each column name shows what’s in it.
Fix: Map only the barcode column to GTIN, UPC, EAN, or ISBN, and set the others to Do not import.
5. The same code appears twice in your import file#
Rows are saved one at a time from the top. The first row with a code keeps it and every later row with the same code fails, including rows where several variations were given their parent’s barcode.
Check: Sort the barcode column in your spreadsheet and look for repeats.
Fix: Give each product and variation its own code, or leave the cell empty for the ones that don’t have one.
Quick reference#
| Cause | How to check | Fix |
|---|---|---|
| Another product or variation already has the code | Type the code into the search box on Products > All Products. The search matches GTINs too, including drafts and variations, which show up as their parent product. | Remove the code from the product that shouldn't have it, then save the other one again. |
| Two different codes became the same after cleaning | Open the product that was accepted and look at its GTIN field. If it holds a shortened or stripped version of what you typed, this is the cause. | Put only real barcodes in this field, and keep part numbers in the SKU. In a spreadsheet, format the column as Text before pasting the codes, so they're saved in full. |
| There's an X in the middle of the code | Look at the value you entered or the cell in your file. Any x or X before the last character triggers the X-rule message. | Enter the barcode alone. If the X is an ISBN-10 check digit, it belongs at the very end. |
| The wrong column is mapped to the barcode field on import | Start the import again and look at the Map CSV fields to products screen. The Sample under each column name shows what's in it. | Map only the barcode column to GTIN, UPC, EAN, or ISBN, and set the others to Do not import. |
| The same code appears twice in your import file | Sort the barcode column in your spreadsheet and look for repeats. | Give each product and variation its own code, or leave the cell empty for the ones that don't have one. |
Reproduced on a test store#
We set up each case below on a clean WooCommerce 11.2.1 store on 6 November 2026 and recorded exactly what it showed.
| What we did | What WooCommerce showed |
|---|---|
| Simple product A with GTIN 4006381333931. Open simple product B, enter 4006381333931 in GTIN, UPC, EAN, or ISBN on the Inventory tab, press Update. | Invalid or duplicated GTIN, UPC, EAN or ISBN. |
| Open product B, type 10×20 into GTIN, UPC, EAN, or ISBN, press Update. | Invalid GTIN, UPC, EAN, or ISBN. The letter X is only valid as the final ISBN-10 check digit. |
| Open product B, enter 0-306-40615-X, press Update. | No message. The change was saved. |
| CSV with header Type,SKU,Name,GTIN and rows simple,P1,One,AB-1001 and simple,P2,Two,CD-1001. Map GTIN by hand to GTIN, UPC, EAN, or ISBN. Update existing products unticked. | Invalid or duplicated GTIN, UPC, EAN or ISBN. Imported: 1. Updated: 0. Saved: One gtin -1001. |
| Product A has GTIN 036000291452. Import a new simple product with GTIN 0036000291452. | No message. The row was imported. Imported: 1. Updated: 0. Saved: Three gtin 0036000291452. |
| Move A to the Trash. Give product B the GTIN 4006381333931 and press Update. | No message. The change was saved. |
For developers#
The exceptions come from WC_Product::set_global_unique_id() with codes product_invalid_global_unique_id and product_invalid_global_unique_id_format. To see what a code is stored as and who holds it, run this in wp shell:
$code = preg_replace( '/[^0-9Xx\-]/', '', 'AB-1001' );
var_dump( $code, wc_get_product_id_by_global_unique_id( $code ) );The uniqueness test can be replaced with wc_product_pre_has_global_unique_id (return a boolean) or adjusted with wc_product_has_global_unique_id. WooCommerce has no check digit validation to switch on; the GTIN check digit calculator checks codes before you enter them.
Where this lives in WooCommerce 11.2.1:
includes/abstracts/abstract-wc-product.php,WC_Product::set_global_unique_id: Strips every character except digits, X and hyphens, refuses an X that isn’t last, then refuses a code another product already has.includes/wc-product-functions.php,wc_product_has_global_unique_id: The uniqueness test, with the wc_product_pre_has_global_unique_id and wc_product_has_global_unique_id filters.includes/data-stores/class-wc-product-data-store-cpt.php,WC_Product_Data_Store_CPT::is_existing_global_unique_id: Exact text match against other products and variations in wc_product_meta_lookup, any status except trash.assets/js/admin/woocommerce_admin.js,(keyup and change handlers on _global_unique_id fields): Shows the Enter only numbers and hyphens tip, and cleans the field when you leave it. The text comes from i18n_global_unique_id_error in includes/admin/class-wc-admin-assets.php.includes/class-wc-post-data.php,WC_Post_Data::untrash_post: A product restored from the Trash loses its GTIN if another product has taken it meanwhile.includes/admin/class-wc-admin-duplicate-product.php,WC_Admin_Duplicate_Product::product_duplicate: Duplicating a product leaves the copy’s GTIN empty, so a duplicate never triggers the message.
Related WooCommerce errors#
- Invalid or duplicated SKU.
- No matching product exists to update.
- A product with this SKU already exists.
Back to the WooCommerce error reference.
Frequently asked questions#
Does WooCommerce check the barcode's check digit?
No. In our import tests a code with a wrong check digit was saved without any warning. Check codes with a check digit calculator before you enter them.
Why did the letters in my code disappear?
WooCommerce removes everything except digits, hyphens and the letter X before saving. The editor does the same when you leave the field, and also removes hyphens at the start and end, so AB-1001 typed in the editor is saved as 1001 but imported as -1001.
Is 036000291452 the same code as 0036000291452?
Not to WooCommerce. It compares the text exactly, so the 12-digit and 13-digit forms count as two different codes and both can be saved.
Can two variations share one barcode?
No. Every product and variation needs a different code, and a variation can’t reuse its parent’s code.
Why isn't my GTIN column imported?
A column with the heading GTIN, UPC, EAN, or ISBN isn’t mapped automatically. Choose GTIN, UPC, EAN, or ISBN for it by hand on the mapping screen.
What does the message about the letter X mean?
An ISBN-10 can end in X as its check digit, so WooCommerce allows an X only in the last position. An X anywhere else gets the code refused.