Skip to content

Order Model Pro

The Order model manages financial records for bookings. It tracks payment status, totals, and currency for paid appointments.

Attributes

AttributeTypeDescription
idbigintPrimary key
statusvarchardraft, pending, completed, failed, refunded, cancelled
parent_idbigintAssociated booking ID
order_numbervarcharUnique order display/reference number
typevarcharOrder type — sale, refund, subscription (default sale)
customer_idbigintWordPress User ID of the customer
payment_methodvarcharPayment gateway key (e.g., stripe, paypal, offline)
payment_modevarcharPayment environment — test / live
payment_method_typevarcharFurther method details (e.g., card, bank_transfer)
payment_method_titlevarcharHuman-readable payment method label
currencyvarcharISO currency code (e.g., USD, EUR)
subtotaldecimalAmount before taxes and discounts
discount_taxdecimalDiscount tax amount
discount_totaldecimalDiscount pre-tax
shipping_taxdecimalShipping tax
shipping_totaldecimalShipping cost
tax_totaldecimalTotal tax amount
total_amountdecimalFinal order total (after all fees/discounts)
total_paiddecimalAmount collected so far
ratedecimalConversion rate if multi-currency (default 1)
notetextOrder notes
ip_addresstextCustomer's IP address
completed_atdatetimePayment completion time (nullable)
refunded_atdatetimeRefund processing time (nullable)
uuidvarcharPublic unique identifier
created_attimestampRecord creation time
updated_attimestampRecord last update time

Relations

booking

Belongs to the parent Booking (via parent_id).

transaction

Has one Transaction record detailing the payment gateway hit.

items

Has many OrderItems line items representing the booking fee and any addons (excludes items where type is discount).

discounts

Has many OrderItems line items representing applied discounts (where type is discount).

Usage Examples

Checking if an order is fully paid

php
use FluentBookingPro\App\Models\Order;

$order = Order::where('order_number', 'FB-12345')->first();

if ($order->total_paid >= $order->total_amount) {
    echo "Payment Complete";
}
php
$booking = $order->booking;
echo "Booking for: " . $booking->first_name;