Jump to content
zonetown

[Contribution] QTpro - Quantity Tracking Professional

Recommended Posts

LOL Thanks for info. I'm doing single radio/drop down, either or...

 

I understand a little, but i'm not even close to your status,lol

 

I will try...and i'll talk about the first error that comes up! ha ha ha

 

mike

Share this post


Link to post
Share on other sites

I managed to get version 4.0_1_2_1 working before but now I have tried installing it on again using the same files but a clean database.

 

I made all the changes as before but when I go to add stock to a product there are no attribute options.

 

Befor I had a pull down menu, e.g. for clothing size small, medium, large and extra large.

 

Could anyone offer advice on why this might be.

 

 

Many Thanks

Share this post


Link to post
Share on other sites

PROBLEM: qtpro don't subtract stock from the inventory when costumers purchase items.

 

I have a webstore selling clothing.

 

If I have a tee-shirt in sizes s, m and large.

Say stock is 1 of each.

 

If a costumer purchases the tee-shirts in size small, the next costumer will NOT be notified of the stock of small tee-shirts beeing 0.

 

If I manually set the stock to 0 for small t-shirts, the costumer will see the "out of stock"-small in the attributes box of the product.

 

I don't know where the problem is, and I hope someone can help me with this. This mod is a very essential part of my website.

 

thanks.


Dedicated OsCommerce user. 2011 will be the return of OsC

Share this post


Link to post
Share on other sites
PROBLEM: qtpro don't subtract stock from the inventory when costumers purchase items.

 

I have a webstore selling clothing.

 

If I have a tee-shirt in sizes s, m and large.

Say stock is 1 of each.

 

If a costumer purchases the tee-shirts in size small, the next costumer will NOT be notified of the stock of small tee-shirts beeing 0.

 

If I manually set the stock to 0 for small t-shirts, the costumer will see the "out of stock"-small in the attributes box of the product.

 

I don't know where the problem is, and I hope someone can help me with this. This mod is a very essential part of my website.

 

thanks.

I would guess either downloads are enabled or the changes to checkout_process weren't applied completely.

Share this post


Link to post
Share on other sites
I managed to get version 4.0_1_2_1 working before but now I have tried installing it on again using the same files but a clean database.

 

I made all the changes as before but when I go to add stock to a product there are no attribute options.

 

Befor I had a pull down menu, e.g. for clothing size small, medium, large and extra large.

 

Could anyone offer advice on why this might be.

Many Thanks

Two possibilities I can think of:

 

1) The option isn't set to track stock

2) You're using an older version of PHP and need to change $_SERVER to $HTTP_SERVER_VARS in catalog/admin/stock.php

Share this post


Link to post
Share on other sites
OK...

 

Need those couple lines of code :)

Tried and i'm not getting anywhere

 

Please and thank you

 

mike

Give this a try. Warning its untested code!

 

In catalog/includes/classes/pad_base.php find this:

          $is_out_of_stock=tep_check_stock(tep_get_prid($this->products_id),1,$newcomb);
         if (!$is_out_of_stock | ($showoos == true)) {
           switch ($markoos) {
             case 'Left':   $newtext=($is_out_of_stock ? TEXT_OUT_OF_STOCK.' - ' : '').substr($newtext,2);
                            break;
             case 'Right':  $newtext=substr($newtext,2).($is_out_of_stock ? ' - '.TEXT_OUT_OF_STOCK : '');
                            break;
             default:       $newtext=substr($newtext,2);
                            break;
           }
           $combinations[] = array('comb'=>$newcomb, 'id'=>substr($newid,1), 'text'=>$newtext);
           if ($newisselected) $selected_combination = sizeof($combinations)-1;
         }

 

and replace it with this:

          $is_out_of_stock=tep_check_stock(tep_get_prid($this->products_id),1,$newcomb);
         if (!$is_out_of_stock | ($showoos == true)) {
           if (!$is_out_of_stock) {
             $newtext.=' - '.tep_get_products_stock(tep_get_prid($this->products_id),$newcomb).' in stock';
           }
           switch ($markoos) {
             case 'Left':   $newtext=($is_out_of_stock ? TEXT_OUT_OF_STOCK.' - ' : '').substr($newtext,2);
                            break;
             case 'Right':  $newtext=substr($newtext,2).($is_out_of_stock ? ' - '.TEXT_OUT_OF_STOCK : '');
                            break;
             default:       $newtext=substr($newtext,2);
                            break;
           }
           $combinations[] = array('comb'=>$newcomb, 'id'=>substr($newid,1), 'text'=>$newtext);
           if ($newisselected) $selected_combination = sizeof($combinations)-1;
         }

 

This should work for the single radioset or single dropdown plugins and will display the quantity like this "small - 5 in stock".

Share this post


Link to post
Share on other sites

I was wondering if it is possible to solve these problems I have:

Presently I sell tiny little down pillows...I also sell bedspreads and sheet sets which need pillows. With QTPRO I have added the pillows as a pull-down option so that a customer can add pillows if they want. However when I add stock I have to add 1 sheet set with pillows and 1 sheet set without pillows, when I really only have 1 sheet set.....That?s the first problem, the second problem is:

Lets say I have one sheet set and 3 pillows (or 1 double set of pillows = 2 pillows and 1 twin pillow = 1 pillow, total 3 pillows)

So I sell one double sheet set with a double set of pillows, but after that I sell another double sheet set, but I have only 1 pillow left....oscommerce doesn?t know this because it doesn?t track the attributes like that....

So what I would like is something that can do these two things giving me a more realistic inventory count and I am not sure which one of these contributions will accomplish this....If you have any thought or comments on that I would surely love to hear what your recommendation might be.

Teresa

Share this post


Link to post
Share on other sites
I was wondering if it is possible to solve these problems I have:

Presently I sell tiny little down pillows...I also sell bedspreads and sheet sets which need pillows. With QTPRO I have added the pillows as a pull-down option so that a customer can add pillows if they want. However when I add stock I have to add 1 sheet set with pillows and 1 sheet set without pillows, when I really only have 1 sheet set.....That?s the first problem, the second problem is:

