Skip to main content
Version: 2.0.0

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

  1. Go to yStore → Orders.
  2. Filter or select the orders you want to export (leave unselected to export all visible orders).
  3. Click Export in the toolbar.
  4. Choose an export type from the dropdown and select the file format (CSV, JSON, or XLSX).
  5. 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_price
  • sub_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 order
  • shipping_fees — JSON array of extended data entries whose keys start with shipping_fee
  • sub_products — same as above
  • cash_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:

ColumnDescription
order_item_idItem's entity_id in the order items table
order_item_parent_idParent item ID for configurable children
order_item_item_idInternal item identifier
order_item_yui_idProduct's yui internal ID
order_item_nameProduct name at time of order
order_item_skuSKU
order_item_qtyQuantity ordered
order_item_priceUnit price (excl. tax)
order_item_price_incl_taxUnit price (incl. tax)
order_item_row_totalLine total (excl. tax)
order_item_row_total_incl_taxLine total (incl. tax)
order_item_discount_amountDiscount applied to this item
order_item_typeItem type (simple, variant, configurable, digital)
order_item_customCustom 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:

ColumnDescription
discount_sourcecoupon, gift_card, or order
codeCoupon or gift card code
discount_amountAbsolute value of the discount
when_usedDate/time the discount was applied or the order was placed
coupon_priorityPriority of the coupon (coupon rows only)
coupon_typeDiscount type: fixed or percent (coupon rows only)
gift_card_availableRemaining balance flag (gift card rows only)
gift_card_enabledWhether the card is still active (gift card rows only)
gift_card_valid_untilExpiry 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:

ColumnDescription
voucher_codeThe generated gift card code
voucher_security_codeSecurity / PIN code
voucher_availableRemaining balance
voucher_valid_untilExpiry date
voucher_used_atDate/time the code was used
voucher_account_idLinked gift card account ID
voucher_messagePersonalized message stored on the voucher
voucher_enabledWhether the code is active
order_item_idOrder item that generated this voucher
order_item_nameName of the purchased gift card product
order_item_skuSKU of the purchased gift card product
order_item_qtyQuantity
order_item_priceUnit price
order_item_row_totalRow 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:

  1. Create a class that extends AbstractOrderExporter.
  2. Implement displayName() and export(ElementQueryInterface $query).
  3. 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():

MethodDescription
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