Store the GTIN of the variable-weight item with the weight digits set to zero.
Example: 26 123 4 000000 8
That is the GTIN to keep on the product. The barcode printed on each pack includes the weight, and that weight changes the check digit.
Creating a base unit checks the check digit. See Check if barcodes are correct.