Last active
June 4, 2025 05:41
-
-
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: 'plugin-renewal', | |
plugin: p.moduleId, | |
licenseId: p.licenseId, | |
edition: p.edition, | |
}) | |
|values | |
%} | |
{% set cmsLicense = craft.app.getEditionHandle !== 'solo' ? { | |
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 #} | |
<p style="font-size:x-large;font-family:system-ui,sans-serif;padding:1em;"> | |
<a href={{ pluginStoreUrl }}> | |
Renew {{ purchases|length }} Licenses via Craft Console → | |
</a> | |
</p> | |
<pre style="margin:1em;padding:1em;background:#EEE;"> | |
{{- purchases|json_encode(constant('JSON_PRETTY_PRINT')) -}} | |
</pre> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment