Jump to content
Latest News: (loading..)

Recommended Posts

I have QT Pro installed with the Ajax Attribute Manager.  As far as adding attributes, all's good. But in the product info page the option drop down is in reverse order of what I'd like it to be.  The QT Pro Currently On Stock table is ordered as I want it.

So looking at the sort order add on, it is so far out of date I am hesitant to mix that in with my CE shop running a PHP 7.1* version..  I was thinking about modifying a SQL statement in the padbase file with an order by to perhaps achieve to sorting I want.

Thoughts?

 

Edited by altoid

I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Share this post


Link to post
Share on other sites

Hello Steve @altoid,

Please check if you have activated sort order support in the ajax attribute manager config class:

         $this->add('AM_USE_SORT_ORDER' , false);

Then you can controle the sort order in ajax attribute manager moving the options/attributes with the arrows on the right.

This works without additional installations, but you have to do it with ajax attribute manager. In the standard products_attributes.php page, sort order control is only available with the additional sort order add-on.

Sort order support is already included in the pad_base class.

In the product info qtpro products attribute content module, you have to switch on the option: "Sort Order"

 

Share this post


Link to post
Share on other sites
5 hours ago, raiwa said:

Hello Steve @altoid,

Please check if you have activated sort order support in the ajax attribute manager config class:


         $this->add('AM_USE_SORT_ORDER' , false);

Then you can controle the sort order in ajax attribute manager moving the options/attributes with the arrows on the right.

This works without additional installations, but you have to do it with ajax attribute manager. In the standard products_attributes.php page, sort order control is only available with the additional sort order add-on.

Sort order support is already included in the pad_base class.

In the product info qtpro products attribute content module, you have to switch on the option: "Sort Order"

 

Hello...I changed to

   /**
         * Options Sort Order
         */
         $this->add('AM_USE_SORT_ORDER' , true);

and I see in admin how I can move the values up and down.

What I can't figure out is to get the attributes drop down to sort like the table as follows:

image.thumb.png.2ead4d324845bf6023be3d9de39b786f.png

For reference, here is a product I did with just QT Pro before I added AJAX AM:

image.thumb.png.bd4314be2ad9d1ad70ba2b0fa04804f9.png

 

Is there something I have to change in the pad_base class file? Thx

Edited by altoid
add info

I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Share this post


Link to post
Share on other sites

Supposed the drop down menu sort order is correct, it seems the sort order support for the table module is incorrect.

Please try this chang ein includes/modules/content/product_info/cm_pi_qtpro_table.php:

