Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

  • 2 weeks later...

Hello raiwa,

my playground shop is configured to redirect to shopping cart after adding a product, which didn't work from product_info.php after installing QTPro. There is little bit missing in application_top.php - it works now after adding:

$cart->add_cart($_POST['products_id'], $cart->get_quantity(tep_get_uprid($_POST['products_id'], $attributes))+1, $attributes);

}

$messageStack->add_session('product_action', sprintf(PRODUCT_ADDED, tep_get_products_name((int)$_POST['products_id'])), 'success');
tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                          
//++++ QT Pro: End Changed Code
break;

Best regards

beerbee

Link to comment
Share on other sites

Hello Christoph @@beerbee,

 

Yes, this is missing in the code. I'll fix it asap and upload.

 

Thanks You!

 

rgds

Rainer

Link to comment
Share on other sites

Hi @@raiwa

 

recently I recognized that the qtpro_sick_product_count() function in header.php from my 2.3.4 BS Edge Shop with QTpro for osc 2.3 V4.6.1 takes 

about 30 seconds while loading my backend  :blink: I'm not sure when this problem occurs, maybe it was a creeping process. I have only 337 products 

with 19 tracked options in my shop.

Do you think that the problem disappears if I update to your 5.2 version ? Do you use the same functions ? I'm unsure to install the update...  B)

 

Thank you for helping me !

 

SEE YA

Denzel.

Link to comment
Share on other sites

Hello Dennis @@Denzel,

 

The only function which introduces a small update to avoid undefined errors is the qtpro_get_products_summary_stock function:

function qtpro_get_products_summary_stock($products_id) {
	$products_summary_stock_query = tep_db_query("SELECT products_quantity
											                          FROM products 
											                          WHERE products_id = '" . $products_id . "'");
	$product_facts = tep_db_fetch_array($products_summary_stock_query);
	if ($product_facts['products_quantity'] > 0) { //If they are negative they are oversold and this do not affect what we have on stock. added by @raiwa to avoid error if negative stock
	  return $product_facts['products_quantity'];
	} else {
	  return 0;
	}
}

All mods in other functions included in the admin qtpro functions file are hardcoded database table names, filenames and introducing language constants instead of hardcoded text for the messages. There are no essential script/programming changes elsewhere. So I can't promise that it will solve your problem.

 

rgds

Rainer

Link to comment
Share on other sites

  • 2 weeks later...

@@raiwa

Hi, again a little bit missing inside of cm_sc_product_listing_qtpro.php: call of the correct function for attributes stock check:

//is
 if ( isset($products[$i]['attributes']) && is_array($products[$i]['attributes']) ) {
            $stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity'], $products[$i]['attributes']);
// but should be
 if ( isset($products[$i]['attributes']) && is_array($products[$i]['attributes']) ) {
            $stock_check = check_stock_qtpro($products[$i]['id'], $products[$i]['quantity'], $products[$i]['attributes']); 
        

Best regards

Christoph

Link to comment
Share on other sites

Hello Christoph @@beerbee,

 

This was wrong in version 5.0 and has been already fixed in version 5.1.:

        if (STOCK_CHECK == 'true') {
          if ( isset($products[$i]['attributes']) && is_array($products[$i]['attributes']) ) {
            $stock_check = check_stock_qtpro($products[$i]['id'], $products[$i]['quantity'], $products[$i]['attributes']); 
          } else {
            $stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity']);
          }

Please check if you are working with the latest version 5.2

 

rgds

Rainer

Link to comment
Share on other sites

  • 1 month later...

This addon does exactly what I needed. I want to make 2 changes and thought I'd ask here if anyone has done it before I start.

 

1) I want to change the sequenced drop down to sequenced radio buttons.

 

2) I want to embed the section in the attached image on the product page in the admin section.

 

 

post-338442-0-47736200-1492327414_thumb.png

Link to comment
Share on other sites

 HelloLee @@LeeFoster,

 

If you need such specific things you should consider to post in the commercial support forum.

 

rgds

Rainer

Link to comment
Share on other sites

@@LeeFoster,

 

I's not that easy. You can try as a starting point to look on the pad_multiple_dropdowns and pad_single_radioset classes and try to merge them together.

Link to comment
Share on other sites

This addon does exactly what I needed. I want to make 2 changes and thought I'd ask here if anyone has done it before I start.

 

1) I want to change the sequenced drop down to sequenced radio buttons.

 

2) I want to embed the section in the attached image on the product page in the admin section.

 

