function check_action() { global $FUNCS; if (isset($_GET['kcart_action']) && $FUNCS->is_non_zero_natural($_GET['kcart_action'])) { // Sanity check - actions should be executed only when invoked on the cart template $cur_tpl = KWebpage::get_template_name(); if ($FUNCS->is_error($cur_tpl) || $cur_tpl != $this->config['tpl_cart']) { return; } $action = (int) $_GET['kcart_action']; if ($action == PP_ACTION_UPDATE_ITEMS && isset($_POST['checkout'])) { // Account for 'checkout' button implemented as a submit button instead of a link $action = PP_ACTION_CHECKOUT; } $this->current_action = $action; switch ($action) { case PP_ACTION_ADD_ITEM: /* add item */ $this->add_item(); break; case PP_ACTION_UPDATE_ITEMS: /* update items */ $this->update_items(); break; case PP_ACTION_REMOVE_ITEM: /* remove item */ $this->remove_item(); break; case PP_ACTION_EMPTY_CART: /* empty cart */ $this->empty_cart(); break; case PP_ACTION_CHECKOUT: /* checkout */ $this->checkout(); break; default: $this->current_action = PP_ACTION_CUSTOM; $this->custom_action(); /* some custom action probably implemented by subclass */ } } }