Skip to content
 WooCommerce · 10 min · easy

Connect Perfect Day to WooCommerce.

Are you using WooCommerce? There are two ways: the native connector plugin (recommended, easier) or the Webhook variant via code snippet. Both write to the same platform — the result is identical.

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.

Way 1 — Native Connector (recommended, ~10 min)

The easiest way: We maintain our own WordPress plugin for WooCommerce.

  1. Install the connector plugin

    WordPress admin of your WooCommerce shop → Plugins → Add. Download the plugin ZIP file. „Perfect Day Shop connector" Upload it (you'll get it from us — download link available upon request via support) and activate it.

  2. Configure plugin

    WP-Admin → Settings → Perfect Day Connector. Enter:

    • Platform host: https://plattform.deinperfectday.de
    • Username + Application password from the preparation

    Save.

  3. Enter coupon ID for each product

    WP-Admin → Products → Open product. In the sidebar block „"Perfect Day"" Enter the coupon ID (15114 etc.) and save the product.

  4. Test order

    Place the order in the shop and set the status to "completed". WP-Admin → Orders → Check Note: „Perfect Day Codes generated: 1". The order will appear in the platform's back office under Perfect Day → Shop orders, The customer receives the brand email.

Method 2 — Via the generic webhook (~15 min)

If you don't want to install the connector plugin — for example, with a very old WooCommerce version or for a lighter setup — you can address the webhook via a small code snippet.

  1. Coupon ID as a custom field on the product

    WP-Admin → Products → Open product → Block „Own fields" (If not visible: top right, select "Screen Options" → activate "Custom Fields"). New field:

    • Name: pfd_coupon_id
    • Value: 15114 (your platform coupon ID)

    „Click "Update".

  2. Snippet in the functions.php of the child theme

    Add the following code to the functions.php of your active child theme. Enter your username and application password in the marked fields.

    View full code — PHP · functions.php
    PHP · functions.php
    add_action('woocommerce_order_status_completed', 'pfd_send_to_perfectday', 10, 1); function pfd_send_to_perfectday($order_id) { $order = wc_get_order($order_id); if (!$order) return; // Idempotence protection: only once per order if ($order->get_meta('_pfd_webhook_sent', true)) return; $items = array(); foreach ($order->get_items() as $item) { $product = $item->get_product(); if (!$product) continue; $coupon_id = get_post_meta($product->get_id(), 'pfd_coupon_id', true); if (empty($coupon_id)) continue; $items[] = array( 'coupon_id' => (int) $coupon_id, 'count' => (int) $item->get_quantity(), ); } if (empty($items)) return; $payload = array( 'shop_order_id' => (string) $order->get_order_number(), 'shop_type' => 'woocommerce', 'shop_domain' => parse_url(home_url(), PHP_URL_HOST), 'customer' => array( 'email' => $order->get_billing_email(), 'name' => trim($order->get_billing_first_name() . ' ' . $order->get_billing_last_name()), 'locale' => substr(get_locale(), 0, 2), ), 'items' => $items, 'order_total_cents' => (int) round($order->get_total() * 100), 'currency' => $order->get_currency(), 'placed_at' => $order->get_date_paid() ? $order->get_date_paid()->format('c') : current_time('c'), ); // ⬇ Enter YOUR values here ⬇ $username = 'YOUR-USERNAME'; $app_pwd = 'xxxx xxxx xxxx xxxx xxxx xxxx'; // ⬆ Enter YOUR values here ⬆ $response = wp_remote_post( 'https://plattform.deinperfectday.de/wp-json/perfectday/shop/webhook/order', array( 'headers' => array( 'Content-Type' => 'application/json', 'Authorization' => 'Basic ' . base64_encode($username . ':' . $app_pwd), ), 'body' => wp_json_encode($payload), 'timeout' => 15, ) ); if (!is_wp_error($response)) { $order->update_meta_data('_pfd_webhook_sent', '1'); $order->add_order_note(sprintf( 'Perfect Day: Webhook sent (HTTP %d)', wp_remote_retrieve_response_code($response) )); $order->save(); } else { $order->add_order_note('Perfect Day: Webhook failed — ' . $response->get_error_message()); } }
  3. Securely store credentials

    Having the application password directly in the PHP code is suboptimal. Better: via wp-config.phpDefine the constant and reference it in the snippet.

    PHP · wp-config.php
    define('PFD_API_USER', 'your-name'); define('PFD_API_PASSWORD', 'xxxx xxxx xxxx xxxx xxxx xxxx'); // In the snippet then: // $username = PFD_API_USER; // $app_pwd = PFD_API_PASSWORD;
  4. Test order

    Place the order, set the status to "completed", then open the order in WP-Admin and select the desired option at the bottom. Notes check: Perfect Day: Webhook sent (HTTP 200) → Everything's fine.

If something is stuck

Troubleshooting.

The code will not be executed.

Is the snippet in the correct theme (child theme!)? Otherwise, it will be gone after a theme update. Also: The hook. woocommerce_order_status_completed This only fires when the status changes to "completed". If your payment method leaves orders directly in "processing", change the hook to... woocommerce_order_status_processing.

HTTP 403 — forbidden_coupon

The pfd_coupon_id The custom field points to a coupon that doesn't belong to your provider account. Check in the platform back office under Vouchers, whether the ID exists there.

HTTP 401 — authentication required

Incorrect username (it's the WordPress username, not the email address) or incorrect application password, revoked, or copied with an error.

Setup service

Would you prefer us to set it up for you?

WooCommerce is the simplest case—you can usually manage it yourself. However, if you'd like help, we can install and configure the connector for you, including mapping your product coupon IDs.

Frequently Asked Questions

Still questions?

Route 1 or Route 2 — which should I take?
For most providers, we recommend option 1 (Connector plugin). It updates automatically via the WordPress plugin update. Option 2 (Snippet) is for providers with their own development team who prefer a lightweight setup without an additional plugin. Functionally, both are identical.
Does this also work with an older WooCommerce version?
Yes. If the connector plugin requires a WooCommerce version that is too new, use method 2 with the snippet — it also works with older installations.

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