Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save steveosoule/aca2549886528476bbd6c012ef16850e to your computer and use it in GitHub Desktop.

Select an option

Save steveosoule/aca2549886528476bbd6c012ef16850e to your computer and use it in GitHub Desktop.
Miva - Load all Subscriptions with a "Next Order Date" of Today
<mvt:comment>
|
| Configure Query
|
</mvt:comment>
<mvt:assign name="l.query:offset" value="0" />
<mvt:assign name="l.query:max" value="10" />
<mvt:assign name="l.query:sort_by" value="'id_desc'" /><mvt:comment><!-- Available Options: id_desc, name_asc, name_desc, code_asc, code_desc, total_asc, total_desc, firstdate_asc, firstdate_desc, lastdate_asc, lastdate_desc, nextdate_asc, nextdate_desc, payment_asc, payment_desc, shipping_asc, shipping_desc, termrem_asc, termrem_desc, termproc_asc, termproc_desc --></mvt:comment>
<mvt:comment>
|
| Select All Subscriptions & Join Necessary Tables
|
</mvt:comment>
<mvt:do file="g.Module_Feature_SUB_DB" name="l.success" value="Runtime_SubscriptionList_Build_Query( l.query:query )" />
<mvt:comment> Where the Subscription is Active</mvt:comment>
<mvt:do file="g.Module_Library_DB" name="l.query:where_status" value="SQL_Query_Field( 'A' )" />
<mvt:do file="g.Module_Library_DB" name="l.success" value="SQL_Query_WHERE( l.query:query, 'sub.status = ?', l.query:where_status )" />
<mvt:comment> Where Subscriptions next-order-date is Today</mvt:comment>
<mvt:do file="g.Module_Library_DB" name="l.success" value="SQL_Query_WHERE( l.query:query, 'DATE_FORMAT(FROM_UNIXTIME(sub.nextdate), \'%Y-%m-%d\') = CURDATE()', '' )" />
<mvt:comment> OR where Subscriptions next-order-date is within a relative number of days </mvt:comment>
<mvt:comment>
<!--
<mvt:do file="g.Module_Library_DB" name="l.success" value="SQL_Query_WHERE( l.query:query, 'sub.nextdate <= UNIX_TIMESTAMP(NOW() + INTERVAL 3 DAY)', '' )" />
<mvt:do file="g.Module_Library_DB" name="l.success" value="SQL_Query_WHERE( l.query:query, 'sub.nextdate >= UNIX_TIMESTAMP(NOW() - INTERVAL 3 DAY)', '' )" />
-->
</mvt:comment>
<mvt:do file="g.Module_Feature_SUB_DB" name="l.success" value="Runtime_SubscriptionList_Build_Query_ORDER_BY(l.query:query, l.query:sort_by)" />
<mvt:comment>
|
| Execute Query
|
</mvt:comment>
<mvt:do file="g.Module_Feature_SUB_DB" name="l.success" value="Runtime_SubscriptionList_Load_Query(l.query:query, l.query:offset, l.query:max, l.settings:customer_product_subscriptions:nextoffset, l.settings:customer_product_subscriptions:total_count, l.settings:customer_product_subscriptions:subscriptions)" />
<mvt:comment>
|
| Use Results
|
</mvt:comment>
<mvt:assign name="g.mvt_debug" value="glosub( miva_array_serialize( l.settings:customer_product_subscriptions ), ',', asciichar( 10 ) )" />
<!--
@@l.settings:customer_product_subscriptions
===================================
&mvt:global:mvt_debug;
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment