Fix license generation and checkout domain field bugs

- Add WooCommerce Checkout Blocks support for domain field
- Create CheckoutBlocksIntegration for block-based checkout
- Create StoreApiExtension for Store API domain handling
- Add checkout-blocks.js for frontend domain field in blocks
- Fix LicenseManager product type check in generateLicense()
- Add multiple order status hooks for reliable license generation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-21 21:58:54 +01:00
parent 182dabebed
commit 319dfe357a
6 changed files with 427 additions and 3 deletions

View File

@@ -13,7 +13,9 @@ use Jeremias\WcLicensedProduct\Admin\AdminController;
use Jeremias\WcLicensedProduct\Admin\SettingsController;
use Jeremias\WcLicensedProduct\Admin\VersionAdminController;
use Jeremias\WcLicensedProduct\Api\RestApiController;
use Jeremias\WcLicensedProduct\Checkout\CheckoutBlocksIntegration;
use Jeremias\WcLicensedProduct\Checkout\CheckoutController;
use Jeremias\WcLicensedProduct\Checkout\StoreApiExtension;
use Jeremias\WcLicensedProduct\Email\LicenseEmailController;
use Jeremias\WcLicensedProduct\Frontend\AccountController;
use Jeremias\WcLicensedProduct\Frontend\DownloadController;
@@ -110,6 +112,8 @@ final class Plugin
// Initialize controllers
new LicensedProductType();
new CheckoutController($this->licenseManager);
new StoreApiExtension($this->licenseManager);
$this->registerCheckoutBlocksIntegration();
$this->downloadController = new DownloadController($this->licenseManager, $this->versionManager);
new AccountController($this->twig, $this->licenseManager, $this->versionManager, $this->downloadController);
new RestApiController($this->licenseManager);
@@ -122,13 +126,34 @@ final class Plugin
}
}
/**
* Register WooCommerce Checkout Blocks integration
*/
private function registerCheckoutBlocksIntegration(): void
{
add_action('woocommerce_blocks_loaded', function (): void {
if (class_exists('Automattic\WooCommerce\Blocks\Integrations\IntegrationRegistry')) {
add_action(
'woocommerce_blocks_checkout_block_registration',
function ($integration_registry): void {
$integration_registry->register(new CheckoutBlocksIntegration());
}
);
}
});
}
/**
* Register plugin hooks
*/
private function registerHooks(): void
{
// Generate license on order completion
// Generate license on order completion (multiple hooks for compatibility)
add_action('woocommerce_order_status_completed', [$this, 'onOrderCompleted']);
add_action('woocommerce_order_status_processing', [$this, 'onOrderCompleted']);
// Also hook into payment complete for immediate license generation
add_action('woocommerce_payment_complete', [$this, 'onOrderCompleted']);
}
/**