Fix barcode 500 error, GTIN mask formatting, and add price sync
Deploy / deploy (push) Successful in 15s

- Wrap barcode generation in try-catch to prevent 500 on invalid GTIN
- Move barcode preview above GTIN input field
- Add input mask (X XXXXXX XXXXXX) and strip non-digits before save/render
- Only render barcode when >= 8 digits present
- shopify:sync now updates price alongside inventory

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Malek TellissiandClaude Sonnet 4.6 committed 2026-09-12 04:59:46 +02:00
1 parent 25b32c717b
commit e959faff8d
2 files changed
+17 -6

No files matched your search

+5
View File
@@ -35,6 +35,11 @@ class ShopifySync extends Command
continue; // not mapped yet — run shopify:map first
}
// Preis immer aktualisieren
if (! $dryRun && $size->price != $variant['price']) {
$size->update(['price' => $variant['price']]);
}
$shopifyQty = $variant['inventory_quantity'];
$localQty = ProductInventory::where('size_id', $size->id)
->whereNull('out_at')
@@ -70,14 +70,11 @@ class ProductResource extends Resource {
->required(),
TextInput::make('sku')
->label('SKU'),
TextInput::make('gtin')
->label('GTIN')
->live(debounce: 500),
Placeholder::make('barcode_preview')
->label('Barcode')
->content(function (Get $get): HtmlString {
$gtin = trim((string) $get('gtin'));
if (empty($gtin)) {
$gtin = preg_replace('/\D/', '', (string) $get('gtin'));
if (strlen($gtin) < 8) {
return new HtmlString('');
}
$type = match (strlen($gtin)) {
@@ -87,11 +84,20 @@ class ProductResource extends Resource {
14 => BarcodeGeneratorSVG::TYPE_CODABAR,
default => BarcodeGeneratorSVG::TYPE_CODE_128,
};
try {
$svg = (new BarcodeGeneratorSVG())->getBarcode($gtin, $type, 2, 60);
return new HtmlString($svg);
} catch (\Throwable) {
return new HtmlString('');
}
})
->columnSpanFull()
->visible(fn (Get $get) => filled($get('gtin'))),
->visible(fn (Get $get) => strlen(preg_replace('/\D/', '', (string) $get('gtin'))) >= 8),
TextInput::make('gtin')
->label('GTIN')
->mask('9 999999 999999')
->dehydrateStateUsing(fn ($state) => preg_replace('/\D/', '', (string) $state))
->live(debounce: 500),
])
->label('Größen & Preise')
->columns(2)