Jump to content

Changing the order of "Product options"?


Guest macstar

Recommended Posts

Guest macstar

This seems simple, but i don't see how to fix this......

Exp in the admin panel it's in this order:

T-Shirt > Colour > Red

T-Shirt > Colour > Blue

......But it shows a different order on the website:

T-Shirt > Colour > Blue

T-Shirt > Colour > Red

I don't see how to fix this??? This is just annoying and the only way i can fix it sometimes is to delet all my work and repost the options....Help!!

Link to comment
Share on other sites

Guest Devlish

This seems simple, but i don't see how to fix this......

Exp in the admin panel it's in this order:

T-Shirt > Colour > Red

T-Shirt > Colour > Blue

......But it shows a different order on the website:

T-Shirt > Colour > Blue

T-Shirt > Colour > Red

I don't see how to fix this??? This is just annoying and the only way i can fix it sometimes is to delet all my work and repost the options....Help!!

I agree this is very annoying and a problem. I have as many as 40 color options for some products. I can not get them to stay in the order I list them. I am having to redo all of my options and use a new method of breaking colors into more categories of options. IE instead of colors, Grade 1 fabrics with 10 colors, grade 2 fabrics with 9 colors. The only problem is even doing that the colors will not stay in any order within the group. At least one always ends up out of order and looking sloppy.

If this is not something we are both missing in how to add options then it really should be addressed in a future version. For now I am going mod shopping again.

Link to comment
Share on other sites

Guest Brivtech

It wouldn't be difficult to change this...

in includes/content/viewProd.inc.php, find this line:

(4.1.1)

;) )... 2. Remove or change the ORDER BY criteria, so that it pulls the options from the databse as it gets them, and displays them that way, in the case of 4.1.1, which I'm still running across the board, replace

	## Build SQL for product options

	  $query = "SELECT ".$glob['dbprefix']."CubeCart_options_bot.option_id, ".$glob['dbprefix']."CubeCart_options_bot.value_id, option_price, option_symbol, value_name, option_name, assign_id FROM `".$glob['dbprefix']."CubeCart_options_bot` INNER JOIN `".$glob['dbprefix']."CubeCart_options_mid` ON ".$glob['dbprefix']."CubeCart_options_mid.value_id = ".$glob['dbprefix']."CubeCart_options_bot.value_id INNER JOIN `".$glob['dbprefix']."CubeCart_options_top` ON ".$glob['dbprefix']."CubeCart_options_bot.option_id = ".$glob['dbprefix']."CubeCart_options_top.option_id WHERE product =".$db->mySQLSafe($_GET['productId'])." ORDER BY option_name, value_name ASC";




(4.2.0)
	## Build SQL for product options

	  $query		= sprintf("SELECT B.*, T.option_name, T.option_type, M.value_name FROM %1\$sCubeCart_options_bot AS B LEFT JOIN %1\$sCubeCart_options_mid AS M ON B.value_id = M.value_id, %1\$sCubeCart_options_top AS T WHERE B.option_id = T.option_id AND B.product = %2\$d ORDER BY T.option_name ASC", $glob['dbprefix'], $_GET['productId']);




Where you see ORDER BY near the end of the line, here is the crieria by which the options are ordered. in the example of red and blue, it's doing it alphabetically - Which I suppose would hold some logic, however, you are right, there needs to be more than one way to present the options....



So, here's your options for a solution (ARF! 
ORDER BY option_name, value_name ASC


with:


ORDER BY option_id, value_id ASC

or

1. Add in a bit of programming and an extra database field to the top options, to act as the sort criteria, which then gets applied to the middle options, so, for instance...

Create Option >

ID > Option Name > Display Order > Asc/Desc.

Where display order could have a dropdown for:

- alphabetical

- as entered

- Price

and Asc/Desc means Ascending or Descending respectively... and of course, apply that search criteria.

:yeahhh:

Link to comment
Share on other sites

Guest Devlish

It wouldn't be difficult to change this...

in includes/content/viewProd.inc.php, find this line:

(4.1.1)

;) )... 2. Remove or change the ORDER BY criteria, so that it pulls the options from the databse as it gets them, and displays them that way, in the case of 4.1.1, which I'm still running across the board, replace

	## Build SQL for product options

	  $query = "SELECT ".$glob['dbprefix']."CubeCart_options_bot.option_id, ".$glob['dbprefix']."CubeCart_options_bot.value_id, option_price, option_symbol, value_name, option_name, assign_id FROM `".$glob['dbprefix']."CubeCart_options_bot` INNER JOIN `".$glob['dbprefix']."CubeCart_options_mid` ON ".$glob['dbprefix']."CubeCart_options_mid.value_id = ".$glob['dbprefix']."CubeCart_options_bot.value_id INNER JOIN `".$glob['dbprefix']."CubeCart_options_top` ON ".$glob['dbprefix']."CubeCart_options_bot.option_id = ".$glob['dbprefix']."CubeCart_options_top.option_id WHERE product =".$db->mySQLSafe($_GET['productId'])." ORDER BY option_name, value_name ASC";




(4.2.0)
	## Build SQL for product options

	  $query		= sprintf("SELECT B.*, T.option_name, T.option_type, M.value_name FROM %1\$sCubeCart_options_bot AS B LEFT JOIN %1\$sCubeCart_options_mid AS M ON B.value_id = M.value_id, %1\$sCubeCart_options_top AS T WHERE B.option_id = T.option_id AND B.product = %2\$d ORDER BY T.option_name ASC", $glob['dbprefix'], $_GET['productId']);




Where you see ORDER BY near the end of the line, here is the crieria by which the options are ordered. in the example of red and blue, it's doing it alphabetically - Which I suppose would hold some logic, however, you are right, there needs to be more than one way to present the options....



So, here's your options for a solution (ARF! 
ORDER BY option_name, value_name ASC


with:


ORDER BY option_id, value_id ASC

or

1. Add in a bit of programming and an extra database field to the top options, to act as the sort criteria, which then gets applied to the middle options, so, for instance...

Create Option >

ID > Option Name > Display Order > Asc/Desc.

Where display order could have a dropdown for:

- alphabetical

- as entered

- Price

and Asc/Desc means Ascending or Descending respectively... and of course, apply that search criteria.

:yeahhh:

Thank you!!! That helps to know there is a solution.

LOL now comes the hard part. Using the info. One of these days I need to learn php, html, and several other languages.

Link to comment
Share on other sites

Guest JodieR

I don't know any of the languages much either... but if you follow things to a "T" it's relatively easy. It would be nice to know what we're doing (know and understand the language).. one day we might LOL.

I might try this after the next upgrade.

Link to comment
Share on other sites

  • 3 weeks later...

I tried to replace:

  ## Build SQL for product options

	  $query		= sprintf("SELECT B.*, T.option_name, T.option_type, M.value_name FROM %1\$sCubeCart_options_bot AS B LEFT JOIN %1\$sCubeCart_options_mid AS M ON B.value_id = M.value_id, %1\$sCubeCart_options_top AS T WHERE B.option_id = T.option_id AND B.product = %2\$d ORDER BY T.option_name ASC", $glob['dbprefix'], $_GET['productId']);




for






  ## Build SQL for product options

	  $query		= sprintf("SELECT B.*, T.option_name, T.option_type, M.value_name FROM %1\$sCubeCart_options_bot AS B LEFT JOIN %1\$sCubeCart_options_mid AS M ON B.value_id = M.value_id, %1\$sCubeCart_options_top AS T WHERE B.option_id = T.option_id AND B.product = %2\$d ORDER BY T.option_[b]id[/b] ASC", $glob['dbprefix'], $_GET['productId']);

But it don't work. I want to order my product options alphabeticly. Can somebody help me? I use Cubecart 4.2.0.

Link to comment
Share on other sites

Guest mikelschwarz

I opened a ticket with CubeCart support and they were kind enough to provide this answer. I changed mine to the version in #2 below. However, to be sure I would get the sort order exactly right, I went back and removed all my product options and option values and recreated them in the order I wanted them to appear. After I redid that part, changed the OrderBy statement, my product options are being listed in the order I wanted.

Keep in mind, if you have any other Mods, you have to make this mod to the viewProd.inc.php you have in production. Also, just in case, make a backup first :homestar:

I am using the latest version of CubeCart (version 4.2.1)

### From CubeCart Support #####

You have to modify the SQL query a bit. Posting two option of product option values order.

OPEN includes/content/viewProd.inc.php

SEARCH FOR

----------

$query = sprintf("SELECT B.*, T.option_name, T.option_type,

M.value_name FROM %1\$sCubeCart_options_bot AS B LEFT JOIN

%1\$sCubeCart_options_mid AS M ON B.value_id = M.value_id, %1\$sCubeCart_options_top AS T

WHERE B.option_id = T.option_id AND B.product = %2\$d ORDER BY

T.option_name ASC", $glob['dbprefix'], $_GET['productId']);

REPLACE in line above

-------

ORDER BY T.option_name ASC

#1#

WITH [sort by option value name]

----

ORDER BY T.option_name ASC, M.value_name ASC

#2#

WITH [sort by order you assigned to a product]

----

ORDER BY T.option_name ASC, B.assign_id ASC

In other words you should add some additional sorting just after ORDER BY T.option_name ASC

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