Jump to content

Hide Specified Payment Method if Stock is Zero


Recommended Posts

Hi All..


I allow order on out of stock product on my website, the problem is it's hard to refund customer who used Credit Card payment (the process), so I want to hide this credit card payment method if product stock is zero. Any idea?


Thank you

Link to comment
Share on other sites

I think you would have to edit the payment module, which would have a function hookpayment or hookdisplaypayment.


in that function you would have to look at the carts contents, and then for each product check its stock.  if a product does not have stock, then you would return false from that function, which would hide it.

  • Like 1
Link to comment
Share on other sites

You would add the following in the payment modules hookpayment function.


This uses a core prestashop function to check the cart contents quantity.  It ignores any virtual products which would not typically have stock.

if (!$this->context->cart->isAllProductsInStock(true))
     return false;
Link to comment
Share on other sites

  • 3 years later...
  • 3 months later...
  • 2 weeks later...

This is the solution i found

I edited my hookPaymentOptions function in the module to include this

		//Dezactivare plata cu cardul pentru produse cu stoc 0
		$products = $this->context->cart->getProducts();
		foreach($products as $product){
			if($product['quantity_available'] == 0){


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...