Skip to content

Instantly share code, notes, and snippets.

@bheyde
Created July 20, 2017 23:44
Show Gist options
  • Save bheyde/fde1a3d88df0aa052bf0e53eee54844b to your computer and use it in GitHub Desktop.
Save bheyde/fde1a3d88df0aa052bf0e53eee54844b to your computer and use it in GitHub Desktop.
JSON Export Template
<mvt:comment>
| Loop though all orders returned all new orders.
</mvt:comment>
{
<mvt:assign name="g.number_orders" value="miva_array_elements( l.settings:admin_order:orders )" />
"orders_returned": "&mvtj:global:number_orders;",
"orders":
[
<mvt:foreach iterator="order" array="admin_order:orders">
{
"date": "&mvtj:order:date; &mvtj:order:time;",
"id": "&mvtj:order:id;",
"login": "&mvtj:order:id;",
"batch_id": "&mvtj:order:batch_id;",
"status": "&mvtj:order:formatted_status;",
"customer_id": "&mvtj:order:cust_id;",
"customer_login": "&mvtj:order:customer_login;",
"bill_fname": "&mvtj:order:bill_fname;",
"bill_lname": "&mvtj:order:bill_lname;",
"bill_addr1": "&mvtj:order:bill_addr1;",
"bill_addr2": "&mvtj:order:bill_addr2;",
"bill_city": "&mvtj:order:bill_city;",
"bill_state": "&mvtj:order:bill_state;",
"bill_zip": "&mvtj:order:bill_zip;",
"bill_cntry": "&mvtj:order:bill_cntry;",
"bill_comp": "&mvtj:order:bill_comp;",
"bill_phone": "&mvtj:order:bill_phone;",
"bill_fax": "&mvtj:order:bill_fax;",
"bill_email": "&mvtj:order:bill_email;",
"ship_fname": "&mvtj:order:ship_fname;",
"ship_lname": "&mvtj:order:ship_lname;",
"ship_addr1": "&mvtj:order:ship_addr1;",
"ship_addr2": "&mvtj:order:ship_addr2;",
"ship_city": "&mvtj:order:ship_city;",
"ship_state": "&mvtj:order:ship_state;",
"ship_zip": "&mvtj:order:ship_zip;",
"ship_cntry": "&mvtj:order:ship_cntry;",
"ship_comp": "&mvtj:order:ship_comp;",
"ship_phone": "&mvtj:order:ship_phone;",
"ship_fax": "&mvtj:order:ship_fax;",
"ship_email": "&mvtj:order:ship_email;",
"items": [
<mvt:assign name="g.item_count" value="miva_array_elements( l.settings:order:items )" />
<mvt:foreach iterator="item" array="order:items">
{
"line_id": "&mvtj:item:line_id;",
"code": "&mvtj:item:code;",
"name": "&mvtj:item:name;",
"quantity": "&mvtj:item:quantity;",
"weight": "&mvtj:item:weight;",
"price": "&mvtj:item:price;",
"item_subtotal": "&mvtj:item:subtotal;",
"item_status": "&mvtj:item:formatted_status;",
"options": [
<mvt:assign name="g.options_count" value="miva_array_elements( l.settings:order:item:options )" />
<mvt:foreach iterator="option" array="item:options">
{
"attribute_code": "&mvtj:option:attr_code;",
"attribute_prompt": "&mvtj:option:attr_prompt;",
<mvt:if expr="l.settings:option:option_id">
"option_data": "&mvtj:option:opt_code;",
<mvt:elseif expr="NOT ISNULL l.settings:option:data">
"option_data": "&mvtj:option:data;",
<mvt:elseif expr="NOT ISNULL l.settings:option:data_long">
"option_data": "&mvtj:option:data_long;",
<mvt:else>
"option_data": "&mvtj:option:attr_code;",
</mvt:if>
"option_subtotal": "&mvtj:option:subtotal;"
}
<mvt:if expr="pos3 LT g.options_count">,</mvt:if>
</mvt:foreach>
]
}
<mvt:if expr="pos2 LT g.item_count">,</mvt:if>
</mvt:foreach>
],
<mvt:foreach iterator="charge" array="order:charges">
<mvt:if expr="l.settings:charge:type EQ 'TAX'">
"tax": "&mvtj:charge:amount;",
</mvt:if>
</mvt:foreach>
"total": "&mvtj:order:total;",
<mvt:comment>
| Display all payment fields. To decrpyt encrypted payment data, request must be made with Passphrase[1]=XXXX parameter.
</mvt:comment>
"payment_info": [
<mvt:assign name="g.payment_count" value="miva_array_elements( l.settings:order:payment:fields )" />
<mvt:foreach iterator="field" array="order:payment:fields">
{
"payment_label": "&mvtj:field:label;",
"payment_value": "&mvtj:field:value;"
}
<mvt:if expr="pos2 LT g.payment_count">,</mvt:if>
</mvt:foreach>
],
"shipping_info": {
<mvt:foreach iterator="charge" array="order:charges">
<mvt:if expr="l.settings:charge:type EQ 'SHIPPING'">
"ship_cost": "&mvtj:charge:amount;",
</mvt:if>
</mvt:foreach>
"ship_method": "&mvtj:order:ship_method;"
},
<mvt:comment>
| List all charges available in the order charges loop. This will include Tax, Shipping, Discounts, and Gift Certificates if available
</mvt:comment>
"charges": [
<mvt:assign name="g.charges_count" value="miva_array_elements( l.settings:order:charges )" />
<mvt:foreach iterator="charge" array="order:charges">
{
"charge_type": "&mvtj:charge:type;",
"charge_description": "&mvtj:charge:descrip;",
"charge_amount": "&mvtj:charge:amount;"
}
<mvt:if expr="pos2 LT g.charges_count">,</mvt:if>
</mvt:foreach>
],
<mvt:item name="customfields" param="Read_Order( l.settings:order:id, '' )" />
<mvt:assign name="g.custom_field_count" value="miva_array_elements( l.settings:customfields )" />
<mvt:foreach iterator="field" array="customfields">
"&mvtj:field:code;": "&mvtj:field:value"
<mvt:if expr="pos2 LT g.custom_field_count">,</mvt:if>
</mvt:foreach>
}
<mvt:if expr="pos1 LT g.number_orders">,</mvt:if>
</mvt:foreach>
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment