Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

@@joe122joe,

 

@@raiwa

 

it  seems the  changes in checkout_process.php are  ok.

I have installed order editor and create orders, I am not sure if this case this issue.

The order editor it should work fine with QTPro..

 

Order editor shouldn't have an influence.

Which payment module do you use??

Link to comment
Share on other sites

@@joe122joe,

 

and in Stock Report show the total 19 

 

@@raiwa 

I am using  Cach on Delivery and Paytrail payment .. I tested the Cach on Delivery payment and same issue. 

 

Joe

 

Are you using another option in the same product which doesn't have stock control activated? If yes, please activate stock control for all options used in one product.

I do not know paytrail payment. Please check if it uses the standard checkout_process.php.

 

rgds

Rainer

Link to comment
Share on other sites

and if I delete the order and check Restock product quantity ..   the product will  NOT appear  on the QTPro doctor , and if I type on the browser www.myshop.com/admin/stock.php?product_id=1421

 

product_id=1421 it is same product what I am talking about it before it is  show like this:

This product is all ok.

The stock quantity summary is ok
This means that the current summary of this products quantity, which is in the database, is the value we get if we calculates it from scratch right now.
The Summary stock is: 20

The options stock is ok
This means that the database entries for this product looks the way they should. No options are missing in any row. No option exist in any row where it should not.
Total number of stock entries this product has: 2
Number of messy entries: 0 

Link to comment
Share on other sites

@@joe122joe,

 

The stock substraction is done in checkout_process.php by the hook function "StockUpdateProcess".

 

You should first make sure that you have the hooks correct installed and the hooks support in place in application_top.php.

Depending on your 2.3.4 EDGE version this was already in place or you had to add it.

 

Then, if you applied the modifications to your existing checkout_process.php, try temporary to use the provided modified files.

 

Then check also if you had already applied any other modifications in checkout _process.php which could interfere in the stock substraction.

 

Please do all tests with cod payment.

 

rgds

Rainer

Link to comment
Share on other sites

@@raiwa

I everything installed as in the manual 

here is checkout _process.php

<?php
/*
  $Id: checkout_process.php 1750 2007-12-21 05:20:28Z hpdl $

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

  Copyright (c) 2007 osCommerce

  Released under the GNU General Public License
*/

  include('includes/application_top.php');

// QTPro  
  $OSCOM_Hooks->register('qtpro');

// 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 there is nothing in the customers cart, redirect them to the shopping cart page
  if ($cart->count_contents() < 1) {
    tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
  }

// if no shipping method has been selected, redirect the customer to the shipping method selection page
  if (!tep_session_is_registered('shipping') || !tep_session_is_registered('sendto')) {
    tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', '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;

// QTPro    
  $OSCOM_Hooks->call('qtpro', 'StockCheckProcess');
  
// Stock Check
  $any_out_of_stock = false;
  if (STOCK_CHECK == 'true') {
    for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
      if (tep_check_stock($order->products[$i]['id'], $order->products[$i]['qty'])) {
        $any_out_of_stock = true;
      }
    }
    // Out of Stock
    if ( (STOCK_ALLOW_CHECKOUT != 'true') && ($any_out_of_stock == true) ) {
      tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
    }
  }

  $payment_modules->update_status();

  if ( ( is_array($payment_modules->modules) && (sizeof($payment_modules->modules) > 1) && !is_object($$payment) ) || (is_object($$payment) && ($$payment->enabled == false)) ) {
    tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_NO_PAYMENT_MODULE_SELECTED), 'SSL'));
  }

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

  $order_totals = $order_total_modules->process();

// load the before_process function from the payment modules
  $payment_modules->before_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' => trim($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') {
      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 = (isset($order->products[$i]['attributes'])) ? $order->products[$i]['attributes'] : '';
        if (is_array($products_attributes)) {
          $stock_query_raw .= " AND pa.options_id = '" . (int)$products_attributes[0]['option_id'] . "' AND pa.options_values_id = '" . (int)$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 = '" . (int)$stock_left . "' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
        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']) . "'");
        }
      }
    }

// 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']) . "'");

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

// QTPro    
  $OSCOM_Hooks->call('qtpro', 'StockUpdateProcess');
 
    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 = '" . (int)$order->products[$i]['id'] . "' 
                                and pa.options_id = '" . (int)$order->products[$i]['attributes'][$j]['option_id'] . "' 
                                and pa.options_id = popt.products_options_id 
                                and pa.options_values_id = '" . (int)$order->products[$i]['attributes'][$j]['value_id'] . "' 
                                and pa.options_values_id = poval.products_options_values_id 
                                and popt.language_id = '" . (int)$languages_id . "' 
                                and poval.language_id = '" . (int)$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 = '" . (int)$order->products[$i]['id'] . "' and pa.options_id = '" . (int)$order->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . (int)$order->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . (int)$languages_id . "' and poval.language_id = '" . (int)$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";
  }
 // Discount Codes 4.1 BS - start
  if (MODULE_ORDER_TOTAL_DISCOUNT_STATUS == 'true' && !empty($discount)) {
    $discount_codes_query = tep_db_query("select discount_codes_id from discount_codes where discount_codes = '" . tep_db_input($sess_discount_code) . "'");
    $discount_codes = tep_db_fetch_array($discount_codes_query);

    tep_db_perform('customers_to_discount_codes', array('customers_id' => $customer_id, 'discount_codes_id' => $discount_codes['discount_codes_id']));
    tep_db_query("update discount_codes set number_of_orders = number_of_orders + 1 where discount_codes_id = '" . (int)$discount_codes['discount_codes_id'] . "'");

    tep_session_unregister('sess_discount_code');
  }
  // Discount Codes 4.1 BS - end
  
