pub struct Cart {Show 37 fields
pub id: CartId,
pub cart_number: String,
pub customer_id: Option<CustomerId>,
pub status: CartStatus,
pub currency: CurrencyCode,
pub items: Vec<CartItem>,
pub subtotal: Decimal,
pub tax_amount: Decimal,
pub shipping_amount: Decimal,
pub discount_amount: Decimal,
pub grand_total: Decimal,
pub customer_email: Option<String>,
pub customer_phone: Option<String>,
pub customer_name: Option<String>,
pub shipping_address: Option<CartAddress>,
pub billing_address: Option<CartAddress>,
pub billing_same_as_shipping: bool,
pub fulfillment_type: Option<FulfillmentType>,
pub shipping_method: Option<String>,
pub shipping_carrier: Option<String>,
pub estimated_delivery: Option<DateTime<Utc>>,
pub payment_method: Option<String>,
pub payment_token: Option<String>,
pub payment_status: CartPaymentStatus,
pub coupon_code: Option<String>,
pub discount_description: Option<String>,
pub order_id: Option<OrderId>,
pub order_number: Option<String>,
pub notes: Option<String>,
pub metadata: Option<Value>,
pub inventory_reserved: bool,
pub reservation_expires_at: Option<DateTime<Utc>>,
pub x402_payment: Option<CartX402Payment>,
pub expires_at: Option<DateTime<Utc>>,
pub completed_at: Option<DateTime<Utc>>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}Expand description
Cart/Checkout Session aggregate
Fields§
§id: CartId§cart_number: String§customer_id: Option<CustomerId>§status: CartStatus§currency: CurrencyCode§items: Vec<CartItem>§subtotal: Decimal§tax_amount: Decimal§shipping_amount: Decimal§discount_amount: Decimal§grand_total: Decimal§customer_email: Option<String>§customer_phone: Option<String>§customer_name: Option<String>§shipping_address: Option<CartAddress>§billing_address: Option<CartAddress>§billing_same_as_shipping: bool§fulfillment_type: Option<FulfillmentType>§shipping_method: Option<String>§shipping_carrier: Option<String>§estimated_delivery: Option<DateTime<Utc>>§payment_method: Option<String>§payment_token: Option<String>§payment_status: CartPaymentStatus§coupon_code: Option<String>§discount_description: Option<String>§order_id: Option<OrderId>§order_number: Option<String>§notes: Option<String>§metadata: Option<Value>§inventory_reserved: bool§reservation_expires_at: Option<DateTime<Utc>>§x402_payment: Option<CartX402Payment>§expires_at: Option<DateTime<Utc>>§completed_at: Option<DateTime<Utc>>§created_at: DateTime<Utc>§updated_at: DateTime<Utc>Implementations§
Source§impl Cart
impl Cart
Sourcepub fn item_count(&self) -> i32
pub fn item_count(&self) -> i32
Get total item count
Sourcepub fn requires_shipping(&self) -> bool
pub fn requires_shipping(&self) -> bool
Check if cart requires shipping
Sourcepub const fn is_checkoutable_status(&self) -> bool
pub const fn is_checkoutable_status(&self) -> bool
Check if the cart’s lifecycle status permits it to be checked out into an order.
A cart in a terminal/non-checkoutable state (CartStatus::Cancelled,
CartStatus::Abandoned, or CartStatus::Expired) can never be
completed into a real order. CartStatus::Completed is excluded here
too — completion of an already-completed cart is handled separately as an
idempotent short-circuit, not via this readiness check.
Sourcepub fn is_ready_for_checkout(&self) -> bool
pub fn is_ready_for_checkout(&self) -> bool
Check if cart is ready for checkout
Sourcepub const fn can_modify(&self) -> bool
pub const fn can_modify(&self) -> bool
Check if cart can be modified
Sourcepub const fn can_complete(&self) -> bool
pub const fn can_complete(&self) -> bool
Check if cart can be completed
Sourcepub const fn can_cancel(&self) -> bool
pub const fn can_cancel(&self) -> bool
Check if cart can be cancelled
Sourcepub fn is_abandoned(&self) -> bool
pub fn is_abandoned(&self) -> bool
Check if cart is abandoned
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if cart is expired
Sourcepub fn recalculate_totals(&mut self)
pub fn recalculate_totals(&mut self)
Recalculate totals from items
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Cart
impl<'de> Deserialize<'de> for Cart
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Cart, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Cart, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Cart
Source§impl Serialize for Cart
impl Serialize for Cart
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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
impl StructuralPartialEq for Cart
Auto Trait Implementations§
impl Freeze for Cart
impl RefUnwindSafe for Cart
impl Send for Cart
impl Sync for Cart
impl Unpin for Cart
impl UnsafeUnpin for Cart
impl UnwindSafe for Cart
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more