New API discount functions

See #2473, #2457
Loop changes

Simplified after our discussion in #shopp
Merge pull request #2531 from crunnells/master

New API discount functions