Instead of accessing an Offer directly through its id, you can also generate single use codes that are tied back to the offer.
When using offer codes, the offer is no longer able to be redeemed through its underlying id. That is, either an offer is global (and anyone with its id can claim it subject to timing and redemption limits), or an offer can be redeemed via single-use codes.
As soon as one code is generated for an offer, the require_code
flag on the offer will be set to true
and its id
disallowed for redemption.
Further, if you generate codes for an offer, the max_redemptions
attribute will be ignored. The offer's timing attributes (e.g., starts_at
and ends_at
) will still be considered, as will the code's enabled
attribute, but a valid code for an active offer will work in a redemption flow, no matter the value set for max_redemptions
.