Examples of Magic Data in Orders
Some Magic Data Commerce examples to try in the symbol tester. In the symbol tester you can select who the 'current user' is for testing only.
List all orders of the current user and their dates
LIST_ORDERS APPLY_EACH ORDER_STATUS_DATE DATE "d M Y" END_APPLY_EACH IMPLODE_NICELY
List all orders of the current user and the products in them with links to the product pages.
LIST_ORDERS APPLY_EACH LIST_ORDER APPLY_EACH PRODUCT_PAGE_LINK END_APPLY_EACH IMPLODE_NICELY END_APPLY_EACH HTML_OL
As above, but to handle the case of a user with no orders.
LIST_ORDERS ZERO_AS_THEN_END "No orders" APPLY_EACH LIST_ORDER APPLY_EACH PRODUCT_PAGE_LINK END_APPLY_EACH IMPLODE_NICELY END_APPLY_EACH HTML_OL
Now including the date and content of each order. Note how memories are used to save intermediate values.
LIST_ORDERS ZERO_AS_THEN_END "No orders" APPLY_EACH SAVE m1 LIST_ORDER APPLY_EACH PRODUCT_PAGE_LINK END_APPLY_EACH IMPLODE_NICELY SAVE m2 m1 RETRIEVE ORDER_STATUS_DATE DATE "d M Y" . " - " . ( m2 RETRIEVE ) END_APPLY_EACH HTML_UL
Similar to above, but now using a format to design the output.
LIST_ORDERS ZERO_AS_THEN_END "No orders" APPLY_EACH SAVE m1 LIST_ORDER APPLY_EACH PRODUCT_PAGE_LINK END_APPLY_EACH IMPLODE_NICELY SAVE m2 m1 RETRIEVE ORDER_STATUS_DATE DATE "d M Y" SAVE m3 "On {{m3}} you ordered {{m2}}" FORMAT END_APPLY_EACH HTML_UL
Similar again, but filtering orders to those marked as "Shipped".
LIST_ORDERS "Shipped" ZERO_AS_THEN_END "No orders" APPLY_EACH SAVE m1 LIST_ORDER APPLY_EACH PRODUCT_PAGE_LINK END_APPLY_EACH IMPLODE_NICELY SAVE m2 m1 RETRIEVE ORDER_STATUS_DATE DATE "d M Y" SAVE m3 "On {{m3}} {{m2}} were shipped to you." FORMAT END_APPLY_EACH HTML_UL
Similar again, but this time only the most recent order, and using FRIENDLY_DATE (from the Last Updated addon).
LIST_ORDERS 1 ZERO_AS_THEN_END "No orders" LIST_ORDER APPLY_EACH PRODUCT_PAGE_LINK END_APPLY_EACH IMPLODE_NICELY SAVE m2 m1 RETRIEVE ORDER_STATUS_DATE FRIENDLY_DATE "Human" SAVE m3 "Your most recent order was {{m3}} when you ordered {{m2}}" FORMAT
Having tested and developed from any of the above using the symbol tester, to use the expression in a content block you will need to reformat to just one line within the [% ... %].
In an html block you can keep the lines to make it easier to read/maintain.
Last updated: over a year ago