Skip to content
  1. Extras
  2. GoogleSheets
  3. Export
  4. Orders

Orders (msOrder)

Standard fields

FieldName
idOrder ID
user_idCustomer (id)
createdonOrder creation date
updatedonOrder update date
numOrder number
costTotal with delivery
cart_costCart total
delivery_costDelivery price
weightWeight
statusStatus (id)
deliveryDelivery (id)
paymentPayment (id)
contextContext
commentManager comment

Field modifiers

FieldName
status_nameStatus (name)
delivery_nameDelivery (name)
payment_namePayment (name)

Address

FieldName
address_receiverRecipient
address_phonePhone
address_countryCountry
address_indexZIP
address_regionRegion
address_cityCity
address_metroMetro station
address_streetStreet
address_buildingBuilding
address_roomRoom
address_commentComment
address_propertiesExtra properties

User

All standard user fields supported with user_ prefix. E.g. user_email, user_fullname

List of purchased products

FieldName
products_(field name)List of purchased products

E.g.:

  • products_id outputs list of product IDs
  • products_name outputs list of product names

Export example

Export fields: id,num,user_username,status_name,cart_cost,products_name

Result:

Result

System events

Class gsOrder fires these events:

php
<?php
switch($modx->event->name) {
  // fetches the list of orders
  case 'gsOnBeforeGetOrders':
    // $query - selection query
    // $range - sheet name, where data will be exported
    break;
  case 'gsOnGetOrders':
    // $orders - array of orders with all fields
    // $range - sheet name
    break;
}

Examples

  1. Get all orders with status 2 (Paid)

    php
    <?php
    if ($modx->event->name == 'gsOnBeforeGetOrders') {
      $query->where(array('status' => 2));
    }
  2. Convert order creation date createdon

    php
    <?php
    if ($modx->event->name == 'gsOnGetOrders') {
      $modx->event->params['orders'] = array_map(function($order){
        if (!empty($order['createdon'])) {
          $order['createdon'] = date("d-m-Y",strtotime($order['createdon']));
        }
        return $order;
      }, $orders);
    }