Forums / Contribution-Writing Guidelines / Updating a customer-related SESSION variable on pageload with an observer

Updating a customer-related SESSION variable on pageload with an observer

Views: 5,248

Results 1 to 3 of 3
22 Jun 2021, 9:52 PM
#1
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,876
Plugin Contributions:
7

Updating a customer-related SESSION variable on pageload with an observer

When I update a custom field in the customer record, I want that to take effect on the next page load.

Initially I am using the notifier-observer in function zen_is_logged_in to get the custom field, as it is only used when the customer is logged in, but I see that function gets called multiple times on a page load so it's wasteful.

Suggestions for a better notifier/way to do this, that gets called once?

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

22 Jun 2021, 10:42 PM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Updating a customer-related SESSION variable on pageload with an observer

On the store front there is the 'NOTIFY_FOOTER_END' notifier in the respective includes/templates/YOUR_TEMPLATE/common/tpl_main_page.php

$zco_notifier->notify('NOTIFY_FOOTER_END', $current_page);

That is expected to be loaded once per page load, though also depends on the page actually loading to that point (e.g. a page error before that point will prevent execution).

Alternatively some file that gets loaded on each page load... There are plenty of places to tuck that away.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

23 Jun 2021, 8:18 AM
#3
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,876
Plugin Contributions:
7

Re: Updating a customer-related SESSION variable on pageload with an observer

That worked for me, thanks.

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...