Last active
May 21, 2026 11:18
-
-
Save rungta/42d53285171a65e60bdaaa1a8e3b6f64 to your computer and use it in GitHub Desktop.
Create a new Craft Console cart with all licenses from a Craft CMS project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {# | |
| renew-craft-licenses.twig | |
| Create a new Craft Console cart with all licenses from a Craft CMS project | |
| #} | |
| {# Biz Logic #} | |
| {% set paidPlugins = craft.app.plugins.allPluginInfo | |
| |where('isInstalled', true) | |
| |where('isEnabled', true) | |
| |where('licenseId', true) | |
| |map(p => { | |
| type: p.isTrial ? 'plugin-edition' : 'plugin-renewal', | |
| plugin: p.moduleId, | |
| licenseId: p.licenseId, | |
| edition: p.edition, | |
| }) | |
| |values | |
| %} | |
| {% set cmsLicenseIsPerpetual = not craft.app.api.licenseInfo.expirable %} | |
| {% set cmsLicense = craft.app.getEditionHandle !== 'solo' and not cmsLicenseIsPerpetual ? { | |
| type: 'cms-renewal', | |
| edition: craft.app.getEditionHandle, | |
| licenseId: craft.app.api.licenseInfo.id, | |
| } %} | |
| {% set purchases = [cmsLicense] | |
| |merge(paidPlugins) | |
| |filter | |
| |values | |
| %} | |
| {% set pluginStoreUrl = url( | |
| 'https://console.craftcms.com/cart/new', | |
| { items: purchases } | |
| ) %} | |
| {# Render #} | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Craft Licenses</title> | |
| <script src="https://unpkg.com/@tailwindcss/browser@4"></script> | |
| </head> | |
| <body class="p-8 space-y-6"> | |
| <h1 class="text-3xl"> | |
| <a class="bg-red-600 text-white p-3 rounded shadow inline-block" href="{{ pluginStoreUrl }}" target="_blank"> | |
| Renew {{ purchases|length }} Licenses via Craft Console → | |
| </a> | |
| </h1> | |
| {% if cmsLicenseIsPerpetual %} | |
| <p>Craft is on a perpetual license.</p> | |
| {% endif %} | |
| <pre class="p-4 bg-gray-200"> | |
| {{- purchases|json_encode(constant('JSON_PRETTY_PRINT')) -}} | |
| </pre> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment