Skip to content

Instantly share code, notes, and snippets.

@rungta
Last active May 21, 2026 11:18
Show Gist options
  • Select an option

  • Save rungta/42d53285171a65e60bdaaa1a8e3b6f64 to your computer and use it in GitHub Desktop.

Select an option

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: 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 &rarr;
</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