You need to enable YITH Compare plugin for product comparison to work

// Script by Sarmad Gardezi