Hi all,
I have an interesting requirement in that I need to POST order information to a third party API that will then consume/translate this to XML. The API is limited, however, in that it can't take a long string and parse it. The following works to send the data as a long string within an XML output tag of <order>
However, since the third party API is looking for individual tags (ex. <orderID> <orderPrice>) and can't parse the long string, I need to do something like this:
The challenge, and where I need help, is that an order may contain multiple items, and I won't know how many items exist/can't hard code a guess for how many items a customer may have in an order (ex. groups[1]:price, groups[2]:price, etc.).
Is there a way to parse out the order so it creates individual tags, including the appropriate nesting, for items in an order versus sending all data in a string with a single tag of <order> as shown in my first example? I envision that the end output would look something like this:
Thanks in advance for your assistance!
Kelly
I have an interesting requirement in that I need to POST order information to a third party API that will then consume/translate this to XML. The API is limited, however, in that it can't take a long string and parse it. The following works to send the data as a long string within an XML output tag of <order>
Code:
<mvt:assign name="g.order" value="miva_array_serialize( l.settings:order )" /> <mvt:comment>Send data to PHP script and get the response</mvt:comment> <mvt:call action="'http://myvendor.net/orderinfo'" method="'POST'" fields="'order'"> <mvt:eval expr="s.callvalue" /> </mvt:call>
Code:
<mvt:assign name="g.orderaddr" value="l.settings:order:bill_addr" /> <mvt:assign name="g.orderemail" value="l.settings:order:bill_email" /> <mvt:comment>Send data to PHP script and get the response</mvt:comment> <mvt:call action="'http://myvendor.net/orderinfo'" method="'POST'" fields="'orderaddr,orderemail"> <mvt:eval expr="s.callvalue" /> </mvt:call>
Is there a way to parse out the order so it creates individual tags, including the appropriate nesting, for items in an order versus sending all data in a string with a single tag of <order> as shown in my first example? I envision that the end output would look something like this:
Code:
<orderid>1</orderid> <customername>Bob Smith</customername> <items> <itemname>Item 1</itemname> <itemprice>50.00</itemprice> </items> <items> <itemname>Item 2</itemname> <itemprice>75.00</itemprice> </items>
Kelly
Comment