html Miva - 平面文件订单导出
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html Miva - 平面文件订单导出相关的知识,希望对你有一定的参考价值。
<mvt:comment>
| ------------------------
| Flat File Order Export
| ------------------------
</mvt:comment>
<mvt:comment>
| Development Helper - set to 1 to print out all data on the `l.settings` structure
</mvt:comment>
<mvt:assign name="g.debug" value="0"/>
<mvt:comment>
| Force Download of Output
</mvt:comment>
<mvt:if expr="NOT g.debug">
<mvt:assign name="l.header" value="miva_output_header( 'Content-Type', 'text/csv' )" />
<mvt:assign name="l.header" value="miva_output_header( 'Content-Disposition', 'attachment; filename=order-export.csv' )" />
</mvt:if>
<mvt:comment>
| Helper Variables
</mvt:comment>
<mvt:assign name="l.new_line" value="asciichar(10)"/>
<mvt:assign name="l.comma" value="asciichar(44)"/>
<mvt:assign name="l.quote" value="asciichar(34)"/>
<mvt:assign name="l.tab" value="asciichar(9)"/>
<mvt:comment>
| File Settings
</mvt:comment>
<mvt:assign name="l.file_delimiter" value="l.quote $ l.comma $ l.quote"/>
<mvt:assign name="l.temp_delimiter" value="'%^%'"/>
<mvt:comment>
| Output the Header Row
</mvt:comment>
<mvt:assign name="l.settings:header:row" value="
'Customer ID' $ l.temp_delimiter $
'Order Number' $ l.temp_delimiter $
'Date' $ l.temp_delimiter $
'Ship to Name' $ l.temp_delimiter $
'Ship to Address-Line One' $ l.temp_delimiter $
'Ship to Address-Line Two' $ l.temp_delimiter $
'Ship to City' $ l.temp_delimiter $
'Ship to State' $ l.temp_delimiter $
'Ship to Zipcode' $ l.temp_delimiter $
'Ship to Country' $ l.temp_delimiter $
'Ship Via' $ l.temp_delimiter $
'Ship Date' $ l.temp_delimiter $
'Quantity' $ l.temp_delimiter $
'Description' $ l.temp_delimiter $
'Product Price' $ l.temp_delimiter $
'Product SKU' $ l.temp_delimiter $
'Product Cost'
"/>
<mvt:comment><!-- Escape Quotes for CSV and output row --></mvt:comment>
<mvt:eval expr="l.quote $ glosub( glosub(l.settings:header:row, l.quote, l.quote $ l.quote) , l.temp_delimiter, l.file_delimiter ) $ l.quote $ l.newline"/>
<mvt:comment>
| Output Each Order's Items (Groups) as a Row
</mvt:comment>
<mvt:foreach iterator="order" array="admin_order:orders">
<mvt:assign name="l.settings:order:output:ship_to_name" value="l.settings:order:ship_fname $ ' ' $ l.settings:order:ship_lname" />
<mvt:comment><!-- Save the Shipping/Tax charges to a variable we can access later without looping over the array of charges --></mvt:comment>
<mvt:foreach iterator="charge" array="order:charges">
<mvt:if expr="toupper(l.settings:charge:type) EQ 'SHIPPING'">
<mvt:assign name="l.settings:order:output:shipping_charge" value="l.settings:charge" />
<mvt:elseif expr="toupper(l.settings:charge:type) EQ 'TAX'">
<mvt:assign name="l.settings:order:output:tax_charge" value="l.settings:charge" />
</mvt:if>
</mvt:foreach>
<mvt:assign name="l.settings:order:output:ship_via" value="l.settings:order:output:shipping_charge:descrip" />
<mvt:comment><mvt:item name="customfields" param="Read_Order(l.settings:order:id, 'order_notes,customer_instructions', l.settings:order:cf)" />
<mvt:assign name="l.settings:order:output:customer_instructions" value="l.settings:order:cf:customer_instructions" />
<mvt:assign name="l.settings:order:output:order_notes" value="l.settings:order:cf:order_notes" /></mvt:comment>
<mvt:foreach iterator="item" array="order:items">
<mvt:if expr="l.settings:item:product:sku">
<mvt:assign name="l.settings:item:output:sku" value="l.settings:item:product:sku" />
<mvt:else>
<mvt:assign name="l.settings:item:output:sku" value="l.settings:item:code" />
</mvt:if>
<mvt:assign name="l.settings:item:output:row" value="
l.settings:order:id $ l.temp_delimiter $
l.settings:order:date $ l.temp_delimiter $
l.settings:order:output:ship_to_name $ l.temp_delimiter $
l.settings:order:ship_addr1 $ l.temp_delimiter $
l.settings:order:ship_addr2 $ l.temp_delimiter $
l.settings:order:ship_city $ l.temp_delimiter $
l.settings:order:ship_state $ l.temp_delimiter $
l.settings:order:ship_zip $ l.temp_delimiter $
l.settings:order:ship_cntry $ l.temp_delimiter $
l.settings:order:output:ship_via $ l.temp_delimiter $
l.settings:item:shipment:formatted_ship_date $ l.temp_delimiter $
l.settings:item:quantity $ l.temp_delimiter $
l.settings:item:name $ l.temp_delimiter $
l.settings:item:price $ l.temp_delimiter $
l.settings:item:output:sku $ l.temp_delimiter $
l.settings:item:subtotal
"/>
<mvt:comment><!-- Escape Quotes for CSV and output row --></mvt:comment>
<mvt:eval expr="l.quote $ glosub( glosub(l.settings:item:output:row, l.quote, l.quote $ l.quote) , l.temp_delimiter, l.file_delimiter ) $ l.quote $ l.newline"/>
</mvt:foreach>
</mvt:foreach>
<mvt:comment>
| Debugging Helpers
</mvt:comment>
<mvt:if expr="g.debug">
<hr>
<mvt:eval expr="decodeattribute(glosub(miva_array_serialize(l.settings), ',', '<br>'))" />
</mvt:if>
以上是关于html Miva - 平面文件订单导出的主要内容,如果未能解决你的问题,请参考以下文章