Skip to content
 Shopware 6 · 20–30 min · advanced

Integrating Perfect Day into Shopware 6.

Sell your Perfect Day coupons through your Shopware 6 shop. Shopware doesn't provide a webhook with custom field content out of the box — you'll need a small bridge. A notice: This guide applies to Shopware 6. For Shopware 5, please contact support.

Required beforehand: Go once the general preparation This involves creating a coupon, obtaining the application password, and providing the webhook URL. It takes approximately five minutes and applies to all shop systems.

Step 1 — Create a custom field for the coupon ID

  1. Create custom field set

    Shopware admin → Settings → System → Additional fields„Create sets". Set name: Perfect Day. Under Assignments the option „"Product"" choose.

  2. Add field

    New field with these values:

    • Technical name: pfd_coupon_id
    • Type: Number (Integer)
    • Display name: Perfect Day Coupon ID

    Save.

Step 2 — Enter coupon ID for each product

  1. Enter in the product editor

    Shopware admin → Catalogues → Products → Open product → Tabs „Specifications" → Block „"Additional fields"". Set „"Perfect Day Coupon ID"" on the value from the platform back office (e.g. 15114) and save.

Step 3 — Install the Bridge app

Shopware doesn't include a webhook with custom field content. You'll need a small Shopware app to handle that. We've prepared an app skeleton—you can get the finished product upon request from our support team. Or you can build it yourself using this template.

  1. App manifest (manifest.xml)

    The manifest registers the app and the order-paid webhook. Enter your bridge domain in the manifest. URL-attribute.

    View full code — XML · manifest.xml
    XML · manifest.xml
    PerfectDayConnector  Send order data with Perfect Day coupon IDs to the platform. DigElite (c) DigElite 1.0.0 WITH
  2. Bridge endpoint (own server)

    The bridge receives the Shopware webhook, retrieves the custom field for each item, transforms it into the Perfect Day format, and forwards it. Example in PHP:

    View full code — PHP · bridge.php
    PHP · bridge.php
    <?php
    // bridge.php — empfängt Shopware-Webhook, ruft Shopware-API für
    // Produktdetails, leitet ans Perfect Day weiter.
    
    $rawPayload = file_get_contents('php://input');
    $payload = json_decode($rawPayload, true);
    $order = $payload['data']['payload']['order'] ?? null;
    if (!$order) { http_response_code(400); exit; }
    
    // Shopware-API-Token holen (Server-zu-Server, eigene Credentials)
    $swToken = sw_admin_token();
    
    $items = [];
    foreach ($order['lineItems'] as $li) {
        $product = sw_api_get('/api/product/' . $li['productId'], $swToken);
        $couponId = $product['customFields']['pfd_coupon_id'] ?? null;
        if (!$couponId) continue;
        $items[] = ['coupon_id' => (int)$couponId, 'count' => (int)$li['quantity']];
    }
    if (empty($items)) { http_response_code(200); exit; }
    
    $pfdPayload = [
        'shop_order_id' => $order['orderNumber'],
        'shop_type'     => 'shopware',
        'shop_domain'   => parse_url($order['salesChannel']['domains'][0]['url'], PHP_URL_HOST),
        'customer' => [
            'email'  => $order['orderCustomer']['email'],
            'name'   => trim($order['orderCustomer']['firstName'] . ' ' . $order['orderCustomer']['lastName']),
            'locale' => substr($order['language']['locale']['code'], 0, 2),
        ],
        'items'             => $items,
        'order_total_cents' => (int) round(($order['amountTotal'] ?? 0) * 100),
        'currency'          => $order['currency']['isoCode'] ?? 'EUR',
        'placed_at'         => $order['orderDateTime'] ?? gmdate('c'),
    ];
    
    $ch = curl_init('https://plattform.deinperfectday.de/wp-json/perfectday/shop/webhook/order');
    curl_setopt_array($ch, [
        CURLOPT_POST           => 1,
        CURLOPT_RETURNTRANSFER => 1,
        CURLOPT_HTTPHEADER     => [
            'Content-Type: application/json',
            'Authorization: Basic ' . base64_encode('DEIN-USER:DEIN APP PWD'),
        ],
        CURLOPT_POSTFIELDS => json_encode($pfdPayload),
        CURLOPT_TIMEOUT    => 15,
    ]);
    curl_exec($ch);
    curl_close($ch);
    
    http_response_code(200);
  3. Unzip the app and install it.

    Manifest and bridge URL in one app.zip packing (see Shopware DocsThen Shopware Admin → Extensions → Upload your own extensions → Insert ZIP file → activate.

Easier: Use Cloud Bridge

If setting up your own bridge is too complex, it's also possible without your own server.

  1. Make.com, Zapier or n8n

    Make.com: Module „Webhooks → Custom webhook" as trigger, „Shopware → Get a Product" for enrichment, „HTTP → Make a request" as output — setup takes about 15 minutes. n8n It's self-hostable and therefore more GDPR-compliant. Send us a support request with your preferred tool, and we'll provide a pre-configured workflow.

Step 4 — Test order

  1. Place and check order

    Place a test order and mark the payment as "Paid". The bridge should be automatically called by Shopware. Check: Platform back office → Perfect Day → Shop orders (Entry with shop_type=shopware?) and the customer mailbox to the brand email with print button.

If something is stuck

Troubleshooting.

The webhook was not executed.

Shopware admin → Settings → System → Logs → App Webhooks. If errors are displayed there, the app manifest URL is usually incorrect or the bridge is unreachable.

HTTP 401 on the perfect day endpoint

Incorrect username or application password in the bridge code. wp-config.php-Constants are more secure than hardcoded values.

HTTP 403 — forbidden_coupon

The pfd_coupon_id Items from the custom field do not belong to your provider account on the platform.

Bridge server not reachable

Is the bridge running on your own server? Is the SSL certificate valid? Is the server publicly accessible? Shopware must be able to send POST requests from its cloud backend to your server.

Setup service

Would you prefer us to set it up for you?

Shopware is significantly more complex than Shopify or WooCommerce due to the mandatory bridge. We offer a fully integrated Shopware app with a built-in bridge, or we can host the bridge entirely on our servers. You simply provide us with your Shopware API credentials.

Frequently Asked Questions

Still questions?

Is it possible to do this without your own server?
Yes. Instead of a self-hosted bridge, you can use Make.com, Zapier, or a self-hosted n8n. We can provide a pre-configured workflow upon request.
Does the guide also work for Shopware 5?
No. Shopware 5 does not have built-in custom field webhook support—a separate plugin is required. If you are using Shopware 5, please submit a support request.
Are you planning a native Shopware plugin?
Yes, in the medium term. A native plugin would eliminate the need for the bridge setup. The order depends on demand—let me know if you're interested.

Shop connected — and now what?

Once the webhook is running, all orders will automatically appear in your back office. If you need another connection, each additional shop can be set up in just a few minutes.

Go to shop overview