Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted

Hello, I'm using the official paypal module supported by the osCommerce team, IPN v1.1.

Does anyone have some version of qt working with a paypal module such that when a customer buys an item, qt will automatically subtract the quantity just bought? I'm using Qtpro2.4 and right now, when a customer buys an item, the quantity is not subtracted automatically. I have to painstakingly go in and do it myself.

 

Thanks!

Posted

Btw,

I should note that this quantity is not subtracted if the product has attributes. Any ideas?

 

Hello, I'm using the official paypal module supported by the osCommerce team, IPN v1.1.

Does anyone have some version of qt working with a paypal module such that when a customer buys an item, qt will automatically subtract the quantity just bought? I'm using Qtpro2.4 and right now, when a customer buys an item, the quantity is not subtracted automatically. I have to painstakingly go in and do it myself.

 

Thanks!

Posted
Btw,

I should note that this quantity is not subtracted if the product has attributes. Any ideas?

 

Here is my solution:

 

BACKUP PAYPAL_IPN.PHP BEFORE TRYING THIS.

 

Open up /includes/modules/payment/paypal_ipn.php and search for

 

// Stock Update - Joao Correia
if (STOCK_LIMITED == 'true') {

 

After that, add the line

		$products_attributes = $order->products[$i]['attributes'];

 

You'll find that same line about 10 lines down. You can remove it from there.

 

Next find (a few lines further down)

			if (is_array($products_attributes)) {
			$stock_query_raw .= " AND pa.options_id = '" . $products_attributes[0]['option_id'] . "' AND pa.options_values_id = '" . $products_attributes[0]['value_id'] . "'";
		}
		$stock_query = tep_db_query($stock_query_raw);
	} else {

 

and add after

 

			if (is_array($products_attributes)) {
			$allspecial = true;
			$products_stock_attributes_array = array();
			For($k = 0, $n3 = sizeof($products_attributes); $k < $n3; $k++) {
				if ($products_attributes[$k]['special'] == 0) {
					$products_stock_attributes_array[] = $products_attributes[$k]['option_id'] . "-" . $products_attributes[$k]['value_id'];
					$allspecial = false;
				}
			}
			if (!$allspecial) {
			  asort($products_stock_attributes_array, SORT_NUMERIC);
			  reset($products_stock_attributes_array);
			  $products_stock_attributes = implode(",", $products_stock_attributes_array);
			  $attributes_stock_query = tep_db_query("select products_stock_quantity from " . TABLE_PRODUCTS_STOCK . " where products_stock_attributes = '$products_stock_attributes' AND products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
			  if (tep_db_num_rows($attributes_stock_query) > 0) {
				  $attributes_stock_values = tep_db_fetch_array($attributes_stock_query);
				  $attributes_stock_left = $attributes_stock_values['products_stock_quantity'] - $order->products[$i]['qty'];
				  if ($attributes_stock_left < 1) {
					  tep_db_query("update " . TABLE_PRODUCTS_STOCK . " set products_stock_quantity = '0' where products_stock_attributes = '$products_stock_attributes' AND products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
					  $actual_stock_bought = $attributes_stock_values['products_stock_quantity'];
				  } else {
					  tep_db_query("update " . TABLE_PRODUCTS_STOCK . " set products_stock_quantity = '" . $attributes_stock_left . "' where products_stock_attributes = '$products_stock_attributes' AND products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
					  $actual_stock_bought = $order->products[$i]['qty'];
				  }
			  } else {
				  $actual_stock_bought = 0;
			  }
		   }  else {
			 $actual_stock_bought = $order->products[$i]['qty'];
		   }
		} else {
			$actual_stock_bought = $order->products[$i]['qty'];
		}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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