HTML Logo by World Wide Web Consortium ( Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS. ocPortal 9 is superseded by Composr 10.

Head over to for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.

Adding a privilege, and implementing a shopping cart discount feature

There are no pages beneath this page

Submitted by Chris Graham
This set of 4 screencasts, showing how we can add a new feature whereby certain usergroups get shopping cart product discounts.

In the first screencast I:
  • Create a language file in lang_custom/EN in which to define the English title of a new privilege. The name of the .ini file is irrelevant, ocPortal will find it.
  • Write the PHP code to create the permission, referencing my language string and giving it a codename, and putting it in the set of 'ECOMMERCE' privileges ('ECOMMERCE' is also a language string).
  • Put that code into OcCLE to run it (note the ':' before it, which tells OcCLE it is a PHP command)
  • Go to set the privilege, testing on the super-members usergroup
  • Add a super-member
  • Prove the privilege works, again via OcCLE

2013-04-16_0329 - ocProducts's library

And, here are 3 sequential screencasts for how to implement the discounting feature:
  1. 2013-04-16_0343 - ocProducts's library
  2. 2013-04-16_0352 - ocProducts's library
  3. 2013-04-16_0403 - ocProducts's library
I did this right off the bat, so you'll see me getting stuff wrong as I debug through it. I did check the code in more detail than I showed here though, and I believe this gets all the instances of the price field being used, it's not as bad as I feared.

All the files I made are attached within this TAR file:
» Download: shopping_discount.tar (38 Kb, 155 downloads so far)

CEDI change-log Post