<?xml version="1.0" encoding="UTF-8"?><files><file filename="%lastincrementid%.json"><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl"><xsl:output method="text"/><xsl:variable name="sepstart" select="'"'"/> <xsl:variable name="sepmid" select="'": '"/> <xsl:variable name="mid" select="': '"/> <xsl:variable name="sepend" select="',
'"/> <xsl:variable name="newline" select="'
'"/> <xsl:template match="/">
<xsl:for-each select="objects/object"><xsl:text>{</xsl:text><xsl:value-of select="$newline"/>
<xsl:value-of select="concat($sepstart, 'access_key', $sepmid, php:functionString('json_encode','[CLOUGISTIC API ACCESS KEY]'), $sepend)"/> <xsl:value-of select="concat($sepstart, 'entity_id', $sepmid, php:functionString('json_encode','[CLOUGISTIC ENTITY ID]'), $sepend)"/>
<xsl:value-of select="concat($sepstart, 'magestatus', $sepmid, php:functionString('json_encode',status), $sepend)"/> <xsl:value-of select="concat($sepstart, 'payload', $sepmid, '{', $newline)"/> <xsl:choose> <xsl:when test="state='new'"><xsl:text>"status" : "0"</xsl:text></xsl:when> <xsl:when test="state='pending'"><xsl:text>"status" : "0"</xsl:text></xsl:when> <xsl:when test="state='pending_payment'"><xsl:text>"status" : "0"</xsl:text></xsl:when> <xsl:when test="state='payment_review'"><xsl:text>"status" : "0"</xsl:text></xsl:when> <xsl:when test="state='processing'"><xsl:text>"status" : "1"</xsl:text></xsl:when> <xsl:when test="state='holded'"><xsl:text>"status" : "8"</xsl:text></xsl:when> <xsl:when test="state='canceled'"><xsl:text>"status" : "9"</xsl:text></xsl:when> <xsl:when test="state='closed'"><xsl:text>"status" : "9"</xsl:text></xsl:when> <xsl:when test="state='complete' and count(items/item[qty_canceled>0])>0"><xsl:text>"status" : "9"</xsl:text></xsl:when> <xsl:otherwise>"status" : "0"</xsl:otherwise> </xsl:choose> <xsl:text>,</xsl:text> <xsl:value-of select="$newline"/>
<xsl:variable name = "order_type"> <xsl:choose> <xsl:when test="(shipping_method='freeshipping_freeshipping' and store_id='0')">1</xsl:when> <xsl:when test="(customer/consignment_type='sale' and customer/consignment_zone > 0)">1</xsl:when> <xsl:when test="(customer/consignment_type='supply' and customer/consignment_zone > 0)">0</xsl:when> <xsl:otherwise>0</xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:value-of select="concat($sepstart,'type', $sepmid, $order_type, $sepend)"/>
<xsl:comment>ORDER OPTIONS</xsl:comment>
<xsl:variable name = "pos_zone_id"> <xsl:choose> <xsl:when test="(shipping_method='freeshipping_freeshipping' and store_id='0')">5</xsl:when> <xsl:when test="(customer/consignment_type='sale' and customer/consignment_zone > 0)"> <xsl:value-of select="php:functionString('json_encode', customer/consignment_zone)" /> </xsl:when> <xsl:otherwise></xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name = "consignment_zone_id"> <xsl:choose> <xsl:when test="(customer/consignment_type='supply' and customer/consignment_zone > 0)"> <xsl:value-of select="php:functionString('json_encode', customer/consignment_zone)" /> </xsl:when> <xsl:otherwise></xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:comment>Options part</xsl:comment> <xsl:value-of select="concat($sepstart,'options', $sepmid, '{', $newline)"/> <xsl:if test="string-length($pos_zone_id)!=0"> <xsl:value-of select="concat($sepstart,'@pos_zone_id', $sepmid, $pos_zone_id, $sepend)"/> </xsl:if> <xsl:if test="string-length($consignment_zone_id)!=0"> <xsl:value-of select="concat($sepstart,'@consignment_zone_id', $sepmid, $consignment_zone_id, $sepend)"/> </xsl:if> <xsl:comment>for forwarding shipmentinformation to 3th party connectors</xsl:comment> <xsl:value-of select="concat($sepstart,'carrier', $sepmid, '{', $newline)"/> <xsl:value-of select="concat($sepstart, 'name', $sepmid, php:functionString('json_encode', shipping_method), $sepend)"/> <xsl:value-of select="concat($sepstart, 'type', $sepmid, php:functionString('json_encode', '0000'), $newline)"/> <xsl:text>}</xsl:text> <xsl:text>},</xsl:text> <xsl:value-of select="$newline"/>
<xsl:comment>Cash On Delivery Amount</xsl:comment> <xsl:choose> <xsl:when test="shipping_method='Cash on Delivery'"> <xsl:value-of select="concat($sepstart, 'cod_amount', $sepmid, php:functionString('json_encode', base_grand_total),$sepend)"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="concat($sepstart, 'cod_amount', $sepmid, php:functionString('json_encode', '0'),$sepend)"/> </xsl:otherwise> </xsl:choose>
<xsl:value-of select="concat($sepstart, 'source_id', $sepmid, php:functionString('json_encode','[A UNIQUE SOURCE CODE]'), $sepend)"/> <xsl:value-of select="concat($sepstart, 'reference', $sepmid, php:functionString('json_encode', increment_id),$sepend)"/> <xsl:value-of select="concat($sepstart, 'customer_id', $sepmid, php:functionString('json_encode', customer_id),$sepend)"/> <xsl:value-of select="concat($sepstart, 'currency', $sepmid, php:functionString('json_encode', store_currency_code),$sepend)"/> <xsl:value-of select="concat($sepstart, 'shipping_method', $sepmid, php:functionString('json_encode', shipping_method),$sepend)"/> <xsl:value-of select="concat($sepstart, 'flag_partial', $sepmid, php:functionString('json_encode', can_ship_partially),$sepend)"/>
<xsl:value-of select="concat($sepstart, 'created_at', $sepmid, php:functionString('json_encode', created_at),$sepend)"/> or <xsl:value-of select="concat($sepstart, 'created_at', $sepmid, php:functionString('json_encode', php:functionString('strftime','%Y-%m-%d %H:%M:%S', created_at_timestamp)),$sepend)" />
<xsl:value-of select="concat($sepstart, 'delivery_at', $sepmid, php:functionString('json_encode', delivery_at),$sepend)"/> <xsl:value-of select="concat($sepstart, 'billing_company', $sepmid, php:functionString('json_encode', billing/company), $sepend)"/> <xsl:value-of select="concat($sepstart, 'billing_firstname', $sepmid, php:functionString('json_encode', billing/firstname), $sepend)"/> <xsl:value-of select="concat($sepstart, 'billing_lastname', $sepmid, php:functionString('json_encode', billing/lastname), $sepend)"/> <xsl:value-of select="concat($sepstart, 'billing_street_full', $sepmid, php:functionString('json_encode', billing/street), $sepend)"/> <xsl:value-of select="concat($sepstart, 'billing_postcode', $sepmid, php:functionString('json_encode', billing/postcode), $sepend)"/> <xsl:value-of select="concat($sepstart, 'billing_city', $sepmid, php:functionString('json_encode', billing/city), $sepend)"/> <xsl:value-of select="concat($sepstart, 'billing_region', $sepmid, php:functionString('json_encode', billing/region), $sepend)"/> <xsl:value-of select="concat($sepstart, 'billing_country', $sepmid, php:functionString('json_encode', billing/country_id), $sepend)"/> <xsl:value-of select="concat($sepstart, 'billing_phone', $sepmid, php:functionString('json_encode', billing/phone), $sepend)"/> <xsl:value-of select="concat($sepstart, 'billing_email', $sepmid, php:functionString('json_encode', billing/email), $sepend)"/>
<xsl:value-of select="concat($sepstart, 'shipping_company', $sepmid, php:functionString('json_encode', shipping/company), $sepend)"/> <xsl:value-of select="concat($sepstart, 'shipping_firstname', $sepmid, php:functionString('json_encode', shipping/firstname), $sepend)"/> <xsl:value-of select="concat($sepstart, 'shipping_lastname', $sepmid, php:functionString('json_encode', shipping/lastname), $sepend)"/> <xsl:value-of select="concat($sepstart, 'shipping_street_full', $sepmid, php:functionString('json_encode', shipping/street), $sepend)"/> <xsl:value-of select="concat($sepstart, 'shipping_postcode', $sepmid, php:functionString('json_encode', shipping/postcode), $sepend)"/> <xsl:value-of select="concat($sepstart, 'shipping_city', $sepmid, php:functionString('json_encode', shipping/city), $sepend)"/> <xsl:value-of select="concat($sepstart, 'shipping_region', $sepmid, php:functionString('json_encode', shipping/region), $sepend)"/> <xsl:value-of select="concat($sepstart, 'shipping_country', $sepmid, php:functionString('json_encode', shipping/country_id), $sepend)"/> <xsl:value-of select="concat($sepstart, 'shipping_phone', $sepmid, php:functionString('json_encode', shipping/phone), $sepend)"/> <xsl:value-of select="concat($sepstart, 'shipping_email', $sepmid, php:functionString('json_encode', shipping/email),$sepend)"/> <xsl:value-of select="concat($sepstart, 'items', $sepmid,'[',$newline)"/> <xsl:for-each select="items/item"> <xsl:comment>Needed Qty Calculation</xsl:comment> <xsl:variable name = "qty_refunded_calc"> <xsl:choose> <xsl:when test="qty_refunded >=0"><xsl:value-of select="php:functionString('json_encode', round(qty_refunded))"/></xsl:when> <xsl:otherwise>0</xsl:otherwise> </xsl:choose> </xsl:variable>
<xsl:variable name = "qty_canceled_calc"> <xsl:choose> <xsl:when test="qty_canceled >=0"><xsl:value-of select="php:functionString('json_encode', round(qty_canceled))"/></xsl:when> <xsl:otherwise>0</xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name = "qty_shipped_calc"> <xsl:choose> <xsl:when test="qty_shipped >=0"><xsl:value-of select="php:functionString('json_encode', round(qty_shipped))"/></xsl:when> <xsl:otherwise>0</xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name = "qty_calc" select= "round(qty - $qty_refunded_calc - $qty_canceled_calc - $qty_shipped_calc)">
</xsl:variable> <xsl:choose> <xsl:when test="(product_attributes/type_id='simple' and string-length(parent_item_id/text())=0)"> <xsl:text>[{</xsl:text> <xsl:comment>Simple Product without Parent</xsl:comment> <xsl:value-of select="$newline"/> <xsl:value-of select="concat($sepstart, 'sku', $sepmid, php:functionString('json_encode', sku),$sepend)"/> <xsl:value-of select="concat($sepstart, 'description', $sepmid, php:functionString('json_encode', name),$sepend)"/> <xsl:value-of select="concat($sepstart, 'weight', $sepmid, php:functionString('json_encode', weight),$sepend)"/> <xsl:value-of select="concat($sepstart, 'reference', $sepmid, php:functionString('json_encode', item_id),$sepend)"/> <xsl:value-of select="concat($sepstart, 'unit_price', $sepmid, php:functionString('json_encode',php:functionString('number_format',base_price,2,'.','')))"/><xsl:value-of select="$sepend"/> <xsl:value-of select="concat($sepstart, 'qty', $sepmid, php:functionString('json_encode', $qty_calc),$newline)"/>
<xsl:if test="string-length(custom_options/custom_option/text())!=0"> <xsl:text>,"custom_options": { "option_data": [</xsl:text> </xsl:if> <xsl:for-each select="custom_options/custom_option"> <xsl:text>{</xsl:text> <xsl:value-of select="concat($sepstart, 'label', $sepmid, php:functionString('json_encode', name),$sepend)"/> <xsl:value-of select="concat($sepstart, 'value', $sepmid, php:functionString('json_encode', value))"/> <xsl:text>}</xsl:text> </xsl:for-each> <xsl:if test="string-length(custom_options/custom_option/text())!=0"> <xsl:text>]}</xsl:text> </xsl:if> <xsl:text>}]</xsl:text> <xsl:if test="not(position()=last())"><xsl:text>,</xsl:text><xsl:value-of select="$newline"/></xsl:if> </xsl:when> <xsl:when test="(product_attributes/type_id='simple' and parent_item/product_attributes/type_id='configurable' and string-length(parent_item_id/text())!=0)"> <xsl:text>[{</xsl:text> <xsl:comment>Simple Product with Configurable as Parent</xsl:comment> <xsl:value-of select="$newline"/> <xsl:value-of select="concat($sepstart, 'sku', $sepmid, php:functionString('json_encode', parent_item/sku),$sepend)"/> <xsl:value-of select="concat($sepstart, 'description', $sepmid, php:functionString('json_encode', name),$sepend)"/> <xsl:value-of select="concat($sepstart, 'weight', $sepmid, php:functionString('json_encode', weight),$sepend)"/> <xsl:value-of select="concat($sepstart, 'reference', $sepmid, php:functionString('json_encode', parent_item_id),$sepend)"/> <xsl:value-of select="concat($sepstart, 'unit_price', $sepmid, php:functionString('json_encode',php:functionString('number_format',parent_item/base_price,2,'.','')))"/><xsl:value-of select="$sepend"/> <xsl:value-of select="concat($sepstart, 'qty', $sepmid, php:functionString('json_encode', $qty_calc),$newline)"/> <xsl:if test="string-length(parent_item/custom_options/custom_option/text())!=0"> <xsl:text>,"custom_options": { "option_data": [</xsl:text> </xsl:if> <xsl:for-each select="parent_item/custom_options/custom_option"> <xsl:text>{</xsl:text> <xsl:value-of select="concat($sepstart, 'label', $sepmid, php:functionString('json_encode', name),$sepend)"/> <xsl:value-of select="concat($sepstart, 'value', $sepmid, php:functionString('json_encode', value))"/> <xsl:text>}</xsl:text> </xsl:for-each> <xsl:if test="string-length(parent_item/custom_options/custom_option/text())!=0"> <xsl:text>]}</xsl:text> </xsl:if> <xsl:text>}]</xsl:text> <xsl:if test="not(position()=last())"><xsl:text>,</xsl:text><xsl:value-of select="$newline"/></xsl:if> </xsl:when> <xsl:when test="(product_attributes/type_id='simple' and parent_item/product_attributes/type_id='bundle' and parent_item/product_attributes/shipment_type='1')"> <xsl:text>[{</xsl:text> <xsl:comment>Bundle Items / Option Ship Separately is set!</xsl:comment> <xsl:value-of select="$newline"/> <xsl:value-of select="concat($sepstart, 'sku', $sepmid, php:functionString('json_encode', sku),$sepend)"/> <xsl:value-of select="concat($sepstart, 'description', $sepmid, php:functionString('json_encode', name),$sepend)"/> <xsl:value-of select="concat($sepstart, 'weight', $sepmid, php:functionString('json_encode', weight),$sepend)"/> <xsl:value-of select="concat($sepstart, 'reference', $sepmid, php:functionString('json_encode', item_id),$sepend)"/> <xsl:value-of select="concat($sepstart, 'unit_price', $sepmid, php:functionString('json_encode',php:functionString('number_format',base_price,2,'.','')))"/><xsl:value-of select="$sepend"/> <xsl:value-of select="concat($sepstart, 'qty', $sepmid, php:functionString('json_encode', $qty_calc),$newline)"/> <xsl:text>}]</xsl:text> <xsl:if test="not(position()=last())"><xsl:text>,</xsl:text><xsl:value-of select="$newline"/></xsl:if> </xsl:when> </xsl:choose> </xsl:for-each> <xsl:text>]</xsl:text>
<xsl:value-of select="$newline"/>
</xsl:for-each><xsl:text>}</xsl:text><xsl:value-of select="$newline"/><xsl:text>}</xsl:text></xsl:template></xsl:stylesheet></file></files>