Lets say I have one sheet set and 3 pillows (or 1 double set of pillows = 2 pillows and 1 twin pillow = 1 pillow, total 3 pillows)

So I sell one double sheet set with a double set of pillows, but after that I sell another double sheet set, but I have only 1 pillow left....oscommerce doesn?t know this because it doesn?t track the attributes like that....

So what I would like is something that can do these two things giving me a more realistic inventory count and I am not sure which one of these contributions will accomplish this....If you have any thought or comments on that I would surely love to hear what your recommendation might be.

Teresa

QTPro isn't capable of what you want to do. Take a look at the Master Products contribution. I believe it will do what you want.

Share this post


Link to post
Share on other sites
I would guess either downloads are enabled or the changes to checkout_process weren't applied completely.

Hello Ralphday,

thanks for your reply. I really appreciate it.

Downloads are not enabled. Both enable download and download by re-direct are set to false.

 

I will try to look over the checkout_process.

 

Btw; where can i find the fix for 100% width (regarding the image that moves up to the text). I searched the forum and just cant find it.

 

Thanks a million for your time and effort.

 

Mike


Dedicated OsCommerce user. 2011 will be the return of OsC

Share this post


Link to post
Share on other sites

Dear Ralphday,

I am using the PWA mod. (so that costumers can make purchases without creating an account. Could this be causing the troubble.

Here is my checkout_process source code:

<?php

/*

      QT Pro Version 4.0 modifications

   

      Copyright © 2004 Ralph Day

      Released under the GNU General Public License

 

      Based on prior works released under the GNU General Public License:

        QT Pro prior versions

          Ralph Day, October 2004

          Tom Wojcik aka TomThumb 2004/07/03 based on work by Michael Coffman aka coffman

          FREEZEHELL - 08/11/2003 freezehell@hotmail.com Copyright © 2003 IBWO

          Joseph Shain, January 2003

        osCommerce MS2

          Copyright © 2003 osCommerce

         

      Modifications made:

        11/2004 - Rename products_options column from special to products_options_track_stock

                  Allow attribute stock to go negative

                  Save products_stock_attributes in order to facilitate remove order & restock

                  Miscellaneous cleanup

 

********************************************************************************

***********

 

  $Id: checkout_process.php,v 1.128 2003/05/28 18:00:29 hpdl Exp $

 

  osCommerce, Open Source E-Commerce Solutions

  http://www.oscommerce.com

 

  Copyright © 2003 osCommerce

 

  Amended for Attributes Inventory - FREEZEHELL - 08/11/2003 freezehell@hotmail.com

  Copyright © 2003 IBWO

 

 

  Released under the GNU General Public License

*/

 

  include('includes/application_top.php');

 

// if the customer is not logged on, redirect them to the login page

  if (!tep_session_is_registered('customer_id')) {

    $navigation->set_snapshot(array('mode' => 'SSL', 'page' => FILENAME_CHECKOUT_PAYMENT));

    tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));

  }

 

  if (!tep_session_is_registered('sendto')) {

    tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));

  }

 

  if ( (tep_not_null(MODULE_PAYMENT_INSTALLED)) && (!tep_session_is_registered('payment')) ) {

    tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));

}

 

// avoid hack attempts during the checkout procedure by checking the internal cartID

  if (isset($cart->cartID) && tep_session_is_registered('cartID')) {

    if ($cart->cartID != $cartID) {

      tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));

    }

  }

 

  include(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_PROCESS);

 

// load selected payment module

  require(DIR_WS_CLASSES . 'payment.php');

  $payment_modules = new payment($payment);

 

// load the selected shipping module

  require(DIR_WS_CLASSES . 'shipping.php');

  $shipping_modules = new shipping($shipping);

 

  require(DIR_WS_CLASSES . 'order.php');

  $order = new order;

 

// load the before_process function from the payment modules

  $payment_modules->before_process();

 

  require(DIR_WS_CLASSES . 'order_total.php');

  $order_total_modules = new order_total;

 

  $order_totals = $order_total_modules->process();

 

  $sql_data_array = array('customers_id' => $customer_id,

                          'customers_name' => $order->customer['firstname'] . ' ' . $order->customer['lastname'],

                          'customers_company' => $order->customer['company'],

                          'customers_street_address' => $order->customer['street_address'],

                          'customers_suburb' => $order->customer['suburb'],

                          'customers_city' => $order->customer['city'],

                          'customers_postcode' => $order->customer['postcode'],

                          'customers_state' => $order->customer['state'],

                          'customers_country' => $order->customer['country']['title'],

                          'customers_telephone' => $order->customer['telephone'],

                          'customers_email_address' => $order->customer['email_address'],

                          'customers_address_format_id' => $order->customer['format_id'],

                          'delivery_name' => $order->delivery['firstname'] . ' ' . $order->delivery['lastname'],

                          'delivery_company' => $order->delivery['company'],

                          'delivery_street_address' => $order->delivery['street_address'],

                          'delivery_suburb' => $order->delivery['suburb'],

                          'delivery_city' => $order->delivery['city'],

                          'delivery_postcode' => $order->delivery['postcode'],

                          'delivery_state' => $order->delivery['state'],

                          'delivery_country' => $order->delivery['country']['title'],

                          'delivery_address_format_id' => $order->delivery['format_id'],

                          'billing_name' => $order->billing['firstname'] . ' ' . $order->billing['lastname'],

                          'billing_company' => $order->billing['company'],

                          'billing_street_address' => $order->billing['street_address'],

                          'billing_suburb' => $order->billing['suburb'],

                          'billing_city' => $order->billing['city'],

                          'billing_postcode' => $order->billing['postcode'],

                          'billing_state' => $order->billing['state'],

                          'billing_country' => $order->billing['country']['title'],

                          'billing_address_format_id' => $order->billing['format_id'],

                          'payment_method' => $order->info['payment_method'],

                          'cc_type' => $order->info['cc_type'],

                          'cc_owner' => $order->info['cc_owner'],

                          'cc_number' => $order->info['cc_number'],

                          'cc_expires' => $order->info['cc_expires'],

                          'date_purchased' => 'now()',

                          'orders_status' => $order->info['order_status'],

                          'currency' => $order->info['currency'],

                          'currency_value' => $order->info['currency_value']);

  tep_db_perform(TABLE_ORDERS, $sql_data_array);

  $insert_id = tep_db_insert_id();

  for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) {

    $sql_data_array = array('orders_id' => $insert_id,

                            'title' => $order_totals[$i]['title'],

                            'text' => $order_totals[$i]['text'],

                            'value' => $order_totals[$i]['value'],

                            'class' => $order_totals[$i]['code'],

                            'sort_order' => $order_totals[$i]['sort_order']);

    tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array);

  }

 

  $customer_notification = (SEND_EMAILS == 'true') ? '1' : '0';

  $sql_data_array = array('orders_id' => $insert_id,

                          'orders_status_id' => $order->info['order_status'],

                          'date_added' => 'now()',

                          'customer_notified' => $customer_notification,

                          'comments' => $order->info['comments']);

  tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);

 

// initialized for the email confirmation

  $products_ordered = '';

  $subtotal = 0;

  $total_tax = 0;

 

  for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {

// Stock Update - Joao Correia

    if (STOCK_LIMITED == 'true') {

//++++ QT Pro: Begin Changed code

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

//++++ QT Pro: End Changed Code

      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

//++++ 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);

//++++ QT Pro: Begin Changed code

            $actual_stock_bought = $order->products[$i]['qty'];

        } else {

            if (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;

                  }

                }

            } else {

                $actual_stock_bought = $order->products[$i]['qty'];

            }

//++++ QT Pro: End Changed Code

        $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'])) {

//++++ QT Pro: Begin Changed code

                $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

        if ( ($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') ) {

          tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");

        }

      }

    }

//++++ QT Pro: Begin Changed code

    }

//++++ QT Pro: End Changed Code

// Update products_ordered (for bestsellers list)

    tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $order->products[$i]['qty']) . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");

 

//++++ QT Pro: Begin Changed code

    if (!isset($products_stock_attributes)) $products_stock_attributes=null;

    $sql_data_array = array('orders_id' => $insert_id,

                            'products_id' => tep_get_prid($order->products[$i]['id']),

                            'products_model' => $order->products[$i]['model'],

                            'products_name' => $order->products[$i]['name'],

                            'products_price' => $order->products[$i]['price'],

                            'final_price' => $order->products[$i]['final_price'],

                            'products_tax' => $order->products[$i]['tax'],

                            'products_quantity' => $order->products[$i]['qty'],

                            'products_stock_attributes' => $products_stock_attributes);

//++++ QT Pro: End Changed Code

    tep_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);

    $order_products_id = tep_db_insert_id();

 

//------insert customer choosen option to order--------

    $attributes_exist = '0';

    $products_ordered_attributes = '';

    if (isset($order->products[$i]['attributes'])) {

      $attributes_exist = '1';

      for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {

        if (DOWNLOAD_ENABLED == 'true') {

          $attributes_query = "select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename

                              from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa

                              left join " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad

                                on pa.products_attributes_id=pad.products_attributes_id

                              where pa.products_id = '" . $order->products[$i]['id'] . "'

                                and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "'

                                and pa.options_id = popt.products_options_id

                                and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "'

                                and pa.options_values_id = poval.products_options_values_id

                                and popt.language_id = '" . $languages_id . "'

                                and poval.language_id = '" . $languages_id . "'";

          $attributes = tep_db_query($attributes_query);

        } else {

          $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $order->products[$i]['id'] . "' and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $languages_id . "' and poval.language_id = '" . $languages_id . "'");

        }

        $attributes_values = tep_db_fetch_array($attributes);

 

        $sql_data_array = array('orders_id' => $insert_id,

                                'orders_products_id' => $order_products_id,

                                'products_options' => $attributes_values['products_options_name'],

                                'products_options_values' => $attributes_values['products_options_values_name'],

                                'options_values_price' => $attributes_values['options_values_price'],

                                'price_prefix' => $attributes_values['price_prefix']);

        tep_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array);

 

        if ((DOWNLOAD_ENABLED == 'true') && isset($attributes_values['products_attributes_filename']) && tep_not_null($attributes_values['products_attributes_filename'])) {

          $sql_data_array = array('orders_id' => $insert_id,

                                  'orders_products_id' => $order_products_id,

                                  'orders_products_filename' => $attributes_values['products_attributes_filename'],

                                  'download_maxdays' => $attributes_values['products_attributes_maxdays'],

                                  'download_count' => $attributes_values['products_attributes_maxcount']);

          tep_db_perform(TABLE_ORDERS_PRODUCTS_DOWNLOAD, $sql_data_array);

        }

        $products_ordered_attributes .= "\n\t" . $attributes_values['products_options_name'] . ' ' . $attributes_values['products_options_values_name'];

      }

    }

//------insert customer choosen option eof ----

    $total_weight += ($order->products[$i]['qty'] * $order->products[$i]['weight']);

    $total_tax += tep_calculate_tax($total_products_price, $products_tax) * $order->products[$i]['qty'];

    $total_cost += $total_products_price;

 

    $products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n";

  }

 

// lets start with the email confirmation

// DDB - 041103 - Add test for PWA : no display of invoice URL if PWA customer

if (!tep_session_is_registered('noaccount'))

