So I have a custom module that is simply one function that during Commerce checkout goes through the order or cart to create an array saying how many "products" of type 'event','donation' and 'product' there are in the cart.
Now this all works great and I use it to do multiple things such as:
- Change the title page of the checkout if someone is "donating" rather than "purchasing"
Show or hide certain checkout panes depending on whether a 'donation' or 'event' is in the cart
Render a checkout progress bar which shows certain checkout pages, again dependent on the product types currently in the cart.
My issue now is that on render of the Checkout Details page I have this one function executing 4 separate time. How would I go about triggering it once for each load of a page and storing the array in a place that can be accessed by multiple modules and template files?