Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

ripnu

Pioneers
  • Posts

    3
  • Joined

  • Last visited

Profile Information

  • Real Name
    Gerry

ripnu's Achievements

  1. Ps, you will notice the new code that you replace it with is from the "Checkout_Process.php" file.
  2. Ok so i busted my chops trying to get this working and the only issue I came across which doesn't seem to be listed anywhere is the functionality within Paypal module. But I think Huroman pretty much explained the answer. For my situation, I use OSC 2.3.1 and a few other additions as well as QTPro to update stock quantities of different sizes of clothing. This all worked great for "Cash on Delivery" method. (I didnt test any other). It would subtract the stock bought and set items to "Out of Stock" if there was no more stock. Anyway, It worked just as was stated except when I used PayPal Standard 1.0 module. When I used that it would not update the stock level attributes, but it did update the "total stock level" which caused my OScommerce Admin site to spit out an error that QTP Doctor had detected my stock levels were "sick" and to update them. I had configured Paypal (in my paypal account settings) to use Auto Return once the customer has paid for something, thus, returning them to my website and completing the checkout process and hence forwading the IPN information. (the Auto Return url is your full domain/catalog/checkout_process.php file) So everything seemed to be correct except that it would not deduct the individual stock attribute items by the amount that was purchased. Ok i shall end my story with the fix I applied to this file: catalog/includes/modules/payment/paypal_standard.php Just replace the following code: // Stock Update - Joao Correia if (STOCK_LIMITED == 'true') { // if (DOWNLOAD_ENABLED == 'true') { $stock_query_raw = "SELECT products_quantity, pad.products_attributes_filename FROM " . TABLE_PRODUCTS . " p LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa ON p.products_id=pa.products_id LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad ON pa.products_attributes_id=pad.products_attributes_id WHERE p.products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"; // Will work with only one option for downloadable products // otherwise, we have to build the query dynamically with a loop // $products_attributes = $order->products[$i]['attributes']; 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 { $stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); } if (tep_db_num_rows($stock_query) > 0) { $stock_values = tep_db_fetch_array($stock_query); // do not decrement quantities if products_attributes_filename exists if ((DOWNLOAD_ENABLED != 'true') || (!$stock_values['products_attributes_filename'])) { $stock_left = $stock_values['products_quantity'] - $order->products[$i]['qty']; } else { $stock_left = $stock_values['products_quantity']; } tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); With this code: //++++ QT Pro: Begin Changed code $products_stock_attributes=null; if (STOCK_LIMITED == 'true') { $products_attributes = $order->products[$i]['attributes']; // if (DOWNLOAD_ENABLED == 'true') { //++++ QT Pro: End Changed Code $stock_query_raw = "SELECT products_quantity, pad.products_attributes_filename FROM " . TABLE_PRODUCTS . " p LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa ON p.products_id=pa.products_id LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad ON pa.products_attributes_id=pad.products_attributes_id WHERE p.products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"; // Will work with only one option for downloadable products // otherwise, we have to build the query dynamically with a loop //++++ QT Pro: Begin Changed code // $products_attributes = $order->products[$i]['attributes']; //++++ QT Pro: End Changed Code 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 { $stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); } if (tep_db_num_rows($stock_query) > 0) { $stock_values = tep_db_fetch_array($stock_query); $actual_stock_bought = $order->products[$i]['qty']; $download_selected = false; if ((DOWNLOAD_ENABLED == 'true') && isset($stock_values['products_attributes_filename']) && tep_not_null($stock_values['products_attributes_filename'])) { $download_selected = true; $products_stock_attributes='$$DOWNLOAD$$'; } // If not downloadable and attributes present, adjust attribute stock if (!$download_selected && is_array($products_attributes)) { $all_nonstocked = true; $products_stock_attributes_array = array(); foreach ($products_attributes as $attribute) { if ($attribute['track_stock'] == 1) { $products_stock_attributes_array[] = $attribute['option_id'] . "-" . $attribute['value_id']; $all_nonstocked = false; } } if ($all_nonstocked) { $actual_stock_bought = $order->products[$i]['qty']; } else { asort($products_stock_attributes_array, SORT_NUMERIC); $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']; 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 = ($attributes_stock_left < 1) ? $attributes_stock_values['products_stock_quantity'] : $order->products[$i]['qty']; } else { $attributes_stock_left = 0 - $order->products[$i]['qty']; tep_db_query("insert into " . TABLE_PRODUCTS_STOCK . " (products_id, products_stock_attributes, products_stock_quantity) values ('" . tep_get_prid($order->products[$i]['id']) . "', '" . $products_stock_attributes . "', '" . $attributes_stock_left . "')"); $actual_stock_bought = 0; } } } // $stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); // } // if (tep_db_num_rows($stock_query) > 0) { // $stock_values = tep_db_fetch_array($stock_query); // do not decrement quantities if products_attributes_filename exists if (!$download_selected) { $actual_stock_bought = $order->products[$i]['qty']; $stock_left = $stock_values['products_quantity'] - $actual_stock_bought; tep_db_query("UPDATE " . TABLE_PRODUCTS . " SET products_quantity = products_quantity - '" . $actual_stock_bought . "' WHERE products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); //++++ QT Pro: End Changed Code
×
×
  • Create New...