{

  $email_order = STORE_NAME . "\n" .

                EMAIL_SEPARATOR . "\n" .

                EMAIL_TEXT_ORDER_NUMBER . ' ' . $insert_id . "\n" .

                EMAIL_TEXT_INVOICE_URL . ' ' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $insert_id, 'SSL', false) . "\n" .

                EMAIL_TEXT_DATE_ORDERED . ' ' . strftime(DATE_FORMAT_LONG) . "\n\n";

  if ($order->info['comments'])

  {

    $email_order .= tep_db_output($order->info['comments']) . "\n\n";

  }

  $email_order .= EMAIL_TEXT_PRODUCTS . "\n" .

                  EMAIL_SEPARATOR . "\n" .

                  $products_ordered .

                  EMAIL_SEPARATOR . "\n";

} else {

  $email_order = STORE_NAME . "\n" .

                EMAIL_SEPARATOR . "\n" .

                EMAIL_TEXT_ORDER_NUMBER . ' ' . $insert_id . "\n" .

                EMAIL_TEXT_DATE_ORDERED . ' ' . strftime(DATE_FORMAT_LONG) . "\n\n";

  if ($order->info['comments']) {

    $email_order .= tep_db_output($order->info['comments']) . "\n\n";

  }

  $email_order .= EMAIL_TEXT_PRODUCTS . "\n" .

                  EMAIL_SEPARATOR . "\n" .

                  $products_ordered .

                  EMAIL_SEPARATOR . "\n";

  }

 

  for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) {

    $email_order .= strip_tags($order_totals[$i]['title']) . ' ' . strip_tags($order_totals[$i]['text']) . "\n";

  }

 

  if ($order->content_type != 'virtual') {

    $email_order .= "\n" . EMAIL_TEXT_DELIVERY_ADDRESS . "\n" .

                    EMAIL_SEPARATOR . "\n" .

                    tep_address_label($customer_id, $sendto, 0, '', "\n") . "\n";

  }

 

  $email_order .= "\n" . EMAIL_TEXT_BILLING_ADDRESS . "\n" .

                  EMAIL_SEPARATOR . "\n" .

                  tep_address_label($customer_id, $billto, 0, '', "\n") . "\n\n";

  if (is_object($$payment)) {

    $email_order .= EMAIL_TEXT_PAYMENT_METHOD . "\n" .

                    EMAIL_SEPARATOR . "\n";

    $payment_class = $$payment;

    $email_order .= $payment_class->title . "\n\n";

    if ($payment_class->email_footer) {

      $email_order .= $payment_class->email_footer . "\n\n";

    }

  }

  tep_mail($order->customer['firstname'] . ' ' . $order->customer['lastname'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

 

// send emails to other people

  if (SEND_EXTRA_ORDER_EMAILS_TO != '') {

    tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

  }

 

// load the after_process function from the payment modules

  $payment_modules->after_process();

 

  $cart->reset(true);

 

// unregister session variables used during checkout

  tep_session_unregister('sendto');

  tep_session_unregister('billto');

  tep_session_unregister('shipping');

  tep_session_unregister('payment');

  tep_session_unregister('comments');

 

  tep_redirect(tep_href_link(FILENAME_CHECKOUT_SUCCESS, '', 'SSL'));

 

  require(DIR_WS_INCLUDES . 'application_bottom.php');

?>

 

I really hope you can help. (the PWA code is in the end of the sourcecode).

Thanks.

Mike.


Dedicated OsCommerce user. 2011 will be the return of OsC

Share this post


Link to post
Share on other sites
Hello Ralphday,

thanks for your reply. I really appreciate it.

Downloads are not enabled. Both enable download and download by re-direct are set to false.

 

I will try to look over the checkout_process.

 

Btw; where can i find the fix for 100% width (regarding the image that moves up to the text). I searched the forum and just cant find it.

 

Thanks a million for your time and effort.

 

Mike

 

Mike,

 

Your checkout_process.php looks fine. Check to be sure that in Admin|Stock you have Check Stock Level set to true and Subtract Stock set to true. I suspect you have Subtract Stock set to false since manually setting the stock to zero works properly. I should have thought of that first. The default install has Subtract Stock set to false.

 

The width fix for the image pushed up against the text is here:

 

http://forums.oscommerce.com/index.php?sho...73entry504873

 

- Ralph

Share this post


Link to post
Share on other sites

Dear Ralph,

 

thanks a lot for the link to the fix width.

 

My other problem still exists :(

I have the following set:

 

Stock

 

Title Value Action

Check stock level true

Subtract stock true

Allow Checkout true

Mark product out of stock ***

Stock Re-order level 1

Check stock level

 

 

Check to see if sufficent stock is available

 

Date Added: 20/11/2004


Dedicated OsCommerce user. 2011 will be the return of OsC

Share this post


Link to post
Share on other sites

Dear Ralph,

 

thanks a lot for the link to the fix width.

 

My other problem still exists :(

I have the following set:

 

Stock

 

Check stock level true

Subtract stock true

Allow Checkout true

Mark product out of stock ***

Stock Re-order level 1

 

 

I hope you have other ideas to solve my problem.

 

Thanks a lot.

Mike.


Dedicated OsCommerce user. 2011 will be the return of OsC

Share this post


Link to post
Share on other sites
Dear Ralph,

 

thanks a lot for the link to the fix width.

 

My other problem still exists :(

I have the following set:

 

Stock 

 

Check stock level true 

Subtract stock true 

Allow Checkout true 

Mark product out of stock *** 

Stock Re-order level 1 

I hope you have other ideas to solve my problem.

 

Thanks a lot.

Mike.

Hmmmm... :blink: Lets verify a couple of things to make sure I'm understanding this right. You have a T-shirt with one option - Color. That option is set to Track Stock? yes. You set the stock for color White to 1. You buy one T-shirt, color white. Now when you go to the product page for the T-shirt again it doesn't say that color white is out of stock. Though you didn't explicitly say it I assume you go back to look at the stock for color white and it still shows 1 in stock since you say you can manually set the stock to 0 and it shows out of stock on the product page.

 

I just tested your checkout_process.php and it works fine. So, if my assumptions are correct then something in your configuration is either preventing checkout_process.php from running or is stopping it before it gets to the QT Pro code. Check your php_error.log for problems. What shipping method and payment method are you using? Test it with flat rate shipping and cash on delivery if you are using any others. Errors in payment or shipping modules can stop checkout_process execution before it gets to the QT Pro code. If you've integrated the Paypal IPN module it duplicates checkout_process code in pieces in its own code and doesn't use what is in checkout_process. You need to dig and find where to put the QT Pro code to subtract stock in the Paypal IPN code.

 

HTH - Ralph

Share this post


Link to post
Share on other sites
Hmmmm...  :blink:  Lets verify a couple of things to make sure I'm understanding this right.  You have a T-shirt with one option - Color. That option is set to Track Stock? yes.  You set the stock for color White to 1.  You buy one T-shirt, color white.  Now when you go to the product page for the T-shirt again it doesn't say that color white is out of stock.  Though you didn't explicitly say it I assume you go back to look at the stock for color white and it still shows 1 in stock since you say you can manually set the stock to 0 and it shows out of stock on the product page.

Hello Ralph,

once again I must thank you for all your effort and time - It's amazing.

 

I have t-shirs (and all other products) with only 1 option, that is sizes. This attribute is set "track stock = yes".

When the item is sold, the stock doesn't change. Like you said.

If I manually adjust the stock to 0, the attribute will go out of stock.

When I try to use COD I realise it works better. But it doesn't work completely the way it should.

 

I use the multiple dropdown menu.

When I use flat rate shipping and COD, the attribute doesnt show "out of stock", BUT the QT pro writes the sentence with "the attributes you have selected for this product is currently out of stock" on the screen with the product.

This means that somewhere the QT pro DOES register that the total stock of the product is zero??

But perhaps this is just the regular oscommerce stock counter that goes to zero?

 

I just tested your checkout_process.php and it works fine.  So, if my assumptions are correct then something in your configuration is either preventing checkout_process.php from running or is stopping it before it gets to the QT Pro code.  Check your php_error.log for problems.  What shipping method and payment method are you using?  Test it with flat rate shipping and cash on delivery if you are using any others.  Errors in payment or shipping modules can stop checkout_process execution before it gets to the QT Pro code.  If you've integrated the Paypal IPN module it duplicates checkout_process code in pieces in its own code and doesn't use what is in checkout_process.  You need to dig and find where to put the QT Pro code to subtract stock in the Paypal IPN code.

HTH - Ralph

I have converted all the payment modules to my regional language, so I will try to compare them with my original oscommerce files - but really don't know where the problem lies.

I will also look at the error log.

 

Thanks again.

 

Mike.


Dedicated OsCommerce user. 2011 will be the return of OsC

Share this post


Link to post
Share on other sites
When I try to use COD I realise it works better. But it doesn't work completely the way it should.

 

If it works differently with different payment modules there is definitely a problem with the payment modules.

 

I use the multiple dropdown menu.

When I use flat rate shipping and COD, the attribute doesnt show "out of stock", BUT the QT pro writes the sentence with "the attributes you have selected for this product is currently out of stock" on the screen with the product.

This means that somewhere the QT pro DOES register that the total stock of the product is zero??

Do you you have Mark Out of Stock Attributes set to Left or Right in Admin|Configuration|Product Information. If its not, what you describe would happen.

 

But perhaps this is just the regular oscommerce stock counter that goes to zero?

None of the QT Pro code looks at the osCommerce stock (that shows on the admin prduct edit page) - it just keeps it updated. It only looks at the attribute stock. As an outside chance you could delete all of the rows in the PRODUCTS_STOCK table. Its possible to mess it up a bit if you were playing with multiple options for the product and then dropped down to a single option. I would think the stock page would look funny if that was the case but it might be worth a try.

 

I have converted all the payment modules to my regional language, so I will try to compare them with my original oscommerce files - but really don't know where the problem lies.

Are you using a different language id? If so, check your updates for the text for the new language.

Share this post


Link to post
Share on other sites

If it works differently with different payment modules there is definitely a problem with the payment modules.

 

I use the multiple dropdown menu.

When I use flat rate shipping and COD, the attribute doesnt show "out of stock", BUT the QT pro writes the sentence with "the attributes you have selected for this product is currently out of stock" on the screen with the product.

This means that somewhere the QT pro DOES register that the total stock of the product is zero??

Do you you have Mark Out of Stock Attributes set to Left or Right in Admin|Configuration|Product Information. If its not, what you describe would happen.

 

But perhaps this is just the regular oscommerce stock counter that goes to zero?

None of the QT Pro code looks at the osCommerce stock (that shows on the admin prduct edit page) - it just keeps it updated. It only looks at the attribute stock. As an outside chance you could delete all of the rows in the PRODUCTS_STOCK table. Its possible to mess it up a bit if you were playing with multiple options for the product and then dropped down to a single option. I would think the stock page would look funny if that was the case but it might be worth a try.

 

I have converted all the payment modules to my regional language, so I will try to compare them with my original oscommerce files - but really don't know where the problem lies.

Are you using a different language id? If so, check your updates for the text for the new language.

 

Hello Ralph,

Yes I have the Mark Out of Stock Attributes set to Left.

 

Regarding the PRODUCTS_STOCK, is that in the sql database you are talking?

 

I am using another language ID, which is DK.

I checked all the updates so far, and haven't really found anything wrong.

I am using beyond compare.

I'll look compare some more tomorrow, as it is midnight here know.

 

Thanks again for your help.

 

Mike.


Dedicated OsCommerce user. 2011 will be the return of OsC

Share this post


Link to post
Share on other sites
Regarding the PRODUCTS_STOCK, is that in the sql database you are talking?

Yes, its one of the tables in the mysql database.

 

I am using another language ID, which is DK.

I don't think this is it since you seem to indicate it works if you manually set the attribute out of stock. But make sure you have the TEXT_OUT_OF_STOCK constant defined with something other than an empty string in catalog/includes/languages/danish/product_info.php Also if this was the problem you would see " - S" for an out of stock size S.

 

I'm finding this problem to be a bit confusing as it seems to work in one case, partially works in another and doesn't work in another. So lets make sure I understand you again. Here is what I think I have read in your posts:

 

You have a product , call it "Cool T-Shirt". You have an option Size with option values S, M, L and XL. You have added those option values as attributes of "Cool T-Shirt". You have added a stock of 1 to "Cool T-Shirt" for each of the option values. The product page for "Cool T-Shirt" displays correctly showing S, M, L and XL values for Size. All four values can be selected and added to cart with no indication of out of stock. The three cases below all assume you are starting at this point with all option values in stock.

 

Case 1: You go back to the stock page for "Cool T-Shirt" and set the stock for Size S to 0. The product page for "Cool T-Shirt" now displays with Size option values Out of stock - S, M, L, XL. If you select Out of stock - S you get a message below the options that says something like "The attribute combination you have selected is out of stock....". M, L and XL don't display the message. This is how QT Pro should work.

 

Case 2: You purchase one "Cool T-Shirt" Size S and checkout using COD payment method. The product page for "Cool T-Shirt" now displays with size option values S, M, L, XL. If you select S you get a message below the options that says something like "The attribute combination you have selected is out of stock....". M, L and XL don't display the message. If you go to the stock page for "Cool T-Shirt" what does the stock show for Size S (I would expect it doesn't show any stock).

 

Case 3: You purchase one "Cool T-Shirt" Size S and checkout using some payment method other than COD. The product page fo "Cool T-Shirt" now displays with size option values S, M, L, XL. If you select S you *do not* get a message below the options that says something like "The attribute combination you have selected is out of stock....". M, L and XL also don't display the message. If you go to the stock page for "Cool T-Shirt" the stock for Size S shows 1.

 

Case 1 and Case 2 behaving differently is what puzzles me. The only thing that I can see that would cause Case 2 is the products_stock table issue I mentioned before but that should cause the same problem in case 1. It can't hurt to clear out the table and reneter your stock to see if it helps. Case 3 seems to indicate a problem with the payment method module.

 

HTH - Ralph

Share this post


Link to post
Share on other sites

Hello Ralph,

 

 

I understand that English not being my mother tongue, I might be confusing with my posts sometimes ;)

 

Case 1:

If S is set to stock = 0, I am still allowed to put the item in the basket. I get no out of stock or error messages otherwise.

 

Case 2:

Nothing happens. S looks like it is still in stock after beeing purchased with COD.

I can add Small to the basket, i get no error messages.

When I go to stock page the size small is still 1 in stock.

 

Case 3:

Same scenario happens as in case 2.

 

Please be aware that this is with the multiple dropdown used.

 

 

I checked all checkout and payment modules with the original oscommerce package, and there is nothing different than the language translation I have done.

 

I am considering running through all files with beyond compare, but this will be an awfull job :)

I am more hopefull to your sql idea..

 

I will look into it.

 

Thanks again for all your help.


Dedicated OsCommerce user. 2011 will be the return of OsC

Share this post


Link to post
Share on other sites
Hello Ralph,

I understand that English not being my mother tongue, I might be confusing with my posts sometimes ;)

Your English is great. Its just difficult to describe these things. It can be difficult to understand the posts trying to describe problems from native English speakers including myself. The hard part is that we all have our "filters" on what's relevant to the problem and don't always describe everything.

 

Case 1:

If S is set to stock = 0, I am still allowed to put the item in the basket. I get no out of stock or error messages otherwise.

You should be able to put the item in the basket as you said earlier that you have Allow Checkout set to True. You should see *** next to the item in the basket and a message at the bottom of the basket page that the item is out of stock.

 

When you say you get no out of stock or error messages otherwise do you mean that Case 1 is the only case where you see Out of Stock messages? In Case 1 do you see on the product page both the size dropdown shows "Out of stock - S" and the "The attribute combination you have selected is out of stock...." messages displays when you select S?

 

Case 2:

Nothing happens. S looks like it is still in stock after beeing purchased with COD.

I can add Small to the basket, i get no error messages.

When I go to stock page the size small is still 1 in stock.

 

Case 3:

Same scenario happens as in case 2.

Ok, so stock isn't getting updated no matter which payment module you use.

To narrow down why you'll need to put in some echo statements in checkout_process.php to find out where it quits processing. Try this version of checkout_process.php and see what it writes out when you complete checkout. Its the version of checkout_process.php you posted earlier with a bunch of echo's added.

 

<?php
/*
     QT Pro Version 4.0 modifications
   
     Copyright ? 2004 Ralph Day
     Released under the GNU General Public License
 
     Based on prior works released under the GNU General Public License:
       QT Pro prior versions
         Ralph Day, October 2004
         Tom Wojcik aka TomThumb 2004/07/03 based on work by Michael Coffman aka coffman
         FREEZEHELL - 08/11/2003 freezehell@hotmail.com Copyright ? 2003 IBWO
         Joseph Shain, January 2003
       osCommerce MS2
         Copyright ? 2003 osCommerce
         
     Modifications made:
       11/2004 - Rename products_options column from special to products_options_track_stock
                 Allow attribute stock to go negative
                 Save products_stock_attributes in order to facilitate remove order & restock
                 Miscellaneous cleanup
 
********************************************************************************
***********

 $Id: checkout_process.php,v 1.128 2003/05/28 18:00:29 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright ? 2003 osCommerce
 
 Amended for Attributes Inventory - FREEZEHELL - 08/11/2003 freezehell@hotmail.com
 Copyright ? 2003 IBWO


 Released under the GNU General Public License
*/

 include('includes/application_top.php');

// if the customer is not logged on, redirect them to the login page
 if (!tep_session_is_registered('customer_id')) {
   $navigation->set_snapshot(array('mode' => 'SSL', 'page' => FILENAME_CHECKOUT_PAYMENT));
   tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
 }
 
 if (!tep_session_is_registered('sendto')) {
   tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
 }

 if ( (tep_not_null(MODULE_PAYMENT_INSTALLED)) && (!tep_session_is_registered('payment')) ) {
   tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
}

// avoid hack attempts during the checkout procedure by checking the internal cartID
 if (isset($cart->cartID) && tep_session_is_registered('cartID')) {
   if ($cart->cartID != $cartID) {
     tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
   }
 }

 include(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_PROCESS);

// load selected payment module
 require(DIR_WS_CLASSES . 'payment.php');
 $payment_modules = new payment($payment);
 echo "<p>payment module loaded<p>";

// load the selected shipping module
 require(DIR_WS_CLASSES . 'shipping.php');
 $shipping_modules = new shipping($shipping);
 echo "<p>shipping module loaded<p>";

 require(DIR_WS_CLASSES . 'order.php');
 $order = new order;
 echo "<p>order object created<p>";

// load the before_process function from the payment modules
 $payment_modules->before_process();
 echo "<p>payment module before process complete<p>";

 require(DIR_WS_CLASSES . 'order_total.php');
 $order_total_modules = new order_total;

 $order_totals = $order_total_modules->process();
 echo "<p>order total process complete<p>";

 $sql_data_array = array('customers_id' => $customer_id,
                         'customers_name' => $order->customer['firstname'] . ' ' . $order->customer['lastname'],
                         'customers_company' => $order->customer['company'],
                         'customers_street_address' => $order->customer['street_address'],
                         'customers_suburb' => $order->customer['suburb'],
                         'customers_city' => $order->customer['city'],
                         'customers_postcode' => $order->customer['postcode'], 
                         'customers_state' => $order->customer['state'], 
                         'customers_country' => $order->customer['country']['title'], 
                         'customers_telephone' => $order->customer['telephone'], 
                         'customers_email_address' => $order->customer['email_address'],
                         'customers_address_format_id' => $order->customer['format_id'], 
                         'delivery_name' => $order->delivery['firstname'] . ' ' . $order->delivery['lastname'], 
                         'delivery_company' => $order->delivery['company'],
                         'delivery_street_address' => $order->delivery['street_address'], 
                         'delivery_suburb' => $order->delivery['suburb'], 
                         'delivery_city' => $order->delivery['city'], 
                         'delivery_postcode' => $order->delivery['postcode'], 
                         'delivery_state' => $order->delivery['state'], 
                         'delivery_country' => $order->delivery['country']['title'], 
                         'delivery_address_format_id' => $order->delivery['format_id'], 
                         'billing_name' => $order->billing['firstname'] . ' ' . $order->billing['lastname'], 
                         'billing_company' => $order->billing['company'],
                         'billing_street_address' => $order->billing['street_address'], 
                         'billing_suburb' => $order->billing['suburb'], 
                         'billing_city' => $order->billing['city'], 
                         'billing_postcode' => $order->billing['postcode'], 
                         'billing_state' => $order->billing['state'], 
                         'billing_country' => $order->billing['country']['title'], 
                         'billing_address_format_id' => $order->billing['format_id'], 
                         'payment_method' => $order->info['payment_method'], 
                         'cc_type' => $order->info['cc_type'], 
                         'cc_owner' => $order->info['cc_owner'], 
                         'cc_number' => $order->info['cc_number'], 
                         'cc_expires' => $order->info['cc_expires'], 
                         'date_purchased' => 'now()', 
                         'orders_status' => $order->info['order_status'], 
                         'currency' => $order->info['currency'], 
                         'currency_value' => $order->info['currency_value']);
 tep_db_perform(TABLE_ORDERS, $sql_data_array);
 $insert_id = tep_db_insert_id();
 for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) {
   $sql_data_array = array('orders_id' => $insert_id,
                           'title' => $order_totals[$i]['title'],
                           'text' => $order_totals[$i]['text'],
                           'value' => $order_totals[$i]['value'], 
                           'class' => $order_totals[$i]['code'], 
                           'sort_order' => $order_totals[$i]['sort_order']);
   tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array);
 }

 $customer_notification = (SEND_EMAILS == 'true') ? '1' : '0';
 $sql_data_array = array('orders_id' => $insert_id, 
                         'orders_status_id' => $order->info['order_status'], 
                         'date_added' => 'now()', 
                         'customer_notified' => $customer_notification,
                         'comments' => $order->info['comments']);
 tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);

