Das ShopBite Plugin bietet erweiterte Checkout-Funktionen, die speziell für Gastronomie- und Einzelhandelsbetriebe entwickelt wurden. Dieses Kapitel erklärt die Konfiguration und Nutzung dieser Funktionen.
Die Checkout-Erweiterungen umfassen:
Container-basierte Produkte ermöglichen die Gruppierung von Artikeln:
Container: Pizza-Menü
- Hauptgericht: Pizza (Pflichtfeld)
- Optionen: Margherita, Salami, Hawaii
- Beilage: Salat oder Pommes (Pflichtfeld)
- Optionen: Caesar Salat, Gemischter Salat, Pommes
- Getränk: Optional
- Optionen: Cola, Fanta, Wasser, Bier
shopbite_receipt_print_typestandard: Normaler Bon-Druckkitchen: Küchenbon für Zubereitungbar: Barbon für Getränkeno_print: Kein Bon-Druck erforderlich| Produkt | Bon-Drucktyp | Beschreibung |
|---|---|---|
| Pizza Margherita | kitchen | Wird in der Küche zubereitet |
| Cola 0,33l | bar | Wird an der Bar ausgegeben |
| Dessert | standard | Normaler Bon-Druck |
| Gutschein | no_print | Kein physischer Bon nötig |
Der ReceiptPrintTypeProcessor verarbeitet die Bon-Drucktypen:
// src/Checkout/Cart/ReceiptPrintTypeProcessor.php
public function process(CartDataCollection $data, Cart $original, Cart $toCalculate, SalesChannelContext $context, CartBehavior $behavior): void
{
foreach ($toCalculate->getLineItems()->filterFlatByType(LineItem::PRODUCT_LINE_ITEM_TYPE) as $lineItem) {
$productId = $lineItem->getReferencedId();
if ($productId === null) {
continue;
}
$product = $data->get(self::DATA_KEY . $productId);
if ($product === null) {
continue;
}
$customFields = $product->getCustomFields() ?? [];
if (!isset($customFields[CustomFieldsInstaller::SHOPBITE_RECEIPT_PRINT_TYPE])) {
continue;
}
$lineItem->setPayloadValue(
CustomFieldsInstaller::SHOPBITE_RECEIPT_PRINT_TYPE,
$customFields[CustomFieldsInstaller::SHOPBITE_RECEIPT_PRINT_TYPE]
);
}
}
shopbite_delivery_time_factor// Beispielberechnung in der Storefront
function calculateDeliveryTime(product) {
const baseTime = 30; // Basis-Lieferzeit in Minuten
const factor = product.customFields?.shopbite_delivery_time_factor || 1;
return baseTime * factor; // Ergebnis in Minuten
}
// Beispiel
const pizza = { customFields: { shopbite_delivery_time_factor: 2 } };
const deliveryTime = calculateDeliveryTime(pizza); // 60 Minuten
| Produkt | Faktor | Berechnete Lieferzeit |
|---|---|---|
| Pizza | 2 | 60 Minuten |
| Salat | 1 | 30 Minuten |
| Getränk | 0.5 | 15 Minuten |
| Dessert | 1 | 30 Minuten |
// Bestelltypen in der Storefront
const orderTypes = [
{ id: 'pickup', name: 'Abholung', description: 'Selbst abholen' },
{ id: 'delivery', name: 'Lieferung', description: 'Zustellung' },
{ id: 'on_site', name: 'Vor Ort', description: 'Hier verzehren' }
];
// Bestelltyp auswählen
function selectOrderType(typeId) {
// Logik zur Auswahl des Bestelltyps
console.log(`Bestelltyp ausgewählt: ${typeId}`);
}
Das Plugin installiert die Custom Fields automatisch:
// src/Service/CustomFieldsInstaller.php
public function install(Context $context): void
{
$customFieldSetId = Uuid::fromHexToBytes(self::CUSTOM_FIELDSET_ID);
$customFieldSetData = [
'id' => self::CUSTOM_FIELDSET_ID,
'name' => self::CUSTOM_FIELDSET_NAME,
'config' => [
'label' => [
'en-GB' => 'ShopBite',
'de-DE' => 'ShopBite',
],
],
'customFields' => [
[
'id' => '0198be8b24a0722cac46b07e3a9686ec',
'name' => 'shopbite_delivery_time_factor',
'type' => CustomFieldTypes::INT,
'config' => [
'label' => [
'en-GB' => 'Delivery Time Factor',
'de-DE' => 'Lieferzeitfaktor',
],
],
],
[
'id' => '01944f2b1875706596395b8d23966952',
'name' => self::SHOPBITE_RECEIPT_PRINT_TYPE,
'type' => CustomFieldTypes::SELECT,
'config' => [
'label' => [
'en-GB' => 'Receipt Print Type',
'de-DE' => 'Bon-Drucktyp',
],
'options' => [
['value' => 'standard', 'label' => ['en-GB' => 'Standard', 'de-DE' => 'Standard']],
['value' => 'kitchen', 'label' => ['en-GB' => 'Kitchen', 'de-DE' => 'Küche']],
['value' => 'bar', 'label' => ['en-GB' => 'Bar', 'de-DE' => 'Bar']],
['value' => 'no_print', 'label' => ['en-GB' => 'No Print', 'de-DE' => 'Kein Druck']],
],
],
],
],
];
$this->customFieldSetRepository->upsert([$customFieldSetData], $context);
}
Falls die automatische Installation fehlschlägt:
# Custom Fields manuell installieren
bin/console shopbite:custom-fields:install
# Custom Fields prüfen
bin/console custom-field:set:list | grep shopbite
POST /store-api/checkout/cart/line-item
curl -X POST "https://Ihre-Shopware-Domain.de/store-api/checkout/cart/line-item" \
-H "Authorization: Bearer IhrAPIToken" \
-H "sw-access-key: IhrAccessKey" \
-H "Content-Type: application/json" \
-d '{
"items": [
{
"id": "019a36f224b0704fb6835914050392f4",
"type": "product",
"referencedId": "019a36f224b0704fb6835914050392f4",
"quantity": 1,
"payload": {
"shopbite_receipt_print_type": "kitchen",
"shopbite_delivery_time_factor": 2
}
}
]
}'
{
"data": {
"lineItems": [
{
"id": "019a36f224b0704fb6835914050392f4",
"type": "product",
"referencedId": "019a36f224b0704fb6835914050392f4",
"quantity": 1,
"payload": {
"shopbite_receipt_print_type": "kitchen",
"shopbite_delivery_time_factor": 2
}
}
],
"deliveryTime": 60
}
}
-- Indizes für Custom Fields
CREATE INDEX `idx_custom_fields` ON `product` (`custom_fields`);
-- Optimierung für häufige Abfragen
CREATE INDEX `idx_receipt_print_type` ON `product`
((CAST(custom_fields->>'$.shopbite_receipt_print_type' AS CHAR(50))));
// Validierung im Checkout-Prozess
public function validateCheckout(Cart $cart): array
{
$errors = [];
foreach ($cart->getLineItems() as $lineItem) {
$payload = $lineItem->getPayload();
if (!isset($payload['shopbite_receipt_print_type'])) {
$errors[] = sprintf(
'Produkt %s hat keinen Bon-Drucktyp',
$lineItem->getLabel()
);
}
if (!isset($payload['shopbite_delivery_time_factor'])) {
$errors[] = sprintf(
'Produkt %s hat keinen Lieferzeitfaktor',
$lineItem->getLabel()
);
}
}
return $errors;
}
# In config/packages/cache.yaml
framework:
cache:
pools:
shopbite.checkout:
adapter: cache.adapter.redis
default_lifetime: 300 # 5 Minuten Cache
Symptome:
Lösungen:
# Custom Fields neu installieren
bin/console shopbite:custom-fields:install --force
# Cache leeren
bin/console cache:clear
# Datenbank prüfen
mysql -u shopware -p shopware -e "SELECT * FROM custom_field_set WHERE name = 'shopbite_product_set';"
Symptome:
Lösungen:
# Checkout-Prozessor prüfen
bin/console debug:container --tag=shopware.checkout.cart.processor
# Plugin-Cache leeren
bin/console plugin:refresh ShopBite
# Custom Fields prüfen
bin/console custom-field:set:list
Symptome:
Lösungen:
# Custom Field-Werte prüfen
mysql -u shopware -p shopware -e "
SELECT id, custom_fields FROM product
WHERE custom_fields LIKE '%shopbite_delivery_time_factor%' LIMIT 5;
"
# Berechnungslogik prüfen
bin/console config:get ShopBitePlugin.config.baseDeliveryTime
# Debug-Modus aktivieren
bin/console config:set ShopBitePlugin.config.debug true