Jump to content

How to test .php files classes like CartController?


ayin
 Share

Recommended Posts

Hello,

 

I wanted to change the default behavior of "Add to Cart" buttons so it doesn't show the popup with [Continue Shopping] and [Finalize purchase] options, but rather stay on same page (Product.tpl or ProductList.tpl) and do an Ajax Refresh to update de Top right Cart (module?) quantities and in-page product availability.

 

I started looking into the file "prestashop\htdocs\controllers\front\CartController.php" and in line 67~103:

and wish to test this code in order to understand how I can make the change described above.


 

// Make redirection

if (!$this->errors && !$this->ajax)
{
echo 'hi';
$queryString = Tools::safeOutput(Tools::getValue('query', null));
if ($queryString && !Configuration::get('PS_CART_REDIRECT'))
Tools::redirect('index.php?controller=search&search='.$queryString);
 
// Redirect to previous page
if (isset($_SERVER['HTTP_REFERER']))
{
 
if (isset($regs[3]) && !Configuration::get('PS_CART_REDIRECT'))
Tools::redirect($_SERVER['HTTP_REFERER']);
}
 
Tools::redirect('index.php?controller=order&'.(isset($this->id_product) ? 'ipa='.$this->id_product : ''));
}
 
}
elseif (!$this->isTokenValid())
Tools::redirect('index.php');

 

Any hints? : )

Edited by ayin (see edit history)

Share this post


Link to post
Share on other sites

go to the modules page, and search for the "cart block" module and then click configure.

 

Change the "ajax cart" setting to "no" and save

 

Then go to the preferences > product page in the back office, and change the "redirect after adding product to cart" setting to "previous page"

  • Like 1

Share this post


Link to post
Share on other sites

Hey bellini13,

 

but this way I won't lose the ajax Cart? I mean, each time I add an product will I refresh (HTTP POST) the product-list page? It will slow down the user experience, no?

 

Thanks for your input

 

 

go to the modules page, and search for the "cart block" module and then click configure.

 

Change the "ajax cart" setting to "no" and save

 

Then go to the preferences > product page in the back office, and change the "redirect after adding product to cart" setting to "previous page"

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More