Order & OrderItem Reference for Twig Templates
This guide shows how to use Order and OrderItem objects in your Twig templates to display order information, customer details, and product listings.
Available Order Attributes
Basic Order Properties
order.id
- Order ID numberorder.siparis_no
- Order number (e.g., "ORD-2024-001234")order.tarih
- Full order date and timeorder.short_date
- Short date format (d/m/y)order.durum
- Order status number (0=pending, 1=active, 2=passive, 3=cancelled, 4=completed)order.status_text
- Order status as text (e.g., "Active", "Completed")order.order_status_type_name
- Detailed status name (e.g., "Processing", "Shipped")
Customer Information
order.firma
- Company nameorder.telefon
- Phone numberorder.email_address
- Customer emailorder.adres
- Delivery addressorder.sehir
- Cityorder.ilce
- Districtorder.user
- Customer user objectorder.user.name
- Customer nameorder.user.bayi_kod
- Customer code
Financial Information
order.toplam_tutar
- Total amount (number)order.amount_text
- Total amount with currency symbolorder.currency
- Currency code (e.g., "TRY")order.currency_symbol
- Currency symbol (e.g., "₺")order.entered_amount
- Entered amountorder.entered_amount_text
- Entered amount with currencyorder.shipment_cost
- Shipping cost amountorder.shipment_amount_text
- Shipping cost with currencyorder.refund_amount
- Refund amount
Order Content
order.items
- Array of order itemsorder.order_item_count
- Number of items in orderorder.urun_toplam
- Total quantity of all productsorder.urun_cesit
- Number of different productsorder.order_data
- Order data as JSON object
Payment Details
order.odeme_tur
- Payment methodorder.taksit
- Number of installmentsorder.iskonto
- Discount percentageorder.banka
- Bank name
Administrative
order.yetkili
- Authorized personorder.onay_tarih
- Approval dateorder.onay_not
- Approval notesorder.created_at
- Creation timestamporder.updated_at
- Last update timestamporder.status_changed_at
- Status change timestamporder.detail_link
- Frontend detail page URLorder.admin_url
- Admin panel URL
Relationships
order.seller
- Seller user object (if applicable)order.shipment
- Shipment information object
Available OrderItem Attributes
Basic Item Properties
item.id
- Item IDitem.urun_id
- Product IDitem.adet
- Quantity ordereditem.qty
- Quantity (alias for adet)item.durum
- Item statusitem.urun_kod
- Product code/SKU
Product Information
item.product
- Product objectitem.product_name
- Product nameitem.kategori_isim
- Category nameitem.product.title
- Full product titleitem.product.sku
- Product SKUitem.product.brand_name
- Brand name
Variant Information
item.sepet_renk
- Variant name/coloritem.variant_name
- Variant name (formatted)item.sepet_renk_dosya
- Variant image filenameitem.sepet_beden
- Size information
Pricing
item.buy_price
- Purchase price per unititem.buy_amount
- Total purchase amountitem.price
- Current price per unititem.price_format
- Formatted price with currencyitem.total_amount
- Total amount (quantity × price)item.currency
- Currency code
Images
item.image
- Product image URLitem.med_image
- Medium size image URL
Quantities and Measurements
item.base_qty
- Base quantity in main measurement unititem.shipped_qty
- Already shipped quantityitem.awaiting_shipment_qty
- Quantity awaiting shipmentitem.package_count
- Number of packagesitem.package_qty
- Quantity per packageitem.measure_id
- Measurement unit ID
Item Status
item.product_id
- Product ID as stringitem.variant_id
- Variant identifier
Order Object
The Order object contains all information about a customer's order including customer details, order status, pricing, and order items.
Basic Order Information
<!-- Order ID and Number -->
<h2>Order #{{ order.siparis_no }}</h2>
<p>Order ID: {{ order.id }}</p>
<!-- Order Date -->
<p>Order Date: {{ order.short_date }}</p>
<p>Full Date: {{ order.tarih }}</p>
<!-- Order Status -->
<p>Status: {{ order.status_text }}</p>
<p>Status Type: {{ order.order_status_type_name }}</p>
Customer Information
<!-- Company and Contact Details -->
<h3>Customer Information</h3>
<p>Company: {{ order.firma }}</p>
<p>Phone: {{ order.telefon }}</p>
<p>Email: {{ order.email_address }}</p>
<!-- Customer Name -->
<p>Customer: {{ order.user.name }}</p>
<p>Customer Code: {{ order.user.bayi_kod }}</p>
<!-- Delivery Address -->
<address>
{{ order.adres }}
<br>{{ order.ilce }}, {{ order.sehir }}
</address>
Order Totals and Pricing
<!-- Order Summary -->
<div class="order-summary">
<p>Total Amount: {{ order.amount_text }}</p>
<p>Currency: {{ order.currency_symbol }}</p>
<!-- Product Counts -->
<p>Total Items: {{ order.order_item_count }}</p>
<p>Total Quantity: {{ order.urun_toplam }}</p>
<p>Different Products: {{ order.urun_cesit }}</p>
<!-- Additional Costs -->
{% if order.shipment_cost > 0 %}
<p>Shipping Cost: {{ order.shipment_amount_text }}</p>
{% endif %}
{% if order.refund_amount > 0 %}
<p>Refund Amount: {{ order.refund_amount }} {{ order.currency_symbol }}</p>
{% endif %}
</div>
Payment Information
<!-- Payment Details -->
<div class="payment-info">
<p>Payment Method: {{ order.odeme_tur }}</p>
{% if order.taksit > 1 %}
<p>Installments: {{ order.taksit }}</p>
{% endif %}
{% if order.iskonto > 0 %}
<p>Discount: {{ order.iskonto }}%</p>
{% endif %}
{% if order.banka %}
<p>Bank: {{ order.banka }}</p>
{% endif %}
</div>
Order Actions and Links
<!-- Order Links -->
<a href="{{ order.detail_link }}" class="btn btn-primary">View Order Details</a>
<a href="{{ order.admin_url }}" class="btn btn-secondary">Admin Panel</a>
<!-- Order Status Checks -->
{% if order.durum == 1 %}
<span class="badge badge-success">Active Order</span>
{% elseif order.durum == 4 %}
<span class="badge badge-info">Completed</span>
{% elseif order.durum == 3 %}
<span class="badge badge-danger">Cancelled</span>
{% endif %}
Order Items
Displaying Order Items List
<!-- Order Items Table -->
<table class="table order-items">
<thead>
<tr>
<th>Product</th>
<th>Image</th>
<th>Variant</th>
<th>Quantity</th>
<th>Price</th>
<th>Total</th>
</tr>
</thead>
<tbody>
{% for item in order.items %}
<tr>
<td>
<strong>{{ item.product_name }}</strong>
<br>
<small>Code: {{ item.urun_kod }}</small>
</td>
<td>
<img src="{{ item.image }}" alt="{{ item.product_name }}" class="product-thumb">
</td>
<td>
{% if item.variant_name %}
<span class="variant">{{ item.variant_name }}</span>
{% endif %}
{% if item.sepet_beden %}
<span class="size">Size: {{ item.sepet_beden }}</span>
{% endif %}
</td>
<td>{{ item.qty }}</td>
<td>{{ item.price_format }}</td>
<td>{{ item.total_amount }} {{ item.currency }}</td>
</tr>
{% endfor %}
</tbody>
</table>
Individual Item Details
{% for item in order.items %}
<div class="order-item">
<!-- Product Image -->
<div class="item-image">
<img src="{{ item.med_image }}" alt="{{ item.product_name }}">
</div>
<!-- Product Information -->
<div class="item-details">
<h4>{{ item.product_name }}</h4>
<p>Product Code: {{ item.urun_kod }}</p>
<p>Category: {{ item.kategori_isim }}</p>
<!-- Product Link -->
<a href="{{ item.product.detail_link }}">View Product</a>
</div>
<!-- Variant Information -->
{% if item.variant_name or item.sepet_beden %}
<div class="item-variant">
{% if item.variant_name %}
<span class="variant-color">{{ item.variant_name }}</span>
{% endif %}
{% if item.sepet_beden %}
<span class="variant-size">{{ item.sepet_beden }}</span>
{% endif %}
</div>
{% endif %}
<!-- Quantity and Pricing -->
<div class="item-pricing">
<p>Quantity: {{ item.adet }}</p>
<p>Unit Price: {{ item.price_format }}</p>
<p><strong>Total: {{ item.total_amount }} {{ item.currency }}</strong></p>
</div>
<!-- Shipping Information -->
{% if item.shipped_qty > 0 %}
<div class="shipping-info">
<p>Shipped: {{ item.shipped_qty }}</p>
<p>Awaiting Shipment: {{ item.awaiting_shipment_qty }}</p>
</div>
{% endif %}
</div>
{% endfor %}
Order Status Display
Status Badge Component
<!-- Status Badge -->
{% set status_class = '' %}
{% if order.durum == 0 %}
{% set status_class = 'badge-warning' %}
{% elseif order.durum == 1 %}
{% set status_class = 'badge-success' %}
{% elseif order.durum == 2 %}
{% set status_class = 'badge-secondary' %}
{% elseif order.durum == 3 %}
{% set status_class = 'badge-danger' %}
{% elseif order.durum == 4 %}
{% set status_class = 'badge-info' %}
{% endif %}
<span class="badge {{ status_class }}">{{ order.status_text }}</span>
Status Timeline
<!-- Order Status Timeline -->
<div class="order-timeline">
<div class="timeline-item">
<strong>Order Created:</strong> {{ order.tarih }}
</div>
{% if order.onay_tarih %}
<div class="timeline-item">
<strong>Order Approved:</strong> {{ order.onay_tarih }}
{% if order.onay_not %}
<br><em>Note: {{ order.onay_not }}</em>
{% endif %}
</div>
{% endif %}
{% if order.status_changed_at %}
<div class="timeline-item">
<strong>Status Changed:</strong> {{ order.status_changed_at }}
</div>
{% endif %}
</div>
Order Summary Components
Order Card Component
<!-- Order Summary Card -->
<div class="order-card">
<div class="order-header">
<h3>Order #{{ order.siparis_no }}</h3>
<span class="order-date">{{ order.short_date }}</span>
</div>
<div class="order-body">
<div class="customer-info">
<strong>{{ order.firma }}</strong>
<br>{{ order.user.name }}
</div>
<div class="order-stats">
<span class="stat">{{ order.order_item_count }} items</span>
<span class="stat">{{ order.urun_toplam }} qty</span>
</div>
<div class="order-total">
<strong>{{ order.amount_text }}</strong>
</div>
</div>
<div class="order-footer">
<span class="badge {{ status_class }}">{{ order.status_text }}</span>
<a href="{{ order.detail_link }}" class="btn btn-sm btn-outline-primary">View Details</a>
</div>
</div>
Mobile Order List
<!-- Mobile-Friendly Order List -->
<div class="order-list-mobile">
{% for order in orders %}
<div class="order-item-mobile">
<div class="order-main">
<div class="order-number">#{{ order.siparis_no }}</div>
<div class="order-date">{{ order.short_date }}</div>
</div>
<div class="order-details">
<div class="customer">{{ order.firma }}</div>
<div class="amount">{{ order.amount_text }}</div>
</div>
<div class="order-status">
<span class="badge {{ status_class }}">{{ order.status_text }}</span>
</div>
</div>
{% endfor %}
</div>
Product Display in Orders
Product Grid in Order
<!-- Product Grid for Order Items -->
<div class="order-products-grid">
{% for item in order.items %}
<div class="product-card">
<div class="product-image">
<img src="{{ item.image }}" alt="{{ item.product_name }}">
{% if item.qty > 1 %}
<span class="quantity-badge">{{ item.qty }}</span>
{% endif %}
</div>
<div class="product-info">
<h5>{{ item.product_name }}</h5>
<p class="product-code">{{ item.urun_kod }}</p>
{% if item.variant_name %}
<p class="variant">{{ item.variant_name }}</p>
{% endif %}
<p class="price">{{ item.price_format }}</p>
</div>
</div>
{% endfor %}
</div>
Conditional Display
Order Actions Based on Status
<!-- Conditional Actions -->
{% if order.durum == 1 %}
<!-- Active Order Actions -->
<button class="btn btn-warning">Cancel Order</button>
<button class="btn btn-info">Modify Order</button>
{% elseif order.durum == 4 %}
<!-- Completed Order Actions -->
<button class="btn btn-success">Reorder</button>
<button class="btn btn-secondary">Download Invoice</button>
{% endif %}
Display Based on User Permissions
<!-- Show admin features only to admins -->
{% if user.is_admin %}
<div class="admin-controls">
<a href="{{ order.admin_url }}" class="btn btn-primary">Admin Panel</a>
<button class="btn btn-danger">Delete Order</button>
</div>
{% endif %}
<!-- Show customer-specific information -->
{% if order.user.id == current_user.id %}
<div class="customer-actions">
<button class="btn btn-info">Track Order</button>
<button class="btn btn-secondary">Contact Support</button>
</div>
{% endif %}
Common Use Cases
Order Confirmation Page
<div class="order-confirmation">
<h1>Order Confirmed!</h1>
<p>Thank you for your order #{{ order.siparis_no }}</p>
<div class="confirmation-details">
<p>Order Date: {{ order.short_date }}</p>
<p>Total Amount: {{ order.amount_text }}</p>
<p>Items: {{ order.order_item_count }}</p>
</div>
<div class="next-steps">
<h3>What's Next?</h3>
<p>We'll send you an email confirmation to {{ order.email_address }}</p>
<p>You can track your order status anytime.</p>
</div>
</div>
Order History List
<div class="order-history">
<h2>Your Order History</h2>
{% for order in orders %}
<div class="order-history-item">
<div class="order-summary">
<h4>Order #{{ order.siparis_no }}</h4>
<p>{{ order.short_date }} - {{ order.amount_text }}</p>
<span class="status">{{ order.status_text }}</span>
</div>
<div class="order-preview">
<p>{{ order.order_item_count }} items</p>
<a href="{{ order.detail_link }}">View Details</a>
</div>
</div>
{% endfor %}
</div>
This reference provides practical examples for frontend developers working with Twig templates to display order information without exposing technical implementation details.