I'm Interested too to add stock modification into product edition (categories.php).

 

I have tried to replace the variables like this :

- $VARS['product_id']    by    $pInfo->products_id

- $VARS['quantity']        by    $pInfo->products_quantity

 

With these changes the table with name of options appears, but when you want to update the quantities by pressing the "ADD" button, you return to the product selection page without the change being made.

 

Any idea to fix this problem ?

Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Link to comment
Share on other sites

@@LeeFoster

 

Sure, here is the code to modify/add instead original quantity script from categories.php.

 

NB: This code must be fixed to work when you want to update the quantities of the attributes !

          <tr>
            <td class="main" valign="top"><?php echo TEXT_PRODUCTS_QUANTITY; ?></td>
<!-- new start -->
            <td colspan="2" align="left"><table border="0" cellspacing="0" cellpadding="0" width="100%">
			  <tr>

<?php
//++++ QT Pro: Begin Changed code
	if ($product_investigation['has_tracked_options'] or $product_investigation['stock_entries_count'] > 0) {

  $VARS = null;
  if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    $VARS = $_GET;
  } else {
    $VARS = $_POST;
  }
  if ( isset($VARS['action']) && $VARS['action'] == 'Add' ) {
    $inputok = true;
    if (!(is_numeric($pInfo->products_id) and ($pInfo->products_id==(int)$pInfo->products_id))) $inputok = false;
    while(list($v1,$v2) = each($VARS)) {
      if (preg_match('/^option(\d+)$/',$v1,$m1)) {
        if (is_numeric($v2) and ($v2==(int)$v2)) $val_array[] = $m1[1].'-'.$v2;
        else $inputok = false;
      }
    }
    if (!(is_numeric($pInfo->quantity) and ($pInfo->quantity==(int)$pInfo->quantity))) $inputok = false;

    if (($inputok)) {
      sort($val_array, SORT_NUMERIC);
      $val = join(',', $val_array);      
      $q = tep_db_query("select products_stock_id as stock_id from products_stock where products_id=" . (int)$pInfo->products_id . " and products_stock_attributes='" . $val . "' order by products_stock_attributes");
      if (tep_db_num_rows($q)>0) {
        $stock_item = tep_db_fetch_array($q);
        $stock_id = $stock_item['stock_id'];
        if ($pInfo->quantity = intval($pInfo->quantity)) {
          tep_db_query("update products_stock set products_stock_quantity=" . (int)$pInfo->quantity . " where products_stock_id=$stock_id");
        } else {
          tep_db_query("delete from products_stock where products_stock_id=" . $stock_id);
        }
      } else {
        tep_db_query("insert into products_stock values ('0','" . (int)$pInfo->products_id . "', '" . $val . "', '" . (int)$pInfo->quantity . "')");
      }
      $q = tep_db_query("select sum(products_stock_quantity) as summa from products_stock where products_id=" . (int)$pInfo->products_id . " and products_stock_quantity > 0");
      $list = tep_db_fetch_array($q);
      $summa = (empty($list['summa'])) ? 0 : $list['summa'];
      tep_db_query("update products set products_quantity=" . $summa . " where products_id=" . (int)$pInfo->products_id);
      if (($summa<1) && (STOCK_ALLOW_CHECKOUT == 'false')) {
        tep_db_query("update products set products_status='0' where products_id=" . (int)$pInfo->products_id);
      }
    }
  }
  if ( isset($VARS['action']) && $VARS['action'] == 'Update' ) {
    tep_db_query("update products set products_quantity=" . (int)$pInfo->quantity . " where products_id=" . (int)$pInfo->products_id);
    if (($pInfo->quantity<1) && (STOCK_ALLOW_CHECKOUT == 'false')) {
      tep_db_query("update products set products_status='0' where products_id=" . (int)$pInfo->products_id);
    }
  }
  if ( isset($VARS['action']) && $VARS['action'] == 'Apply to all') {

  }
  $flag = null;
  $q = tep_db_query("select products_name,products_options_name as _option,products_attributes.options_id as _option_id,products_options_values_name as _value,products_attributes.options_values_id as _value_id from 
                  products_description, products_attributes,products_options,products_options_values where 
                  products_attributes.products_id = products_description.products_id and 
                  products_attributes.products_id = " . (int)$pInfo->products_id . " and 
                  products_attributes.options_id = products_options.products_options_id and 
                  products_attributes.options_values_id = products_options_values.products_options_values_id and 
                  products_description.language_id = " . (int)$languages_id . " and 
                  products_options_values.language_id = " . (int)$languages_id . " and products_options.products_options_track_stock = 1 and 
                  products_options.language_id = " . (int)$languages_id . " order by products_attributes.options_id, products_attributes.options_values_id");

 $db_quantity = null;
 if (tep_db_num_rows($q)>0) {
    $flag = 1;
    while($list = tep_db_fetch_array($q)) {
      $options[$list['_option_id']][] = array($list['_value'], $list['_value_id']);
      $option_names[$list['_option_id']] = $list['_option'];
      $product_name = $list['products_name'];
    }
  } else {
    $q = tep_db_query("select products_quantity, products_name from products p, products_description pd where pd.products_id=" . (int)$pInfo->products_id . " and p.products_id=" . (int)$pInfo->products_id);
    $list = tep_db_fetch_array($q);
    $db_quantity = $list['products_quantity'];
    $product_name = stripslashes($list['products_name']);
  }
  
  $product_investigation = qtpro_doctor_investigate_product($pInfo->products_id);
  
?>

        <td><form action="<?php echo $PHP_SELF;?>" method="get">
        <table border="0" width="" cellspacing="0" cellpadding="0">
          <tr>
			<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' '; ?></td>
            <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr class="dataTableHeadingRow">

<?php
  $title_num = 1;
  if ($flag) {
    while( list($k,$v) = each($options) ) {
      echo '<td class="dataTableHeadingContent">  ' . $option_names[$k] . '</td>';
      $title[$title_num] = $k;
    }
	echo '<td class="dataTableHeadingContent"><span class="smalltext">' . TABLE_HEADING_QUANTITY . '</span></td><td width="100%"> </td>';
    echo '</tr>';
    //sorting below goes by name rather than products_stock_attributes. Much easier to have it all sorted alphabetically
    $q = tep_db_query("select ps.products_stock_id, ps.products_id, ps.products_stock_attributes, ps.products_stock_quantity, pov.products_options_values_id, pov.language_id, pov.products_options_values_name from products_stock ps, products_options_values pov where ps.products_id=" . $pInfo->products_id . " and pov.products_options_values_id = substring_index(ps.products_stock_attributes, '-', -1) order by pov.products_options_values_name asc");
    $test_string = null;
    while($rec = tep_db_fetch_array($q)) {
      $val_array = explode(',', $rec['products_stock_attributes']);
      if (strpos($test_string, $rec['products_stock_attributes']) === false) {
        echo '<tr>';
        foreach($val_array as $val) {
          if (preg_match('/^(\d+)-(\d+)$/',$val,$m1)) {
            echo '<td class="smalltext">   ' . tep_values_name($m1['2']) . '</td>';
          } else {
            echo '<td> </td>';
          }
        }
        for($i = 0;$i<sizeof($options)-sizeof($val_array);$i++) {
          echo '<td> </td>';
        }
        echo '<td class="smalltext">    ' . $rec['products_stock_quantity'] . '</td><td> </td></tr>';
        $test_string .= $rec['products_stock_attributes'] . ';';
      }
    }
    echo '<tr>';
    reset($options);
    $i = 0;
    while( list($k, $v) = each($options) ) {
      echo '<td class="dataTableHeadingRow"><select name="option' . $k . '">';
      foreach($v as $v1) {
        echo '<option value="' . $v1['1'] . '">' . $v1['0'];
      }
      echo '</select></td>';
      $i++;
    }
  } else {
    $i = 1;
    echo '<td class="dataTableHeadingContent">' . TABLE_HEADING_QUANTITY . '</td>';
  }
  echo '<td class="dataTableHeadingRow"><input type="text" name="quantity" size="4" value="' . $db_quantity . '"><input type="hidden" name="product_id" value="' . $pInfo->products_id . '"></td><td width="100%" class="dataTableHeadingRow"> <input type="submit" name="action" value="' . (($db_quantity)? BUTTON_UPDATE : BUTTON_ADD ) . '"></td>';
?>
              </tr>
            </table></td>
          </tr>
        </table>
        </form></td>
<?php 			
	} else {
?>
            <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_quantity', $pInfo->products_quantity) . ' ' . tep_draw_separator('pixel_trans.gif', '20', '1'); ?></td>
<?php 
	}
