Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How do I eliminate a payment opton for a specific procuct?


Llamma123

Recommended Posts

Posted

We have a couple items which one of our payment providers has a problem with. They say we cannot use them as a payment method for a few specific items.

 

Can anyone suggest a change that would have an effect of PayPal not being available as a payment method only when an item in the customers cart matches one of 4 item numbers?

Posted

Since you cant have multiple payment methods per order you have to disable paypal when any of the items is in the cart. You can do this by checking the cart when the class is loaded.

 

//The stock paypal module
class paypal {
var $code, $title, $description, $enabled;

// class constructor
function paypal() {
  global $order;

  $this->code = 'paypal';
  $this->title = MODULE_PAYMENT_PAYPAL_TEXT_TITLE;
  $this->description = MODULE_PAYMENT_PAYPAL_TEXT_DESCRIPTION;
  $this->sort_order = MODULE_PAYMENT_PAYPAL_SORT_ORDER;
  $this->enabled = ((MODULE_PAYMENT_PAYPAL_STATUS == 'True') ? true : false);
  ...........

 

 

 

//Paypal with excludes
class paypal {
var $code, $title, $description, $enabled;

// class constructor
function paypal() {
  global $order, $cart;

  $this->code = 'paypal';
  $this->title = MODULE_PAYMENT_PAYPAL_TEXT_TITLE;
  $this->description = MODULE_PAYMENT_PAYPAL_TEXT_DESCRIPTION;
  $this->sort_order = MODULE_PAYMENT_PAYPAL_SORT_ORDER;
  $this->enabled = ((MODULE_PAYMENT_PAYPAL_STATUS == 'True') ? true : false);


  //Exclude items from paypal
  $products = $cart->get_products();
  for ($i=0, $n=sizeof($products); $i<$n; $i++) {
	if ($products[$i]['id'] == 10 || $products[$i]['id'] == 20) 
	  $this->enabled = false;
	  break;
	}
  }
  ........

 

 

 

You could also add a field to your config table so its easy to update the product id's.

 

//MODULE_PAYMENT_PAYPAL_EXCLUDES = "10,20,30";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...