Jump to content

How to disable specific payment methods for Virtual Product?


Recommended Posts

Hello,

I'm having a small issue with the Virtual Products. Because is virtual I cannot have a shipping cost but I'm having the option of Cash on Delivery. I saw some posts on the forum that said to modify the code of the payment but still i have some questions.

 

The solution that I'm thinking to do is to check if the product contains the name of the virtual product and if is true to not show the following options (COD) (which this doesn't disable the method right?). This solution will bring issues if the user wants to buy multi products. So the second solution which i think is the correct one is to check if the product contains the name of the virtual box and if the products size is equal to 1. 

My question now is how i can get the products size and if the virtual product has as a quantity 2 instead of 1 the size will be 2? 

 

Thanks anw and if you have any other solution to give feel free to say it!

 

Thank you

Edited by giwrgos (see edit history)
Link to comment
Share on other sites

  • 1 year later...

Hi, 

just found your thread.

 

This might be a solution:

 

Edit your paymentmodule file.

Look for method 

 

hookDisplayPayment or/and hookDisplayPaymentEU

 

add:

 

// Check if cart has virtual product
foreach ($this->context->cart->getProducts() AS $product)
{
if($product['is_virtual'])
return;
}

right after (should exist in most payment modules)

if(!$this->isActive())
 return;

Hope that helps you or somebody...

  • Like 1
Link to comment
Share on other sites

×
×
  • Create New...