// initialized for the email confirmation
 $products_ordered = '';
 $subtotal = 0;
 $total_tax = 0;

 echo "<p>beginning of stock update<p>";
 for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
// Stock Update - Joao Correia
   if (STOCK_LIMITED == 'true') {
//++++ QT Pro: Begin Changed code
       $products_attributes = $order->products[$i]['attributes'];
//++++ QT Pro: End Changed Code
     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
//++++ 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);
//++++ QT Pro: Begin Changed code
           $actual_stock_bought = $order->products[$i]['qty'];
       } else {
           echo "<p>stock update, download not enabled<p>";
           if (is_array($products_attributes)) {
               echo "<p>stock update, has attributes<p>";
               $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 {
                 echo "<p>stock update, some stocked attributes<p>";
                 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'];
                     echo "<p>stock update, attribute stock updated<p>";
     } 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;
                     echo "<p>stock update, attribute stock inserted<p>";
                 }
               }
           } else {
               $actual_stock_bought = $order->products[$i]['qty'];
           } 
//++++ QT Pro: End Changed Code
       $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'])) {
//++++ QT Pro: Begin Changed code
               $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
       if ( ($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') ) {
         tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
       }
     }
   }
//++++ QT Pro: Begin Changed code
   }
//++++ QT Pro: End Changed Code
// Update products_ordered (for bestsellers list)
   tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $order->products[$i]['qty']) . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");

