Fix barcode 500 error, GTIN mask formatting, and add price sync
Deploy / deploy (push) Successful in 15s
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:
1 parent
25b32c717b
commit
e959faff8d
2 files changed
+17
-6
No files matched your search
@@ -35,6 +35,11 @@ class ShopifySync extends Command
|
|||||||
continue; // not mapped yet — run shopify:map first
|
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'];
|
$shopifyQty = $variant['inventory_quantity'];
|
||||||
$localQty = ProductInventory::where('size_id', $size->id)
|
$localQty = ProductInventory::where('size_id', $size->id)
|
||||||
->whereNull('out_at')
|
->whereNull('out_at')
|
||||||
|
|||||||
@@ -70,14 +70,11 @@ class ProductResource extends Resource {
|
|||||||
->required(),
|
->required(),
|
||||||
TextInput::make('sku')
|
TextInput::make('sku')
|
||||||
->label('SKU'),
|
->label('SKU'),
|
||||||
TextInput::make('gtin')
|
|
||||||
->label('GTIN')
|
|
||||||
->live(debounce: 500),
|
|
||||||
Placeholder::make('barcode_preview')
|
Placeholder::make('barcode_preview')
|
||||||
->label('Barcode')
|
->label('Barcode')
|
||||||
->content(function (Get $get): HtmlString {
|
->content(function (Get $get): HtmlString {
|
||||||
$gtin = trim((string) $get('gtin'));
|
$gtin = preg_replace('/\D/', '', (string) $get('gtin'));
|
||||||
if (empty($gtin)) {
|
if (strlen($gtin) < 8) {
|
||||||
return new HtmlString('');
|
return new HtmlString('');
|
||||||
}
|
}
|
||||||
$type = match (strlen($gtin)) {
|
$type = match (strlen($gtin)) {
|
||||||
@@ -87,11 +84,20 @@ class ProductResource extends Resource {
|
|||||||
14 => BarcodeGeneratorSVG::TYPE_CODABAR,
|
14 => BarcodeGeneratorSVG::TYPE_CODABAR,
|
||||||
default => BarcodeGeneratorSVG::TYPE_CODE_128,
|
default => BarcodeGeneratorSVG::TYPE_CODE_128,
|
||||||
};
|
};
|
||||||
|
try {
|
||||||
$svg = (new BarcodeGeneratorSVG())->getBarcode($gtin, $type, 2, 60);
|
$svg = (new BarcodeGeneratorSVG())->getBarcode($gtin, $type, 2, 60);
|
||||||
return new HtmlString($svg);
|
return new HtmlString($svg);
|
||||||
|
} catch (\Throwable) {
|
||||||
|
return new HtmlString('');
|
||||||
|
}
|
||||||
})
|
})
|
||||||
->columnSpanFull()
|
->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')
|
->label('Größen & Preise')
|
||||||
->columns(2)
|
->columns(2)
|
||||||
|
|||||||
Reference in new issue
Block a user