Skip to main content

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 number
  • order.siparis_no - Order number (e.g., "ORD-2024-001234")
  • order.tarih - Full order date and time
  • order.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 name
  • order.telefon - Phone number
  • order.email_address - Customer email
  • order.adres - Delivery address
  • order.sehir - City
  • order.ilce - District
  • order.user - Customer user object
  • order.user.name - Customer name
  • order.user.bayi_kod - Customer code

Financial Information

  • order.toplam_tutar - Total amount (number)
  • order.amount_text - Total amount with currency symbol
  • order.currency - Currency code (e.g., "TRY")
  • order.currency_symbol - Currency symbol (e.g., "₺")
  • order.entered_amount - Entered amount
  • order.entered_amount_text - Entered amount with currency
  • order.shipment_cost - Shipping cost amount
  • order.shipment_amount_text - Shipping cost with currency
  • order.refund_amount - Refund amount

Order Content

  • order.items - Array of order items
  • order.order_item_count - Number of items in order
  • order.urun_toplam - Total quantity of all products
  • order.urun_cesit - Number of different products
  • order.order_data - Order data as JSON object

Payment Details

  • order.odeme_tur - Payment method
  • order.taksit - Number of installments
  • order.iskonto - Discount percentage
  • order.banka - Bank name

Administrative

  • order.yetkili - Authorized person
  • order.onay_tarih - Approval date
  • order.onay_not - Approval notes
  • order.created_at - Creation timestamp
  • order.updated_at - Last update timestamp
  • order.status_changed_at - Status change timestamp
  • order.detail_link - Frontend detail page URL
  • order.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 ID
  • item.urun_id - Product ID
  • item.adet - Quantity ordered
  • item.qty - Quantity (alias for adet)
  • item.durum - Item status
  • item.urun_kod - Product code/SKU

Product Information

  • item.product - Product object
  • item.product_name - Product name
  • item.kategori_isim - Category name
  • item.product.title - Full product title
  • item.product.sku - Product SKU
  • item.product.brand_name - Brand name

Variant Information

  • item.sepet_renk - Variant name/color
  • item.variant_name - Variant name (formatted)
  • item.sepet_renk_dosya - Variant image filename
  • item.sepet_beden - Size information

Pricing

  • item.buy_price - Purchase price per unit
  • item.buy_amount - Total purchase amount
  • item.price - Current price per unit
  • item.price_format - Formatted price with currency
  • item.total_amount - Total amount (quantity × price)
  • item.currency - Currency code

Images

  • item.image - Product image URL
  • item.med_image - Medium size image URL

Quantities and Measurements

  • item.base_qty - Base quantity in main measurement unit
  • item.shipped_qty - Already shipped quantity
  • item.awaiting_shipment_qty - Quantity awaiting shipment
  • item.package_count - Number of packages
  • item.package_qty - Quantity per package
  • item.measure_id - Measurement unit ID

Item Status

  • item.product_id - Product ID as string
  • item.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 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.