//++++ QT Pro: End Changed code
?>

			<td class="smallText" align="right"><?php echo tep_draw_hidden_field('products_date_added', (tep_not_null($pInfo->products_date_added) ? $pInfo->products_date_added : date('Y-m-d'))) . tep_draw_button(IMAGE_SAVE, 'disk', null, 'primary') . tep_draw_button(IMAGE_CANCEL, 'close', tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($_GET['pID']) ? '&pID=' . $_GET['pID'] : ''))); ?></td>
			  </tr>
			</table></td>
<!-- new end -->
          </tr>

Need help please. ;)

Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Link to comment
Share on other sites

@@milerwan

 

I know why it's not working, I just don't know how to fix it. The form method is set to "get" meaning that the values it submits come from the URL not the form. Clicking "Add" doesn't push the required values to the URL with the changes you've made like it does from the standard stock.php file.

Link to comment
Share on other sites

@@raiwa

 

@@milerwan

 

I know why it's not working, I just don't know how to fix it. The form method is set to "get" meaning that the values it submits come from the URL not the form. Clicking "Add" doesn't push the required values to the URL with the changes you've made like it does from the standard stock.php file.

 

I'm sure magican @@raiwa could knows the magic formula to fix it. :)

Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Link to comment
Share on other sites

@@milerwan, @@LeeFoster,

 

I'll try to have a look on this when I'll find some time. Please be patient.

 

rgds

Rainer

Link to comment
Share on other sites

@@raiwa the attribute stock not subtracting.. It is subtracting just from the main stock of the product.

example

Product  A have

color     size      Qyt

Red        S         10

Red       M         10

total 20  ..

If customer bought one red   size M.. Then main stock show total 19 but  in editing product page it show still:

color     size      Qyt

Red        S         10

Red       M         10

 

  the product will appear  on the QTPro doctor page and it show :

 

This product needs attention!

The stock quantity summary is NOT ok
This means that the current summary of this products quantity, which is in the database, isn't the value we get if we calculates it from scratch right now.
The current summary stock is: 19 
If we calculates it we get: 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

Automatic Solutions Avaliable:

Set the summary stock to: 20

 

Do you know why?

 

Thanks and best regards

Joe 

Link to comment
Share on other sites

Hello Joe @@joe122joe,

 

Please check the installation/changes in checkout_process.php and if you use it in paypal standard.

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