1. Go to this page and download the library: Download craftcms/digital-products library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
craftcms / digital-products example snippets
use craft\digitalproducts\events\ProductTypeEvent;
use craft\digitalproducts\services\ProductTypes;
use yii\base\Event;
// ...
Event::on(
ProductTypes::class,
ProductTypes::EVENT_BEFORE_SAVE_PRODUCTTYPE,
function(ProductTypeEvent $e) {
// Custom code to be executed when a product type is saved
}
);
use craft\digitalproducts\elements\License;
use craft\digitalproducts\events\GenerateKeyEvent;
use craft\digitalproducts\Plugin as DigitalProducts;
use yii\base\Event;
// ...
Event::on(
License::class,
License::EVENT_GENERATE_LICENSE_KEY,
function(GenerateKeyEvent $e) {
$licenseService = DigitalProducts::getInstance()->getLicenses();
do {
$licenseKey = // custom key generation logic...
} while (!$licenseService->isLicenseKeyUnique($licenseKey));
$e->licenseKey = $licenseKey;
}
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.