Created
May 13, 2014 19:23
-
-
Save drbyte/1a232476c4e9f1c41df8 to your computer and use it in GitHub Desktop.
Limit cart contents to max $1million (for ZC v1.3.9h)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * This file should be uploaded as: /includes/classes/observers/class.limitCartValue.php | |
| * It also requires that the config.limitCartValue.php file also be installed. See below. | |
| * Limit shopping cart total value, to mitigate against DDOS attacks | |
| */ | |
| class limitCartValue extends base { | |
| /** constructor method | |
| * Attach listeneners to events | |
| */ | |
| function __construct() { | |
| $_SESSION['cart']->attach($this, array('NOTIFIER_CART_ADD_CART_START', 'NOTIFIER_CART_ADD_CART_END', 'NOTIFIER_CART_UPDATE_QUANTITY_START', 'NOTIFIER_CART_UPDATE_QUANTITY_END')); | |
| } | |
| /** | |
| * Called by observed class when any of the notifiable events occur | |
| * | |
| * @param object $class | |
| * @param string $eventID | |
| */ | |
| function update(&$class, $eventID, $params) { | |
| if ($class->total > 1000000) zen_redirect(zen_href_link(FILENAME_TIME_OUT)); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * This file must be uploaded to /includes/auto_loaders/config.limitCartValue.php | |
| */ | |
| $autoLoadConfig[10][] = array('autoType'=>'class', | |
| 'loadFile'=>'observers/class.limitCartValue.php'); | |
| $autoLoadConfig[135][] = array('autoType'=>'classInstantiate', | |
| 'className'=>'limitCartValue', | |
| 'objectName'=>'limitCartValue'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment