Skip to content

2.20.0

Choose a tag to compare

@goldnead goldnead released this 24 Sep 07:57
· 218 commits to main since this release

Upgrading

  • No migration, no new required config key.
  • Behaviour change for multi-brand sites: flows started by a sibling addon's event now run in
    the brand the event carries, not in whichever brand happened to be current (see Changed). A
    flow that only ever fired because a webhook fell back to the default brand now fires in the
    brand of the subscription or payment instead. Check which brand your payment, entitlement,
    booking and invoice flows belong to.
  • The new triggers appear once the addon that fires them is installed and new enough:
    statamic-payments 1.25, statamic-courses 0.2, statamic-affiliates 0.1, statamic-funnels 1.17.
    The offer and pricing-option filters read statamic-offers 1.12 where it is installed.

Added: triggers for the new subscription, course, partner and funnel events

payments, courses, affiliates and funnels fire events that could not be found in the editor.
Each now has a trigger, built like the existing payments.* ones: coupled only through
class_exists and the IntegrationDetector, flat fields in the context for mails and
conditions, filters on the trigger.

  • [new] payments (11): payments.subscription_paused, …_resumed, …_payment_upcoming,
    …_card_expiring, …_card_expired, …_attempt_failed (filter "Only failure number"),
    …_plan_completed, …_changed (filter upgrade/downgrade), …_replaced (filter on the
    replaced product), payments.checkout_blocked (filter reason), payments.charged_back. The
    subscription in the context also carries paused_at and resumes_at. Not wired:
    SubscriptionCycleFailed (fires per delivery; …_attempt_failed covers it once per failure)
    and PaymentCommunicationLogged.
  • [new] courses (12): courses.learner_enrolled, …lesson_completed, …lesson_unlocked,
    …quiz_passed, …quiz_failed, …course_completed, …drip_paused, …drip_resumed,
    …access_suspended, …access_restored, …team_member_added, …team_member_removed. The
    events carry only ids; the trigger looks the person up and puts them under user (id, email,
    name), the course under course with its title. user.email is therefore the subject of the
    run, and "only once per person" works without a setting. For team seats the member is the
    subject (member.email), the buyer is under owner. Filters: course (entry id or slug), for
    lessons also the lesson slug.
  • [new] affiliates (4): affiliates.commission_earned and …commission_reversed, both with the
    filter "Kind" (sale, recurring payment, order bump, upsell, joint venture);
    affiliates.partner_applied, …partner_approved. Partner with address and code in the context,
    payout details deliberately not. A reversal of a commission that was already paid out arrives
    as a claw-back row of kind clawback, which the filter does not offer: leave "Kind" empty on
    commission_reversed to hear those too.
  • [new] funnels (2): funnels.offer_declined on FunnelOfferDeclined, on every no. Filters funnel,
    step and offer; step.offer names the declined offer. funnels.upsell_declined on
    UpsellDeclined (statamic-funnels 1.17): only a no after a purchase was already paid in the
    same walk. The purchase before it is under payment, with an extra filter "Bought offer"
    (whatever the pricing option). Both fire on the same click; to follow up only with buyers, use
    the second.

Added: filter by offer and pricing option on the purchase triggers

Every payments trigger with a product has two new fields next to Product. Offer matches every
purchase through an offer, whatever the pricing option or a freely chosen amount (offer:kurs,
offer:kurs:raten3, offer:kurs:=2500). Pricing option matches exactly one pricing option
(offer:kurs:raten3). Product stays exact, so saved flows with offer:kurs do not suddenly
fire on the instalment plan too. Handles are parsed with OfferHandle::parse() from
statamic-offers when it is there, otherwise with the same rule here. New option sources
offers.offers, offers.pricing_options (narrowed to the brand) and courses.courses.

Changed: the brand comes from the event, not from chance

Until now the listeners for the sibling addons looked for flows only in the brand that happened to
be current. A command like payments:reminders has none, so its reminders started nothing; a
webhook falls back to the default brand, so flows of the wrong brand started there, with the wrong
sender. That held for the older payments.*, entitlements.*, booking.* and invoices.*
triggers too.

Now Support\EventBrand reads the brand from the event: first an explicit brandId
(statamic-courses 0.2 carries it on every event), then brand_id on the subscription, payment,
partner, commission or grant, and for course events without either the site of the course entry
through brand-context.sites. Lookup and dispatch run inside brand-context->runFor(); the
request's brand is unchanged afterwards. Without a brand in the event the current one applies; if
none is set either, a warning is logged instead of nothing. The same for a brand that does not
exist. Without multi_brand nothing changes.

Changed: German node library, and smaller changes

  • German in the node library. Label, description and group of every payments, funnels,
    courses and affiliates trigger come from resources/lang/de/triggers.php, ordered by handle and
    in the addon's namespace, so "Courses" or "Quiz Passed" are not translated along in other
    addons. The library's search finds "abo" that way.
  • Triggers that fire at the same moment say so in their description: offer_declined and
    upsell_declined, subscription_ended and subscription_plan_completed.
  • payments.checkout_blocked: no full IP address in the context any more, only the network
    (blocked.ip_prefix, /24 or /48). The description warns against mailing blocked.email.
  • Course triggers for a person who cannot be found (deleted) do not start with an empty subject;
    they are skipped with a warning in the log. Team seats go on, there the member is the subject by
    address.
  • courses.courses uses CourseProgress::courses($brandId) with the current brand where it
    exists (the brand's courses and those without a brand).

IntegrationDetector knows courses, affiliates and offers for this (key
automations.integrations.<name>.detect, like the others).