Skip to main content

benecaster_buyup_definition_updated

Action Premium Since v1.0.0

Fires after a buy-up definition is updated. Receives both the new record and the record as it was before the write, which makes it possible to act on what actually changed rather than re-syncing the whole object on every save.

Parameters

Name Type Default Description
$buyup_id int ID of the updated buy-up definition.
$buyup array The buy-up record after the update.
$current array The buy-up record as it was before the update.

Examples

React only when the price changed

add_action( 'benecaster_buyup_definition_updated', function ( int $id, array $buyup, array $current ): void {
    if ( ( $buyup['price_cents'] ?? null ) === ( $current['price_cents'] ?? null ) ) {
        return;
    }
    my_catalogue_reprice( $id, $buyup['price_cents'] ?? 0 );
}, 10, 3 );

Notes

Stripe prices are immutable — a price change provisions a new Stripe price rather than editing the existing one, and subscribers who already purchased keep the price they bought at.