Skip to content

Instantly share code, notes, and snippets.

@andrew-serrano
Last active June 25, 2020 22:30
Show Gist options
  • Save andrew-serrano/40e44a16e47b89197335cca15ad40373 to your computer and use it in GitHub Desktop.
Save andrew-serrano/40e44a16e47b89197335cca15ad40373 to your computer and use it in GitHub Desktop.
Load an array of emails (WIP)
<mvt:comment>
Reference:
templateorderemails.mv
</mvt:comment>
<mvt:assign name="l.email_templates" value="miva_splitstring('ORDERCONF_CUSTOMER,GIFTCERTIFICATE_CREATED,SHIPMENT_SHIPPED', ',', l.settings:email_templates, 'trim' )" />
<mvt:foreach iterator="email_template" array="email_templates">
<mvt:comment>
Default
</mvt:comment>
<mvt:assign name="l.message" value="''" />
<mvt:assign name="l.page" value="''" />
<mvt:assign name="l.settings:render" value="''" />
<mvt:assign name="l.email" value="''" />
<mvt:do file="g.Module_Root $ '/modules/fulfill/templateorderemails.mvc'" name="l.success" value="TemplateOrderEmail_Load_Code( l.settings:email_template, l.email )" />
<mvt:do file="g.Module_Feature_TUI_DB" name="l.success" value="Page_Load_Code( l.email:page_code, l.page )" />
<mvt:comment>
Overrides if needed
</mvt:comment>
<mvt:do file="g.Module_Library_DB" name="l.success" value="Order_Load_ID( g.Order_ID, l.run:order )" />
<mvt:do file="g.Module_Library_DB" name="l.success" value="OrderItemList_Load_Status( l.run:order:id, 400, l.run:backordered_orderitems )" />
<mvt:assign NAME = "l.rma_count" VALUE = "0"/>
<mvt:assign NAME = "l.rmas" VALUE = "''"/>
<mvt:assign NAME = "l.giftcert_count" VALUE = "0"/>
<mvt:assign NAME = "l.giftcertificates" VALUE = "''"/>
<mvt:assign NAME = "l.multiplex_returns" VALUE = "0"/>
<mvt:assign NAME = "l.multiplex_giftcerts" VALUE = "0"/>
<mvt:assign NAME = "l.run:rma_id" VALUE = "0"/>
<mvt:assign NAME = "l.run:ordershipments" VALUE = "''"/>
<mvt:if EXPR = "l.email:on_retc">
<mvt:do file="g.Module_Library_DB" name="l.rma_count" value="OrderReturnList_Load_Status( l.run:order:id, 500, l.rmas )" />
</mvt:if>
<mvt:if EXPR = "l.email:on_retr">
<mvt:do file="g.Module_Library_DB" name="l.returned_count" value="OrderReturnList_Load_Status( l.run:order:id, 600, l.returned_orderreturns )" />
<mvt:assign NAME = "l.rma_count" VALUE = "miva_array_merge( l.returned_orderreturns, 1, l.returned_count, l.rmas, -1 )"/>
</mvt:if>
<mvt:if EXPR = "l.email:on_shpc AND l.email:on_shps">
<mvt:do file="g.Module_Library_DB" name="l.null" value="OrderItemList_Load_Order( l.run:order:id, l.run:ordershipments )" />
<mvt:elseif EXPR = "l.email:on_shpc">
<mvt:do file="g.Module_Library_DB" name="l.null" value="OrderShipmentList_Load_Status( l.run:order:id, 100, l.run:ordershipments )" />
<mvt:elseif EXPR = "l.email:on_shps">
<mvt:do file="g.Module_Library_DB" name="l.null" value="OrderShipmentList_Load_Status( l.run:order:id, 200, l.run:ordershipments )" />
</mvt:if>
<mvt:if EXPR = "l.email:on_gftcert">
<mvt:do file="g.Module_Feature_GFT_DB" name="l.giftcert_count" value="GiftCertificateList_Load_Order( l.run:order:id, l.giftcertificates )" />
</mvt:if>
<mvt:if EXPR = "l.email:on_digital">
<mvt:do file="g.Module_Feature_DDL_DB" name="l.digitaldownload_count" value="DigitalDownloadList_Load_Order( l.run:order:id, l.digitaldownloads )" />
</mvt:if>
<mvt:if expr="l.giftcert_count GT 1">
<mvt:do file="g.Module_Feature_TUI_DB" name="l.Item_Load_Code" value="Item_Load_Code( 'giftcertificate', l.item )" />
<mvt:if expr="NOT l.Item_Load_Code">
<mvt:do file="g.Module_Library_DB" name="l.Error_Is_EOF" value="Error_Is_EOF()" />
<mvt:if expr="NOT l.Error_Is_EOF">
<mvt:exit/>
</mvt:if>
<mvt:do file="g.Module_Feature_TUI_DB" name="l.PageXItem_Load" value="PageXItem_Load( l.page:id, l.item:id, l.pagexitem )" />
<mvt:elseif expr="NOT l.PageXItem_Load">
<mvt:do file="g.Module_Library_DB" name="l.Error_Is_EOF" value="Error_Is_EOF()" />
<mvt:if expr="NOT l.Error_Is_EOF">
<mvt:exit/>
</mvt:if>
<mvt:else>
<mvt:assign name="l.multiplex_giftcerts" value="1" />
</mvt:if>
</mvt:if>
<mvt:assign NAME = "l.iteration_count" VALUE = "1" />
<mvt:if expr = "l.multiplex_giftcerts AND ( l.iteration_count LT l.giftcert_count )">
<mvt:assign name = "l.iteration_count" value = "l.giftcert_count" />
</mvt:if>
<mvt:assign name="l.count" value="1" />
<mvt:while expr="l.count LE l.iteration_count">
<mvt:if expr="l.count GT l.iteration_count">
<mvt:assign name="l.run:giftcertificate" value="''" />
<mvt:else>
<mvt:assign name = "l.run:giftcertificate" value="l.giftcertificates[ l.count ]"/>
<mvt:do file="g.Module_Root $ '/modules/fulfill/templateorderemails.mvc'" name="l.TemplateOrderEmails_Load_GiftCertificateSalesData" value="TemplateOrderEmails_Load_GiftCertificateSalesData( l.run:order, l.run:giftcertificate )" />
<mvt:if expr="NOT l.TemplateOrderEmails_Load_GiftCertificateSalesData">
<mvt:exit/>
</mvt:if>
</mvt:if>
<mvt:assign name="l.count" value="l.count + 1" />
</mvt:while>
<mvt:comment>
Render Template
</mvt:comment>
<mvt:do file="g.Module_Feature_TUI_DB" name="l.success" value="ItemModuleList_Load_Page_Render( l.page:id, l.settings:render )" />
<mvt:foreach iterator="item" array="render:items">
<mvt:assign name="l.result" value="''" />
<mvt:assign NAME="l.item_code" VALUE="l.settings:item:item_code"/>
<mvt:if expr="l.item_code EQ 'order'">
<mvt:do file="g.Module_Root $ '/modules/fulfill/templateorderemails.mvc'" name="l.result" value="TemplateOrderEmails_Initialize_Item_order( l.run, l.page:settings )" />
<mvt:elseif EXPR="l.item_code EQ 'backorder'">
<mvt:do file="g.Module_Root $ '/modules/fulfill/templateorderemails.mvc'" name="l.result" value="TemplateOrderEmails_Initialize_Item_backorder( l.run, l.page:settings )" />
<mvt:elseif EXPR="l.item_code EQ 'toe_basket_contents'">
<mvt:do file="g.Module_Root $ '/modules/fulfill/templateorderemails.mvc'" name="l.result" value="TemplateOrderEmails_Initialize_Item_basket( l.run, l.page:settings )" />
<mvt:elseif EXPR="l.item_code EQ 'return'">
<mvt:do file="g.Module_Root $ '/modules/fulfill/templateorderemails.mvc'" name="l.result" value="TemplateOrderEmails_Initialize_Item_return( l.run, l.page:settings )" />
<mvt:elseif EXPR="l.item_code EQ 'shipment'">
<mvt:do file="g.Module_Root $ '/modules/fulfill/templateorderemails.mvc'" name="l.result" value="TemplateOrderEmails_Initialize_Item_shipment( l.run, l.page:settings )" />
<mvt:elseif EXPR="l.item_code EQ 'order_customer'">
<mvt:do file="g.Module_Root $ '/modules/fulfill/templateorderemails.mvc'" name="l.result" value="TemplateOrderEmails_Initialize_Item_order_customer( l.run, l.page:settings )" />
<mvt:elseif EXPR="( l.item_code EQ 'order_contents' ) OR ( l.item_code EQ 'toe_order_contents' )">
<mvt:do file="g.Module_Root $ '/modules/fulfill/templateorderemails.mvc'" name="l.result" value="TemplateOrderEmails_Initialize_Item_order_contents( l.run, l.page:settings )" />
<mvt:elseif EXPR="l.item_code EQ 'giftcertificate'">
<mvt:do file="g.Module_Root $ '/modules/fulfill/templateorderemails.mvc'" name="l.result" value="TemplateOrderEmails_Initialize_Item_giftcertificate( l.run, l.page:settings )" />
<mvt:elseif EXPR="l.item_code EQ 'digitaldownload'">
<mvt:do file="g.Module_Root $ '/modules/fulfill/templateorderemails.mvc'" name="l.result" value="TemplateOrderEmails_Initialize_Item_digitaldownload( l.run, l.page:settings )" />
<mvt:elseif EXPR="l.item_code EQ 'toe_subscription_fields'">
<mvt:do file="g.Module_Root $ '/modules/fulfill/templateorderemails.mvc'" name="l.result" value="TemplateOrderEmails_Initialize_Item_subscription( l.run, l.page:settings )" />
<mvt:elseif EXPR="l.item_code EQ 'toe_subscriptions'">
<mvt:do file="g.Module_Root $ '/modules/fulfill/templateorderemails.mvc'" name="l.result" value="TemplateOrderEmails_Initialize_Item_subscriptions( l.run, l.page:settings )" />
<mvt:else>
<mvt:assign NAME="l.result" VALUE="1"/>
</mvt:if>
</mvt:foreach>
<mvt:do file="g.Module_Root $ '/modules/fulfill/templateorderemails.mvc'" name="l.success" value="TemplateOrderEmail_Set_Originals()" />
<mvt:capture variable="l.message">
<mvt:do file="g.Module_Feature_TUI_MGR" name="l.success" value="TemplateManager_Render_Page_LowLevel( l.page:code, l.page )" />
</mvt:capture>
<mvt:if expr="NOT l.result">
<mvt:do file="g.Module_Root $ '/modules/fulfill/templateorderemails.mvc'" name="l.success" value="TemplateOrderEmail_Reset_Originals()" />
<mvt:exit/>
<mvt:elseif expr="ISNULL l.message">
<mvt:do file="g.Module_Root $ '/modules/fulfill/templateorderemails.mvc'" name="l.success" value="TemplateOrderEmail_Reset_Originals()" />
<mvt:exit/>
</mvt:if>
<p><mvt:eval expr="l.email:name" /></p>
<div id="&mvt:email_template;">
<mvt:eval expr="l.message" />
</div>
<br/>
<hr/>
<br/>
</mvt:foreach>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment