Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
The current_usage field won't cut it, cause we'll need to track per-user usage as well in the future.
We need to remove that field and implement a custom service with custom storage, which keeps track of the promotion_id, order_id, additional_id (i.e coupon code), uid.
We also need to figure out whether we'll track usage for anonymous users or not (if yes, we need to find the most stable id: IP address like flood, or session id? Probably the session id).
Methods would be something like register() and check().
Comments
Comment #2
mglamanI'll be working on something like this, so claiming ticket for a while.
Comment #3
mglamanIf we track orders by session ID, I'd say we need to track by that here as well.
Comment #4
mglamanI just realized this is inherently impossible because the offer plugin applies the adjustment,not the promotion. So the source ID is wrong.
Comment #5
bojanz CreditAttribution: bojanz at Centarro commentedThe adjustment should be pointing to the promotion, that's a bug.
Comment #6
mglamanYep, new code is on https://github.com/drupalcommerce/commerce/pull/695. Fixes that, slowly getting my test to pass.
Comment #7
mglamanPR at https://github.com/drupalcommerce/commerce/pull/695 should have passing tests. All kernel tests passed locally for promotions. Letting Travis do the rest.
Comment #8
bojanz CreditAttribution: bojanz at Centarro commentedWrapping this up.
Comment #10
bojanz CreditAttribution: bojanz at Centarro commentedFinal version committed.
We implemented usage tracking for anonymous customers and made both anon and authenticated customers tracked by email.
Will need a followup to update usage if the user changes their email.
Comment #11
Utilvideo CreditAttribution: Utilvideo commentedDocumentation for API ?:)
Comment #12
bojanz CreditAttribution: bojanz at Centarro commented@Regnoy
What are you trying to do?
This is an internal API meant to be used by other parts of the Promotion module, it's not meant to be consumed by developers (other than perhaps getting current usage for display purpose). The code is the documentation.