Spatially resolved spectroscopy has been obtained for a sample of 27 star-forming (SF) galaxies selected from our deep Halpha survey of the Hercules cluster. We have applied spectral synthesis models to all emission-line spectra of this sample using the population synthesis code STARLIGHT. We have obtained fundamental parameters of the stellar components, as the mean metallicity and age, and we have corrected the emission-line spectra for underlying stellar absorption. O/H and N/O gas chemical abundances were obtained using the latest empirical calibrations. The effects of cluster environment on the chemical evolution of galaxies and on their mass-metallicity (MZ) and luminosity-metallicity (LZ) relations were studied combining the derived gas metallicities, the mean stellar metallicities and ages, the masses and luminosities of galaxies and their existing HI data. We have found that our Hercules SF galaxies divide into three main subgroups: a) chemically evolved spirals with truncated ionized-gas disks and nearly flat oxygen gradients, witnessing the effect of ram-pressure stripping, b) chemically evolved dwarfs/irregulars populating the highest local densities, possible products of tidal interactions in preprocessing events, or c) less metallic dwarf galaxies which appear to be "newcomers" to the cluster, experiencing pressure-triggered star-formation. Most Hercules SF galaxies follow well defined MZ and LZ sequences (for both O/H and N/O); though the dwarf/irregular galaxies located at the densest regions appear to be outliers to these global relations, suggesting a physical reason for the dispersion in these fundamental relations. The Hercules cluster appears to be currently assembling via the merger of smaller substructures, providing an ideal laboratory where the local environment has been found to be a key parameter to understand the chemical history of galaxies.