// lets start with the email confirmation
   $oscTemplate->getContent('email_checkout_process');

// 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');
?>

Joe

Edited by joe122joe
Link to comment
Share on other sites

@@joe122joe,

 

please do the following test:

- add a "die;" command just at the beginning of the "listen_StockUpdateProcess" function in:

includes/hooks/shop/qtpro/qtpro_hooks.php

so it looks like this:

  function listen_StockUpdateProcess() {
    global $order, $i, $insert_id, $sql_data_array;
    die;
    $products_stock_attributes = null;

then do an order  with the cod payment.

you should stuck in checkout_process.php with a blank screen showing.

Please confirm.

 

rgds

Rainer

Link to comment
Share on other sites

@@joe122joe,

 

Please confirm that you did the test with COD payment.

Then the qtpro hooks are not correct installed and not included in the checkout_process.php.

Even you did all code changes in checkout_process.php, something else is missing.

Please recheck the changes in application_top.php for the inclusion of the lines:

  require('includes/classes/hooks.php');
  $OSCOM_Hooks = new hooks('shop');

Then check if you have the following class in place:

includes/classes/hooks.php

 

If all is correct installed, you must get the blank page in checkout_process.php when the die command is added like explained in the last post.

 

rgds

Rainer

Link to comment
Share on other sites

@@raiwa  

did the test with COD payment. I  didn't get any blank screen, and i checked the  application_top.php  and the lines there ..
and hooks.php file in 
includes/classes/hooks.php.

 

wired ..  I will try to install it again from beginning f . :- 

and check last addons I have been add it.

 

Maybe as you said something else is missing. 

 

Thank you so much 

Joe 

Link to comment
Share on other sites

I have been reinstalling it .. but still same. It is subtracting just from the main stock of the product not from the attribute stock.

 there was many talking about this issue on the old  support topic, but I didn't find any solution  from there.
 
Joe
Link to comment
Share on other sites

@@joe122joe,

 

This has nothing to do with the issues dicussed for older versions. Older versions didn't use hooks.

The problem is that the qtpro hooks are not loaded in checkout_process.php.

I can't say why, but if you solve this problem it will work.

 

rgds

Rainer

Link to comment
Share on other sites

@@raiwa  When I add this line

// QTPro  
  $OSCOM_Hooks->register('qtpro');

to checkout_process.php.. I got blank screen showing on the checkout_confirmation page ...The Edge what  I am using downloaded  before 9/2016 . so there is no hooks system and database_tables.php and filenames.php still there, Do you think that make sense.

 

Joe

Link to comment
Share on other sites

@@joe122joe,

 

of course, this is essential, now the stock subtraction should work.

 

But you had this modifcation in your modified checkout_process.php you posted before!

Link to comment
Share on other sites

The Edge what  I am using downloaded  before 9/2016 . so there is no hooks system and database_tables.php and filenames.php still there, Do you think that make sense.

 

@@joe122joe,

 

I suppose you did Installation Step: 0. Legacy (for older 2.3.4 BS versions whithout hooks).

Database table names and filenames are no problem for downward compatibility to older versions.

Edited by raiwa
Link to comment
Share on other sites

@@joe122joe,

 

I'm sorry, but I do not understand now, you say it's the same checkout_process.php with the hook register line in place. But you said you didn't get the blank page (with the die command added in the hook function).

Now you said you get a blank page when you add the hook register.

 

Please try to give more precise information.

 

Also:

Did you all installation steps for the hook support, also the modification in application_top.php.

 

I'm sorry it's very difficult or impossible to give support without precise, complete and consistent information.

 

rgds

Rainer

Link to comment
Share on other sites

@@joe122joe,

 

I suppose you did Installation Step: 0. Legacy (for older 2.3.4 BS versions whithout hooks).

Database table names and filenames are no problem for downward compatibility to older versions.

 

I missed this step when I did my first install and had issues. Once installed everything worked fine. @@joe122joe, it's probably worth you doing the same

Link to comment
Share on other sites

@@raiwa   I am so sorry for been confusing you..

I did as Installation steps 

   1. Upload the hooks to catalog/includes/classes/

  2. adding the line to application_top.php                                 

                  require(DIR_FS_CATALOG . 'includes/classes/hooks.php');
                  $OSCOM_Hooks = new hooks('shop');

 This was not working for me I got blank page all whole site  so I toke the lines from your application_top.php.

   

 

@@LeeFoster thank you,   I have been follow the steps  but still same 

Edited by joe122joe
Link to comment
Share on other sites

@@joe122joe,

 

if you get a blank page on the whole site, this means that you get a fatal php error. It's not done then to just not add that code. You need to find out which php error is produced and why. Edit your error log file to see the error and post it. Then we can help.

Link to comment
Share on other sites

@@joe122joe,

 

you may have added the code for hooks inclusion to application_top.php BEFORE you had copied the hook class. This would explain the error.

Edited by raiwa
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...