Documentation

Installation of the Order Printer

This guide will walk you through the installation and setup of the ShopBite Order Printer.

Check Prerequisites

Before you begin the installation, make sure all prerequisites are met:

Server Prerequisites

# Check PHP version
php -v
# Should show PHP 8.2 or higher

# Install Composer (if not present)
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"

# Check SQLite extension
php -m | grep sqlite

Printer Prerequisites

  • Install CUPS (for local printers):
    # On Ubuntu/Debian
    sudo apt-get update
    sudo apt-get install cups
    
    # Start CUPS service
    sudo systemctl start cups
    sudo systemctl enable cups
    
  • Set up printer:
    # Add printer (example for Epson TM-T20)
    lpadmin -p TM-T20 -E -v usb://Epson/TM-T20 -m drv:///sample.drv/generic.ppd
    
    # Set default printer
    lpoptions -d TM-T20
    

Installation

1. Clone Repository

git clone https://github.com/shopbite/order-printer.git
cd order-printer

2. Install Dependencies

composer install --no-dev --optimize-autoloader

For development purposes:

composer install

3. Configure Environment

Copy the example environment file:

cp .env .env.local

4. Set Up Database

# Create database
bin/console doctrine:database:create

# Update schema
bin/console doctrine:schema:update --force

Shopware 6 Integration

Set Up API Access

  1. Open Shopware Administration
  2. Settings > System > Integrations
  3. Add New Integration
  4. Set Permissions:
    • order:read - Read orders
    • order:update - Update order status
    • customer:read - Read customer data

Configure Integration

Edit the .env.local file:

# Shopware API Access
SHOPWARE_HOST=https://your-shopware-domain.de
SHOPWARE_CLIENT_ID=your_client_id
SHOPWARE_CLIENT_SECRET=your_client_secret

# Printer Settings
PRINTER_NAME=TM-T20

# Data Directory
DATA_DIR="/data/receipts/"

Set Up Printer

CUPS Configuration

  1. Add Printer:
    sudo lpadmin -p YourPrinterName -E -v usb://Manufacturer/Model -m drv:///sample.drv/generic.ppd
    
  2. Set Default Printer:
    lpoptions -d YourPrinterName
    
  3. Print Test Page:
    lp -d YourPrinterName /etc/cups/ppd/YourPrinterName.ppd
    

Set Up Network Printer

For network printers, use the IP address:

sudo lpadmin -p NetworkPrinter -E -v socket://192.168.1.100:9100 -m drv:///sample.drv/generic.ppd

Start Service

Development Mode

# Start scheduler (checks every 10 seconds for new orders)
bun run scheduler

# Start worker (processes print jobs)
bun run worker

Production Mode

For production operation, we recommend using Supervisor:

  1. Create Supervisor Configuration (/etc/supervisor/conf.d/order-printer.conf):
[program:order-printer-scheduler]
command=/path/to/project/bin/console messenger:consume scheduler_default
user=www-data
autostart=true
autorestart=true
stderr_logfile=/var/log/order-printer-scheduler.err.log
stdout_logfile=/var/log/order-printer-scheduler.out.log

[program:order-printer-worker]
command=/path/to/project/bin/console messenger:consume async
user=www-data
autostart=true
autorestart=true
stderr_logfile=/var/log/order-printer-worker.err.log
stdout_logfile=/var/log/order-printer-worker.out.log
  1. Update Supervisor:
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start all

Getting Started

Create Test Order

  1. Create a test order in Shopware
  2. Set order status to "Open"
  3. Monitor printer - The receipt should be printed automatically

Check Logs

# Scheduler logs
tail -f /var/log/order-printer-scheduler.out.log

# Worker logs
tail -f /var/log/order-printer-worker.out.log

Common Installation Issues

Problem: Printer not detected

  • Solution: Restart CUPS: sudo systemctl restart cups
  • Solution: Check printer permissions: lpstat -t

Problem: Connection to Shopware API failed

  • Solution: Check API credentials in .env.local
  • Solution: Check firewall settings
  • Solution: Check Shopware logs for API errors

Problem: Database error

  • Solution: Check SQLite permissions: chmod 666 data/queue_*.db
  • Solution: Recreate database: rm data/queue_*.db && bin/console doctrine:database:create

Next Steps