Update Hooks

Learn what update hooks are and how X-Cart uses them in the store update process.

Olga Tereshina avatar
Written by Olga Tereshina
Updated over a week ago

The general idea of any update is to overwrite the existing core and add-on files. That's simple. However, sometimes X-Cart needs to synchronize data or do some utility work. That is what update hooks do.

There are three types of update hooks.

  • Pre-update hooks run before the files' overwriting starts. These hooks work using the code of the old core.

  • Post-update hooks run after the files' overwriting completes but before the cache rebuild process is initiated. These hooks prepare a store for the cache rebuild process and work using the old core code.

  • Post-rebuild hooks run after the very first cache rebuild process has finished. They work using the code of the new core.

Update hooks of the core are located in the folder <X-Cart 5>/upgrade/. For example, the folder <X-Cart 5>/upgrade/5.1/3/ stores the update hooks for version 5.1.3. There you will find three types of files:

  • pre_upgrade.php with pre-update hooks;

  • post_upgrade.php with post-update hooks;

  • post_rebuild.php with post-rebuild hooks.

Update hooks may also exist in the add-ons if an add-on needs to synchronize data between its versions. Add-on update hooks can locate in the <X-Cart 5>/classes/Module/<DEV-ID>/<MODULE-ID>/upgrade/ folders; for example <X-Cart 5>/classes/XLite/Module/XC/ProductComparison/upgrade/.

Related pages:

Did this answer your question?