Jump to content

attaching add to cart to a custom controller and redirecting to custom page on clicking the button


_ola

Recommended Posts

i am trying to implement a voucher section in my prestashop so i needed to create a new page by editing the product.tpl page and changing the add to cart button to buy now to buy a voucher if they click on the button buy now i created a controller called VoucherController.php to handle the form submission by changing the action value in the form to $link.getPageLink('voucher') and the controller is to display the voucherform.tpl page. but once i click on buy now it display an empty page so i turned on the debugging messages on and it gave the error Fatal error: Class 'VoucherController' not found in C:\xampp\htdocs\prestashop\classes\controller\Controller.php on line 131. how do i fix this. here is my VoucherController code

 

class VoucherControllerCore extends FrontController{

 
 
//public $php_self = 'Voucherhandler.php'; 
 
public $voucher_price;
 
public function setMedia()
  {
 parent::setMedia();
 Tools::addCSS(_THEME_CSS_DIR_.'all.css');
 Tools::addCSS(_THEME_CSS_DIR_.'app.css');
 Tools::addJS(_THEME_JS_DIR_.'all.js');
 Tools::addJS(_THEME_JS_DIR_.'app.js');
  }
 
 
public function displayContent()
{
parent::displayContent();
 
 
//self::$smarty->display(_PS_THEME_DIR_.'voucherform.tpl');
 
if (isset(_POST['voucher_price'])){
 
$this->$voucher_price = _POST['voucher_price'];
self::$smarty->display(_PS_THEME_DIR_.'voucherform.tpl');
 
//Tools::redirect('Voucherhandler.php?controller=voucher');
}
}
 
}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...