Skip to content

[6.x] Remove trigger JavaScript from the Create sale and Set default variant actions - #4445

Draft
brianjhanson wants to merge 1 commit into
6.xfrom
chore/remove-element-action-trigger-html
Draft

brianjhanson wants to merge 1 commit into
6.xfrom
chore/remove-element-action-trigger-html

Conversation

@brianjhanson

Copy link
Copy Markdown

Description

Companion to craftcms/cms#20592, which removes getTriggerHtml() from core element actions. Two Commerce actions overrode it to write trigger JavaScript.

CreateSale
  before: getTriggerHtml() → JS that redirects to sales/new?purchasableIds=…
  after:  performAction()  → RedirectResponse(sales/new?purchasableIds=…)   (same as CreateDiscount)

SetDefaultVariant
  before: getTriggerHtml() → JS creating a trigger with bulk: false
  after:  removed; supportsBulk() === false already limits it to one selection

Evidence

  • New test in tests/Feature/Http/Controllers/ProductIndexTest.php:
    perform CreateSale on [hoodie]
      → 200, json.redirect === cp/commerce/store-management/{store}/sales/new?purchasableIds={hoodie.id}
    
  • Full suite (1,003 passed), ECS and PHPStan pass locally against current 6.x CMS.

Nothing here depends on the CMS PR, so it can merge first.

🤖 Generated with Claude Code

…ariant actions

Craft 6 no longer gives element actions a getTriggerHtml() method; the legacy
element index's triggers are provided by the Yii2 adapter.

Create sale now redirects from performAction(), like Create discount does, so
both element indexes send the selected purchasables to a new sale. Set default
variant's trigger only limited it to one element, which supportsBulk() already
does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant