Skip to main content

Promotion

Struct Promotion 

Source
pub struct Promotion {
Show 37 fields pub id: PromotionId, pub code: String, pub name: String, pub description: Option<String>, pub internal_notes: Option<String>, pub promotion_type: PromotionType, pub trigger: PromotionTrigger, pub target: PromotionTarget, pub stacking: StackingBehavior, pub status: PromotionStatus, pub percentage_off: Option<Decimal>, pub fixed_amount_off: Option<Decimal>, pub max_discount_amount: Option<Decimal>, pub buy_quantity: Option<i32>, pub get_quantity: Option<i32>, pub get_discount_percent: Option<Decimal>, pub tiers: Option<Vec<DiscountTier>>, pub bundle_product_ids: Option<Vec<ProductId>>, pub bundle_discount: Option<Decimal>, pub starts_at: DateTime<Utc>, pub ends_at: Option<DateTime<Utc>>, pub total_usage_limit: Option<i32>, pub per_customer_limit: Option<i32>, pub usage_count: i32, pub conditions: Vec<PromotionCondition>, pub applicable_product_ids: Vec<ProductId>, pub applicable_category_ids: Vec<Uuid>, pub applicable_skus: Vec<String>, pub excluded_product_ids: Vec<ProductId>, pub excluded_category_ids: Vec<Uuid>, pub eligible_customer_ids: Vec<CustomerId>, pub eligible_customer_groups: Vec<String>, pub currency: CurrencyCode, pub priority: i32, pub metadata: Option<Value>, pub created_at: DateTime<Utc>, pub updated_at: DateTime<Utc>,
}
Expand description

A promotion/discount offer

Fields§

§id: PromotionId§code: String

Unique code for the promotion (for internal reference)

§name: String

Display name

§description: Option<String>

Description for customers

§internal_notes: Option<String>

Internal notes

§promotion_type: PromotionType§trigger: PromotionTrigger§target: PromotionTarget§stacking: StackingBehavior§status: PromotionStatus§percentage_off: Option<Decimal>

Percentage off (0.0-1.0, e.g., 0.20 for 20%)

§fixed_amount_off: Option<Decimal>

Fixed amount off

§max_discount_amount: Option<Decimal>

Maximum discount amount (cap)

§buy_quantity: Option<i32>

Quantity to buy

§get_quantity: Option<i32>

Quantity to get free/discounted

§get_discount_percent: Option<Decimal>

Discount on the “get” items (1.0 = free, 0.5 = 50% off)

§tiers: Option<Vec<DiscountTier>>

Tiered discount rules (JSON array of tiers)

§bundle_product_ids: Option<Vec<ProductId>>

Required product IDs for bundle

§bundle_discount: Option<Decimal>

Bundle discount when all products purchased

§starts_at: DateTime<Utc>§ends_at: Option<DateTime<Utc>>§total_usage_limit: Option<i32>

Total uses allowed (None = unlimited)

§per_customer_limit: Option<i32>

Uses per customer (None = unlimited)

§usage_count: i32

Current usage count

§conditions: Vec<PromotionCondition>§applicable_product_ids: Vec<ProductId>

Specific product IDs this applies to (empty = all)

§applicable_category_ids: Vec<Uuid>

Specific category IDs this applies to (empty = all)

§applicable_skus: Vec<String>

Specific SKUs this applies to (empty = all)

§excluded_product_ids: Vec<ProductId>

Excluded product IDs

§excluded_category_ids: Vec<Uuid>

Excluded category IDs

§eligible_customer_ids: Vec<CustomerId>

Specific customer IDs (empty = all customers)

§eligible_customer_groups: Vec<String>

Customer groups/segments

§currency: CurrencyCode§priority: i32§metadata: Option<Value>§created_at: DateTime<Utc>§updated_at: DateTime<Utc>

Implementations§

Source§

impl Promotion

Source

pub fn has_product_scoping(&self) -> bool

Whether this promotion restricts which products it applies to (any applicability or exclusion list is non-empty).

Source

pub fn item_in_scope(&self, item: &PromotionLineItem) -> bool

Whether a line item is in scope for this promotion’s product lists.

Exclusions win over applicability. When any applicability list is set, the item must match at least one of them; otherwise every non-excluded item is in scope.

Source

pub fn is_active(&self) -> bool

Check if promotion is currently active

Source

pub fn discount_description(&self) -> String

Get human-readable discount description

Trait Implementations§

Source§

impl Clone for Promotion

Source§

fn clone(&self) -> Promotion

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Promotion

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Promotion

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Promotion, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Promotion

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit #126799)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more