Trigger action based on Order's Item

(Emily) #1

Matrix Version: 5.5.2

We are setting up a subscription-based site with a few different levels of access.
Our ideal/planned process flow is:

  1. User selects desired level of access
  2. If user is not logged in already, they are prompted to either login or create a free account to place an order
  3. Goes through Checkout / Payment Gateway
  4. User’s account is moved to the User-Group for their level of access

What is the best way to achieve Step 4 - the moving of their User account?

  • Initially I thought a Trigger may be useful, but accessing the Order Item is difficult. There is an order_xml keyword which might output in the Triggers, but ^index modifier only seems to work on JSON and not on XML data, so I’m not sure how to access the Item (asset ID) data to make a condition of the Trigger.

  • I notice that on the Order Completion Actions of the Checkout I can create a Call REST Resource.
    This really is not my area of knowledge, and haven’t used it much before.
    Is there a way to use the REST Resource to send the Order Item data to somewhere (e.g. a trigger) which could then be used to move the user account??

(I have been using an Asset Listing to test the outputs of various keywords & modifiers. Not all Keywords listed on the Checkout Completion Action work in the asset listing… asset_attribute_details , asset_attribute_product_code , order_array do not work in the Asset Listing. order_xml does.)

Thank you in advance,

(Bart Banda) #2

This is a tricky one. You’d somehow have to set a metadata field or notice link on the order that gets created by the user (or maybe you could just source it from the asset created by user value?) and once that order is done, fire a trigger that links the user to the right group. That way you *shouldn’t need to use a REST call to then link the user hopefully. I can’t remember when the order asset gets created though, as it may only happen when the order is complete. Another thing to try, if that’s the case, is somehow use a trigger action to set a session variable of the user’s ID, and then when the order is complete, fire another trigger that uses the session ID as the source of the user’s ID to then link that to the right group?