Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How can I disable paypal standard payment if item is out of stock?


rikic

Recommended Posts

Hi to everybody!

We are working on 2.3.3 and we use 3 payment method: Cod, Paypal with standard module and bank transfert.

 

when the item is "out of stock" and with "stock_allow_checkout" is true, I'd like to disable the Paypal payment in checkout_payment.php page, enabling payments only with Cod and banck transfert.

Anyone know how I can solve it?

I'm not such an expert, sorry...

 

Trying to solve my problem, in module paypal_standard.php I've changed this code

function update_status() {
 global $order;
 if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_PAYPAL_STANDARD_ZONE > 0) ) {
 $check_flag = false;
 $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_PAYPAL_STANDARD_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");
 while ($check = tep_db_fetch_array($check_query)) {
	 if ($check['zone_id'] < 1) {
	 $check_flag = true;
	 break;
	 } elseif ($check['zone_id'] == $order->billing['zone_id']) {
	 $check_flag = true;
	 break;
	 }
 }
 if ($check_flag == false) {
	 $this->enabled = false;
 }
 }
}

 

to

function update_status() {
 global $order;
 if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_PAYPAL_STANDARD_ZONE > 0) ) {
 $check_flag = false;
 $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_PAYPAL_STANDARD_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");
 while ($check = tep_db_fetch_array($check_query)) {
	 if ($check['zone_id'] < 1) {
	 $check_flag = true;
	 break;
	 } elseif ($check['zone_id'] == $order->billing['zone_id']) {
	 $check_flag = true;
	 break;
	 }
 }
 if ($check_flag == false) {
	 $this->enabled = false;
 }
}
// disable the module if the order only contains items out of stock
if ($this->enabled == true) {
if (STOCK_ALLOW_CHECKOUT == 'true') {
if ($order->products[$i]['qty'] < 1) {
$this->enabled = false;
}
}
}
}

 

but it doesn't is working.....

 

I also tried with

function update_status() {
 global $order;
 if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_PAYPAL_STANDARD_ZONE > 0) ) {
 $check_flag = false;
 $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_PAYPAL_STANDARD_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");
 while ($check = tep_db_fetch_array($check_query)) {
	 if ($check['zone_id'] < 1) {
	 $check_flag = true;
	 break;
	 } elseif ($check['zone_id'] == $order->billing['zone_id']) {
	 $check_flag = true;
	 break;
	 }
 }
 if ($check_flag == false) {
	 $this->enabled = false;
 }
}
// disable the module if the order only contains items out of stock
if ($this->enabled == true) {
if (STOCK_ALLOW_CHECKOUT == 'true') {
$stock_left = $stock_values['products_quantity'] - $order->products[$i]['qty'];
if ($stock_left < 1) {
$this->enabled = false;
}
}
}
}

 

but it doesn't work neather....

 

is there someone that can help me?

thank you very much

Riccardo

Link to comment
Share on other sites

hi guys!

I think I've found the solution.

If someone could be interested, in module paypal_standard.php you have to change function update_status() to:

function update_status() {
  global $order;
  if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_PAYPAL_STANDARD_ZONE > 0) ) {
    $check_flag = false;
    $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_PAYPAL_STANDARD_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");
    while ($check = tep_db_fetch_array($check_query)) {
	  if ($check['zone_id'] < 1) {
	    $check_flag = true;
	    break;
	  } elseif ($check['zone_id'] == $order->billing['zone_id']) {
	    $check_flag = true;
	    break;
	  }
    }
    if ($check_flag == false) {
	  $this->enabled = false;
   }
}
// disable the module if the order only contains item out of stock
if ($this->enabled == true) {
   for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
$stock_left_prod = tep_get_products_stock($order->products[$i]['id']) - $order->products[$i]['qty'];
 if (($stock_left_prod < 0) && (STOCK_ALLOW_CHECKOUT == 'true')) {
  $this->enabled = false;
  }
}
 }
}

 

I've checked it with Firefox, IE and Chrome and it seems is working.

bye

riccardo

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...