find:

      // get the option names
      $products_options_name_query = tep_db_query("SELECT distinct popt.products_options_id, popt.products_options_name 
                                                   FROM products_options popt, products_attributes patrib 
                                                   WHERE patrib.products_id='" . (int)$_GET['products_id'] . "' 
                                                   AND patrib.options_id = popt.products_options_id 
                                                   AND popt.products_options_track_stock = '1' 
                                                   AND popt.language_id = '" . (int)$languages_id . "' 
                                                   ORDER BY popt.products_options_id");			
    
      // build array of attributes price delta
      $attributes_price = array();
      $products_attributes_query = tep_db_query("SELECT pa.options_id, pa.options_values_id, pa.options_values_price, pa.price_prefix 
                                                 FROM products_attributes pa 
                                                 WHERE pa.products_id = '" . (int)$_GET['products_id'] . "'"); 
          $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from products_attributes pa, products_options_values pov where pa.products_id = '" . (int)$this->products_id . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'" . $products_attributes_sort);
      while ($products_attributes_values = tep_db_fetch_array($products_attributes_query)) {
        $option_price = $products_attributes_values['options_values_price'];
        if ($products_attributes_values['price_prefix'] == "-") $option_price= -1*$option_price;
          $attributes_price[$products_attributes_values['options_id']][$products_attributes_values['options_values_id']] = $option_price;
      }									   

change to:

      // product options sort order support
      if ( defined('MODULE_CONTENT_PRODUCT_INFO_QTPRO_OPTIONS_USE_OPT_ATTR_SORT_ORDER') && MODULE_CONTENT_PRODUCT_INFO_QTPRO_OPTIONS_USE_OPT_ATTR_SORT_ORDER == 'True' ) {
        $products_options_sort = 'popt.products_options_sort_order';
      } else {
        $products_options_sort = 'popt.products_options_name';
      }
      // get the option names
      $products_options_name_query = tep_db_query("SELECT distinct popt.products_options_id, popt.products_options_name 
                                                   FROM products_options popt, products_attributes patrib 
                                                   WHERE patrib.products_id='" . (int)$_GET['products_id'] . "' 
                                                   AND patrib.options_id = popt.products_options_id 
                                                   AND popt.products_options_track_stock = '1' 
                                                   AND popt.language_id = '" . (int)$languages_id . "' 
                                                   ORDER BY " . $products_options_sort);			
    
      // build array of attributes price delta
      $attributes_price = array();
      // product options sort order support
      if ( defined('MODULE_CONTENT_PRODUCT_INFO_QTPRO_OPTIONS_USE_OPT_ATTR_SORT_ORDER') && MODULE_CONTENT_PRODUCT_INFO_QTPRO_OPTIONS_USE_OPT_ATTR_SORT_ORDER == 'True' ) {
        $products_attributes_sort = ' order by pa.products_options_sort_order';
      } else {
        $products_attributes_sort = '';
      }

      $products_attributes_query = tep_db_query("SELECT pa.options_id, pa.options_values_id, pa.options_values_price, pa.price_prefix 
                                                 FROM products_attributes pa 
                                                 WHERE pa.products_id = '" . (int)$_GET['products_id'] . "'"); 
          $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from products_attributes pa, products_options_values pov where pa.products_id = '" . (int)$_GET['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'" . $products_attributes_sort);
      while ($products_attributes_values = tep_db_fetch_array($products_attributes_query)) {
        $option_price = $products_attributes_values['options_values_price'];
        if ($products_attributes_values['price_prefix'] == "-") $option_price= -1*$option_price;
          $attributes_price[$products_attributes_values['options_id']][$products_attributes_values['options_values_id']] = $option_price;
      }									   

 

Share this post


Link to post
Share on other sites
5 hours ago, raiwa said:

Supposed the drop down menu sort order is correct, it seems the sort order support for the table module is incorrect.

Please try this chang ein includes/modules/content/product_info/cm_pi_qtpro_table.php:

find:


      // get the option names
      $products_options_name_query = tep_db_query("SELECT distinct popt.products_options_id, popt.products_options_name 
                                                   FROM products_options popt, products_attributes patrib 
                                                   WHERE patrib.products_id='" . (int)$_GET['products_id'] . "' 
                                                   AND patrib.options_id = popt.products_options_id 
                                                   AND popt.products_options_track_stock = '1' 
                                                   AND popt.language_id = '" . (int)$languages_id . "' 
                                                   ORDER BY popt.products_options_id");			
    
      // build array of attributes price delta
      $attributes_price = array();
      $products_attributes_query = tep_db_query("SELECT pa.options_id, pa.options_values_id, pa.options_values_price, pa.price_prefix 
                                                 FROM products_attributes pa 
                                                 WHERE pa.products_id = '" . (int)$_GET['products_id'] . "'"); 
          $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from products_attributes pa, products_options_values pov where pa.products_id = '" . (int)$this->products_id . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'" . $products_attributes_sort);
      while ($products_attributes_values = tep_db_fetch_array($products_attributes_query)) {
        $option_price = $products_attributes_values['options_values_price'];
        if ($products_attributes_values['price_prefix'] == "-") $option_price= -1*$option_price;
          $attributes_price[$products_attributes_values['options_id']][$products_attributes_values['options_values_id']] = $option_price;
      }									   

change to:


      // product options sort order support
      if ( defined('MODULE_CONTENT_PRODUCT_INFO_QTPRO_OPTIONS_USE_OPT_ATTR_SORT_ORDER') && MODULE_CONTENT_PRODUCT_INFO_QTPRO_OPTIONS_USE_OPT_ATTR_SORT_ORDER == 'True' ) {
        $products_options_sort = 'popt.products_options_sort_order';
      } else {
        $products_options_sort = 'popt.products_options_name';
      }
      // get the option names
      $products_options_name_query = tep_db_query("SELECT distinct popt.products_options_id, popt.products_options_name 
                                                   FROM products_options popt, products_attributes patrib 
                                                   WHERE patrib.products_id='" . (int)$_GET['products_id'] . "' 
                                                   AND patrib.options_id = popt.products_options_id 
                                                   AND popt.products_options_track_stock = '1' 
                                                   AND popt.language_id = '" . (int)$languages_id . "' 
                                                   ORDER BY " . $products_options_sort);			
    
      // build array of attributes price delta
      $attributes_price = array();
      // product options sort order support
      if ( defined('MODULE_CONTENT_PRODUCT_INFO_QTPRO_OPTIONS_USE_OPT_ATTR_SORT_ORDER') && MODULE_CONTENT_PRODUCT_INFO_QTPRO_OPTIONS_USE_OPT_ATTR_SORT_ORDER == 'True' ) {
        $products_attributes_sort = ' order by pa.products_options_sort_order';
      } else {
        $products_attributes_sort = '';
      }

      $products_attributes_query = tep_db_query("SELECT pa.options_id, pa.options_values_id, pa.options_values_price, pa.price_prefix 
                                                 FROM products_attributes pa 
                                                 WHERE pa.products_id = '" . (int)$_GET['products_id'] . "'"); 
          $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from products_attributes pa, products_options_values pov where pa.products_id = '" . (int)$_GET['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'" . $products_attributes_sort);
      while ($products_attributes_values = tep_db_fetch_array($products_attributes_query)) {
        $option_price = $products_attributes_values['options_values_price'];
        if ($products_attributes_values['price_prefix'] == "-") $option_price= -1*$option_price;
          $attributes_price[$products_attributes_values['options_id']][$products_attributes_values['options_values_id']] = $option_price;
      }									   

 

that's yielding this error:

[12-Oct-2018 14:53:25 America/New_York] PHP Parse error:  syntax error, unexpected '$attributes_price' (T_VARIABLE) in /home/Username/public_html/includes/modules/content/product_info/cm_pi_qtpro_table.php on line 80

but I want to note, the my table looks fine to me, the products are showing ascending properly from smallest to largest.

it's the drop down that reverses the order (from largest to smallest) that I want to change to match the table.

Thx

Edited by altoid

I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Share this post


Link to post
Share on other sites

@raiwa I came up with plan B, a work around that takes care of what I want to do.  In the attribute manager I enter the attributes in reverse order from what I want the drop down to show.  It works and the table remains as I want it to as well.

image.thumb.png.0082575ac10ad0e372be2dcd0f6edff6.png


I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Share this post


Link to post
Share on other sites

Hello Steve @altoid,

I just checked again and on my test/develop store the sort order in the drop down menu corresponds to the sort order etablished in admin attributes manager.

Do you have in your product info qtpro attributes module this entry: Use Option/Attribute Sort Order

and set it to "true"

If not you may need to update to the latest version.

The other solution would be to add "desc" behind the sort order in the pad_base queries:

        // product options sort order support
        if ( defined('MODULE_CONTENT_PRODUCT_INFO_QTPRO_OPTIONS_USE_OPT_ATTR_SORT_ORDER') && MODULE_CONTENT_PRODUCT_INFO_QTPRO_OPTIONS_USE_OPT_ATTR_SORT_ORDER == 'True' ) {
          $products_attributes_sort = ' order by pa.products_options_sort_order desc';
        } else {
          $products_attributes_sort = '';
        }

this inverts the sort order.

Share this post


Link to post
Share on other sites

Hi rainer.

 

I finaly had time to instal this module. Its giving me this error, tho:

 

[13-Oct-2018 10:23:22 Europe/Lisbon] PHP Fatal error:  Uncaught Error: Call to undefined function check_stock_qtpro() in /home/naturhigia/public_html/loja/shopping_cart.php:97
Stack trace:
#0 {main}
  thrown in /home/naturhigia/public_html/loja/shopping_cart.php on line 97
[13-Oct-2018 10:23:57 Europe/Lisbon] PHP Fatal error:  Uncaught Error: Call to undefined function check_stock_qtpro() in /home/naturhigia/public_html/loja/shopping_cart.php:97
Stack trace:
#0 {main}
  thrown in /home/naturhigia/public_html/loja/shopping_cart.php on line 97

 

any ideas?

Best regards,

Luis XAvier

 

Share this post


Link to post
Share on other sites
On 10/13/2018 at 4:15 AM, raiwa said:

Hello Steve @altoid,

I just checked again and on my test/develop store the sort order in the drop down menu corresponds to the sort order etablished in admin attributes manager.

Do you have in your product info qtpro attributes module this entry: Use Option/Attribute Sort Order

and set it to "true"

If not you may need to update to the latest version.

The other solution would be to add "desc" behind the sort order in the pad_base queries:


        // product options sort order support
        if ( defined('MODULE_CONTENT_PRODUCT_INFO_QTPRO_OPTIONS_USE_OPT_ATTR_SORT_ORDER') && MODULE_CONTENT_PRODUCT_INFO_QTPRO_OPTIONS_USE_OPT_ATTR_SORT_ORDER == 'True' ) {
          $products_attributes_sort = ' order by pa.products_options_sort_order desc';
        } else {
          $products_attributes_sort = '';
        }

this inverts the sort order.

Hello, I believe I have the latest version of QT Pro..

oscom-qtpro-bs-e317m-0xjSb

for product info modules I have 

cm_pi_qtpro_options

cm_pi_qtpro_table

My options settings are:

image.png.3b117f3edefb13593def157d2a648906.png

I can add the descending parameter and report back.

Edited by altoid

I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Share this post


Link to post
Share on other sites

@altoid,

Steve, sorry I forgot this detail:

Sort order support and configuration entry is only added if the sort order column is detected on module installation.

As you added the sort order at a later point, you need to uninstall and reinstall the product_info/QTPro options module.

Then you will see the Configuration entry "Use Option/Attribute Sort Order" below " Show default "Please Select" option"

Edited by raiwa

Share this post


Link to post
Share on other sites

hello Rainer, what can it be that products from product_info are placed twice in the shopping cart?
I mean, the quantity field.
 

      // customer adds a product from the products page
      case 'add_product' :    if (isset($_POST['products_id']) && is_numeric($_POST['products_id'])) {
//++++ QT Pro: Begin Changed code
                                $attributes=array();
                                if (isset($_POST['attrcomb']) && (preg_match("/^\d{1,10}-\d{1,10}(,\d{1,10}-\d{1,10})*$/",$_POST['attrcomb']))) {
                                  $attrlist=explode(',',$_POST['attrcomb']);
                                  foreach ($attrlist as $attr) {
                                    list($oid, $oval)=explode('-',$attr);
                                    if (is_numeric($oid) && $oid==(int)$oid && is_numeric($oval) && $oval==(int)$oval)
                                      $attributes[$oid]=$oval;
                                  }
                                }
                                if (isset($_POST['id']) && is_array($_POST['id'])) {
                                  foreach ($_POST['id'] as $key=>$val) {
                                    if (is_numeric($key) && $key==(int)$key && is_numeric($val) && $val==(int)$val)
                                      $attributes=$attributes + $_POST['id'];
                                  }
                                }
                                $cart->add_cart($_POST['products_id'], $cart->get_quantity(tep_get_uprid($_POST['products_id'], $attributes)) + $_POST['cart_quantity'], $attributes);
//++++ QT Pro: End Changed Code
                              }                              
                              $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)));
                              break;

 

Share this post


Link to post
Share on other sites

why does it work with $HTTP_POST_VARS
 

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

and not with $_POST
 

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

 

Share this post


Link to post
Share on other sites

My buy now button with quantity field:

echo ' <div class="pls_margin"><span class="text">' . TEXT_ENTER_QUANTITY . ' ' . tep_draw_input_field('cart_quantity', '1', 'style="width: 70px;" min="0"', 'number') . '</span> ' . tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_draw_button(IMAGE_BUTTON_IN_CART, 'fa fa-shopping-cart', null, 'primary', array('params' => 'data-has-attributes="' . (($products_attributes['total'] > 0) ? '1' : '0') . '" data-in-stock="' . (int)$product_info['products_quantity'] . '" data-product-id="' . (int)$product_info['products_id'] . '"'), 'btn btn-success btn-block btn-lg') .'</div>';

 

Share this post


Link to post
Share on other sites
3 hours ago, raiwa said:

@altoid,

Steve, sorry I forgot this detail:

Sort order support and configuration entry is only added if the sort order column is detected on module installation.

As you added the sort order at a later point, you need to uninstall and reinstall the product_info/QTPro options module.

Then you will see the Configuration entry "Use Option/Attribute Sort Order" below " Show default "Please Select" option"

@raiwa  Thank you for the explanation.  I uninstalled and reinstalled..set up some values and they are all in order now. 👍


I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Share this post


Link to post
Share on other sites

@Yepi hello Peter,

I do not know which exact store version you are using.

For the $_POST and $HTTP_POST_VARS difference one explication would be, if you are using ther latest CE FROZEN edition, the shopping cart actions have been moved to its own class and would need the $HTTP_POST_VARS  to be in the global list. Meanwhile $_POST is  super global and always available.

Otherwise you have several modifications, try to revert all of them step by step to localize the changes which produce the problem.

I had a look on your codes but can't see it.

You do not have the add products script duplicated in application_top.php and includes/actions/add_product.php, do you??

 

Share this post


Link to post
Share on other sites

I have located the error. I do not know why but it was the field name.

From "cart_quantity" I did "quantityfield" and everything works again.

I thank you anyway.

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

×