//++++ QT Pro: Begin Changed code
   if (!isset($products_stock_attributes)) $products_stock_attributes=null;
   $sql_data_array = array('orders_id' => $insert_id, 
                           'products_id' => tep_get_prid($order->products[$i]['id']), 
                           'products_model' => $order->products[$i]['model'], 
                           'products_name' => $order->products[$i]['name'], 
                           'products_price' => $order->products[$i]['price'], 
                           'final_price' => $order->products[$i]['final_price'], 
                           'products_tax' => $order->products[$i]['tax'], 
                           'products_quantity' => $order->products[$i]['qty'],
                           'products_stock_attributes' => $products_stock_attributes);
//++++ QT Pro: End Changed Code
   tep_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);
   $order_products_id = tep_db_insert_id();

//------insert customer choosen option to order--------
   $attributes_exist = '0';
   $products_ordered_attributes = '';
   if (isset($order->products[$i]['attributes'])) {
     $attributes_exist = '1';
     for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
       if (DOWNLOAD_ENABLED == 'true') {
         $attributes_query = "select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename 
                             from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa 
                             left join " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
                               on pa.products_attributes_id=pad.products_attributes_id
                             where pa.products_id = '" . $order->products[$i]['id'] . "' 
                               and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "' 
                               and pa.options_id = popt.products_options_id 
                               and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "' 
                               and pa.options_values_id = poval.products_options_values_id 
                               and popt.language_id = '" . $languages_id . "' 
                               and poval.language_id = '" . $languages_id . "'";
         $attributes = tep_db_query($attributes_query);
       } else {
         $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $order->products[$i]['id'] . "' and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $languages_id . "' and poval.language_id = '" . $languages_id . "'");
       }
       $attributes_values = tep_db_fetch_array($attributes);

       $sql_data_array = array('orders_id' => $insert_id, 
                               'orders_products_id' => $order_products_id, 
                               'products_options' => $attributes_values['products_options_name'],
                               'products_options_values' => $attributes_values['products_options_values_name'], 
                               'options_values_price' => $attributes_values['options_values_price'], 
                               'price_prefix' => $attributes_values['price_prefix']);
       tep_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array);

       if ((DOWNLOAD_ENABLED == 'true') && isset($attributes_values['products_attributes_filename']) && tep_not_null($attributes_values['products_attributes_filename'])) {
         $sql_data_array = array('orders_id' => $insert_id, 
                                 'orders_products_id' => $order_products_id, 
                                 'orders_products_filename' => $attributes_values['products_attributes_filename'], 
                                 'download_maxdays' => $attributes_values['products_attributes_maxdays'], 
                                 'download_count' => $attributes_values['products_attributes_maxcount']);
         tep_db_perform(TABLE_ORDERS_PRODUCTS_DOWNLOAD, $sql_data_array);
       }
       $products_ordered_attributes .= "\n\t" . $attributes_values['products_options_name'] . ' ' . $attributes_values['products_options_values_name'];
     }
   }
//------insert customer choosen option eof ----
   $total_weight += ($order->products[$i]['qty'] * $order->products[$i]['weight']);
   $total_tax += tep_calculate_tax($total_products_price, $products_tax) * $order->products[$i]['qty'];
   $total_cost += $total_products_price;

   $products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n";
 }

// lets start with the email confirmation
// DDB - 041103 - Add test for PWA : no display of invoice URL if PWA customer
if (!tep_session_is_registered('noaccount')) 
{
 $email_order = STORE_NAME . "\n" . 
               EMAIL_SEPARATOR . "\n" . 
               EMAIL_TEXT_ORDER_NUMBER . ' ' . $insert_id . "\n" .
               EMAIL_TEXT_INVOICE_URL . ' ' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $insert_id, 'SSL', false) . "\n" .
               EMAIL_TEXT_DATE_ORDERED . ' ' . strftime(DATE_FORMAT_LONG) . "\n\n";
 if ($order->info['comments']) 
 {
   $email_order .= tep_db_output($order->info['comments']) . "\n\n";
 }
 $email_order .= EMAIL_TEXT_PRODUCTS . "\n" . 
                 EMAIL_SEPARATOR . "\n" . 
                 $products_ordered . 
                 EMAIL_SEPARATOR . "\n";
} else {
 $email_order = STORE_NAME . "\n" . 
               EMAIL_SEPARATOR . "\n" . 
               EMAIL_TEXT_ORDER_NUMBER . ' ' . $insert_id . "\n" .
               EMAIL_TEXT_DATE_ORDERED . ' ' . strftime(DATE_FORMAT_LONG) . "\n\n";
 if ($order->info['comments']) {
   $email_order .= tep_db_output($order->info['comments']) . "\n\n";
 }
 $email_order .= EMAIL_TEXT_PRODUCTS . "\n" . 
                 EMAIL_SEPARATOR . "\n" . 
                 $products_ordered . 
                 EMAIL_SEPARATOR . "\n";
 }

 for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) {
   $email_order .= strip_tags($order_totals[$i]['title']) . ' ' . strip_tags($order_totals[$i]['text']) . "\n";
 }

 if ($order->content_type != 'virtual') {
   $email_order .= "\n" . EMAIL_TEXT_DELIVERY_ADDRESS . "\n" . 
                   EMAIL_SEPARATOR . "\n" .
                   tep_address_label($customer_id, $sendto, 0, '', "\n") . "\n";
 }

 $email_order .= "\n" . EMAIL_TEXT_BILLING_ADDRESS . "\n" .
                 EMAIL_SEPARATOR . "\n" .
                 tep_address_label($customer_id, $billto, 0, '', "\n") . "\n\n";
 if (is_object($$payment)) {
   $email_order .= EMAIL_TEXT_PAYMENT_METHOD . "\n" . 
                   EMAIL_SEPARATOR . "\n";
   $payment_class = $$payment;
   $email_order .= $payment_class->title . "\n\n";
   if ($payment_class->email_footer) { 
     $email_order .= $payment_class->email_footer . "\n\n";
   }
 }
 tep_mail($order->customer['firstname'] . ' ' . $order->customer['lastname'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

// send emails to other people
 if (SEND_EXTRA_ORDER_EMAILS_TO != '') {
   tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
 }

// load the after_process function from the payment modules
 $payment_modules->after_process();

 $cart->reset(true);

// unregister session variables used during checkout
 tep_session_unregister('sendto');
 tep_session_unregister('billto');
 tep_session_unregister('shipping');
 tep_session_unregister('payment');
 tep_session_unregister('comments');

 tep_redirect(tep_href_link(FILENAME_CHECKOUT_SUCCESS, '', 'SSL'));

 require(DIR_WS_INCLUDES . 'application_bottom.php');
?>

 

Good luck!

 

Ralph

Share this post


Link to post
Share on other sites

It can read the database, but it doesn't write to the database.

It's very weird.

 

I notice that is stock is set to 1 on all available attributes, and I try to add 2 of the same attribute to my cart, it will say that specific attribute is out of stock.

 

Again indicating that it reads but doesn't write the database.


Dedicated OsCommerce user. 2011 will be the return of OsC

Share this post


Link to post
Share on other sites
It can read the database, but it doesn't write to the database.

It's very weird.

 

I notice that is stock is set to 1 on all available attributes, and I try to add 2 of the same attribute to my cart, it will say that specific attribute is out of stock.

 

Again indicating that it reads but doesn't write the database.

Definitely try the checkout_process.php I posted to find out where its failing.

Share this post


Link to post
Share on other sites

Well,

I just tried it again, with the .php you posted above, and i get no unussual writings at all.

 

Where can I finde the error file you mentioned in an earlier post?

Or is it in the sql database.

thanks.


Dedicated OsCommerce user. 2011 will be the return of OsC

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×