Order Export
yStore ships with five export formats that cover different reporting and integration needs. All exporters are available from the standard Craft element export dialog in yStore → Orders.
How to export
- Go to
yStore → Orders. - Filter or select the orders you want to export (leave unselected to export all visible orders).
- Click Export in the toolbar.
- Choose an export type from the dropdown and select the file format (CSV, JSON, or XLSX).
- Click Export to download.
Available exporters
Orders with Items
Display name: Orders with Items
Exports one row per order. Each row includes the standard order fields plus an items column containing a JSON array of all order line items. Use this when you need order totals together with a summary of what was purchased.
Columns included:
- Standard:
increment_id,email,phone_number,status,firstname,lastname,billing_address,shipping_address,grand_total,shipping_method,shipping_price,payment_method,payment_price,cash_rounding,currency_code,siteId,ordered_at,dateCreated,dateUpdated items— JSON array, each element contains:id,name,sku,qty,unit_price,row_pricesub_products— comma-separated names of sub-products (configurable children)
Orders with Extended Data
Display name: Orders with Extended Data
Exports one row per order with additional columns for extended sales metadata and shipping fee detail. Use this for integrations that read custom order data stored via SalesExtendedService.
Extra columns beyond the standard set:
extended_data— JSON array of all extended data key/value pairs attached to the ordershipping_fees— JSON array of extended data entries whose keys start withshipping_feesub_products— same as abovecash_rounding
Order Items
Display name: Order Items
Exports one row per line item (flat/denormalized). Each order appears multiple times — once for each item purchased. Use this for warehouse picking lists, fulfilment sheets, or per-SKU analysis.
Extra columns per row:
| Column | Description |
|---|---|
order_item_id | Item's entity_id in the order items table |
order_item_parent_id | Parent item ID for configurable children |
order_item_item_id | Internal item identifier |
order_item_yui_id | Product's yui internal ID |
order_item_name | Product name at time of order |
order_item_sku | SKU |
order_item_qty | Quantity ordered |
order_item_price | Unit price (excl. tax) |
order_item_price_incl_tax | Unit price (incl. tax) |
order_item_row_total | Line total (excl. tax) |
order_item_row_total_incl_tax | Line total (incl. tax) |
order_item_discount_amount | Discount applied to this item |
order_item_type | Item type (simple, variant, configurable, digital) |
order_item_custom | Custom JSON data stored on the item |
Orders with Discounts
Display name: Orders with Discounts
Exports one row per discount applied to an order. An order with two coupon codes and one gift card produces three rows. Orders with no discounts are excluded unless they have a coupon code on the order record itself.
Extra columns per discount row:
| Column | Description |
|---|---|
discount_source | coupon, gift_card, or order |
code | Coupon or gift card code |
discount_amount | Absolute value of the discount |
when_used | Date/time the discount was applied or the order was placed |
coupon_priority | Priority of the coupon (coupon rows only) |
coupon_type | Discount type: fixed or percent (coupon rows only) |
gift_card_available | Remaining balance flag (gift card rows only) |
gift_card_enabled | Whether the card is still active (gift card rows only) |
gift_card_valid_until | Expiry date (gift card rows only) |
Orders with Voucher Codes
Display name: Orders with Voucher Codes
Exports one row per generated voucher/gift card code associated with an order. Use this to reconcile issued gift cards with the orders that generated them.
Extra columns per voucher row:
| Column | Description |
|---|---|
voucher_code | The generated gift card code |
voucher_security_code | Security / PIN code |
voucher_available | Remaining balance |
voucher_valid_until | Expiry date |
voucher_used_at | Date/time the code was used |
voucher_account_id | Linked gift card account ID |
voucher_message | Personalized message stored on the voucher |
voucher_enabled | Whether the code is active |
order_item_id | Order item that generated this voucher |
order_item_name | Name of the purchased gift card product |
order_item_sku | SKU of the purchased gift card product |
order_item_qty | Quantity |
order_item_price | Unit price |
order_item_row_total | Row total |
Cash rounding
All exporters that include payment totals append a cash_rounding column. It contains the difference between the stored grand_total and the computed sum of (subtotal + tax + shipping + payment − discount). A non-zero value indicates that cash rounding was applied to the order.
Developer reference
Extending with a custom exporter
All built-in exporters extend yui\craft\exporters\AbstractOrderExporter, which itself extends Craft's craft\base\ElementExporter.
To add a custom exporter:
- Create a class that extends
AbstractOrderExporter. - Implement
displayName()andexport(ElementQueryInterface $query). - Register it on the Order element type.
namespace my\plugin\exporters;
use craft\elements\db\ElementQueryInterface;
use yui\craft\exporters\AbstractOrderExporter;
class MyCustomExporter extends AbstractOrderExporter
{
public static function displayName(): string
{
return 'My Custom Export';
}
public function export(ElementQueryInterface $query): mixed
{
// Start with the standard order columns
$query->select($this->getBaseOrderSelect());
$query->groupBy(['elements.id']);
$orders = $query->asArray()->all();
foreach ($orders as &$order) {
// Add phone number after email (helper from the base class)
$phoneNumber = $this->getPhoneNumberFromOrder($order);
$order = $this->insertPhoneNumberAfterEmail($order, $phoneNumber);
// Add cash rounding column
$order = $this->insertCashRoundingAfterPaymentPrice($order);
// Add your own custom column
$order['my_field'] = 'value';
}
return $orders;
}
}
Register the exporter in your plugin's init():
use craft\events\RegisterComponentTypesEvent;
use yui\craft\elements\Order;
Event::on(
Order::class,
Order::EVENT_REGISTER_EXPORTERS,
function (RegisterComponentTypesEvent $event) {
$event->types[] = MyCustomExporter::class;
}
);
Base class helpers
AbstractOrderExporter provides three protected helpers usable in export():
| Method | Description |
|---|---|
getBaseOrderSelect() | Returns the standard column list to pass to $query->select() |
getPhoneNumberFromOrder(array $order) | Extracts phone from billing or shipping address |
insertPhoneNumberAfterEmail(array $order, string $phone) | Inserts phone_number key after email key |
insertCashRoundingAfterPaymentPrice(array $order) | Inserts cash_rounding key after payment_price key |
calculateCashRounding(array $order) | Returns the cash rounding adjustment as a float |
Base order columns
The following columns are available from getBaseOrderSelect():
id, increment_id, email, status, firstname, lastname, billing_address, shipping_address, grand_total, shipping_method, shipping_price, payment_method, payment_price, currency_code, siteId, ordered_at, dateCreated, dateUpdated