Jump to content



Photo
- - - - -

QTPro BS

qtpro attributes stock bs add-on update

  • Please log in to reply
70 replies to this topic

#61 ONLINE   raiwa

raiwa
  • Community Sponsor
  • 1,803 posts
  • Real Name:Rainer Schmied
  • Gender:Male
  • Location:Sant Iscle de Vallalta, Barcelona, Spain

Posted 17 April 2017 - 12:15

 HelloLee @LeeFoster,

 

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

 

rgds

Rainer



#62   LeeFoster

LeeFoster
  • Members
  • 77 posts
  • Real Name:Lee Foster

Posted 17 April 2017 - 12:28

@raiwa,

 

I had considered that but was hoping it might be something simple and that you might be able to say "just change 'x' to 'y' and you're sorted".

 

If that's not the case I'll have another look at the files.



#63 ONLINE   raiwa

raiwa
  • Community Sponsor
  • 1,803 posts
  • Real Name:Rainer Schmied
  • Gender:Male
  • Location:Sant Iscle de Vallalta, Barcelona, Spain

Posted 17 April 2017 - 12:57

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



#64   LeeFoster

LeeFoster
  • Members
  • 77 posts
  • Real Name:Lee Foster

Posted 17 April 2017 - 13:07

@raiwa,

 

That was my thinking, I'll revisit it later today when I've not got 3 kids running round me.



#65   LeeFoster

LeeFoster
  • Members
  • 77 posts
  • Real Name:Lee Foster

Posted 19 April 2017 - 18:23

I've just done a test on processing an order and I get 'this page isn't working' but if I comment out the QTPro additions from the file the page works. Any ideas?



#66   LeeFoster

LeeFoster
  • Members
  • 77 posts
  • Real Name:Lee Foster

Posted 19 April 2017 - 18:56

I've just done a test on processing an order and I get 'this page isn't working' but if I comment out the QTPro additions from the file the page works. Any ideas?

 

Please feel free to ignore this was me being a dumb ass.



#67   milerwan

milerwan
  • Members
  • 130 posts
  • Real Name:Gwenn
  • Gender:Male
  • Location:France

Posted 21 April 2017 - 13:03

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 ?



#68   LeeFoster

LeeFoster
  • Members
  • 77 posts
  • Real Name:Lee Foster

Posted 21 April 2017 - 14:08

@milerwan

 

Can you share all the changes you've made and I'll have a look? I'd not had chance to look in to it yet.



#69   milerwan

milerwan
  • Members
  • 130 posts
  • Real Name:Gwenn
  • Gender:Male
  • Location:France

Posted 21 April 2017 - 20:18

@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') . '&nbsp;'; ?></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">&nbsp;&nbsp;' . $option_names[$k] . '</td>';
      $title[$title_num] = $k;
    }
	echo '<td class="dataTableHeadingContent"><span class="smalltext">' . TABLE_HEADING_QUANTITY . '</span></td><td width="100%">&nbsp;</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">&nbsp;&nbsp;&nbsp;' . tep_values_name($m1['2']) . '</td>';
          } else {
            echo '<td>&nbsp;</td>';
          }
        }
        for($i = 0;$i<sizeof($options)-sizeof($val_array);$i++) {
          echo '<td>&nbsp;</td>';
        }
        echo '<td class="smalltext">&nbsp;&nbsp;&nbsp;&nbsp;' . $rec['products_stock_quantity'] . '</td><td>&nbsp;</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">&nbsp;<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') . '&nbsp;' . tep_draw_input_field('products_quantity', $pInfo->products_quantity) . '&nbsp;' . 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. ;)



#70   LeeFoster

LeeFoster
  • Members
  • 77 posts
  • Real Name:Lee Foster

Posted Yesterday, 17:55

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



#71   milerwan

milerwan
  • Members
  • 130 posts
  • Real Name:Gwenn
  • Gender:Male
  • Location:France

Posted Yesterday, 18:33

@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. :)