Skip to main content

Frameworks

WooCommerce — Scell.io integration

Automatic Factur-X invoice on order completion

The `scell/sdk` PHP SDK v3.5.0 integrates into a WooCommerce plugin to generate a compliant Factur-X invoice on each paid order. `woocommerce_order_status_completed` hook triggers creation, `WC_Order_Item_Product` maps to Scell lines. B2C auto-detection (no buyer SIRET) and automatic BR-CO-26 application.

Key facts

  • `woocommerce_order_status_completed` hook
  • B2C auto-detection via `$order->get_meta('_billing_company')`
  • Maps `WC_Order_Item_Product` to `addLine()`
  • Factur-X PDF attached to confirmation email
  • Compatible with WooCommerce 8.0+ and HPOS

Code example

use Scell\Sdk\Client;

add_action('woocommerce_order_status_completed', function ($order_id) {
    $order = wc_get_order($order_id);
    $client = new Client(get_option('scell_api_key'));
    $builder = $client->invoices()->builder()->facturX();

    foreach ($order->get_items() as $item) {
        $builder->addLine($item->get_name(), $item->get_quantity(), $item->get_total(), 20.0);
    }
    $invoice = $builder->buyerIndividual($order->get_formatted_billing_full_name())->create();
    $order->update_meta_data('_scell_invoice_id', $invoice->id);
    $order->save();
});

See also

Your cookie preferences

We use cookies to improve your experience. Essential cookies are always active. Cookie policy.