Skip to content

Instantly share code, notes, and snippets.

@rungta
Last active June 4, 2025 05:41
Show Gist options
  • Save rungta/42d53285171a65e60bdaaa1a8e3b6f64 to your computer and use it in GitHub Desktop.
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
{#
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 &rarr;
</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