Packing Slip attributes sorting randomly
On my packing slip (and admin invoice), the attributes are sorting in random order.... only 'sometimes'. (Works great on product pages, just odd at times on packing slip)
i.e. (Product name and value sort orders set)
Product Caramel Cheesecake
Attribute 1: Bottle Size 5ml
Attribute 2: Cool Hit
Attribute 3: Base Mix 50/50
Attribute 4: First Flavor Choice
Attribute 5: First Flavor Percent
Attribute 6: Second Flavor Choice
Attribute 7: Second Flavor Choice
Will RANDOMLY appear as (example, other random sorts happen as well):
Attribute 5: First Flavor Percent
1 Product Caramel Cheesecake
Attribute 2: Cool Hit
Attribute 7: Second Flavor Choice
Attribute 3: Base Mix 50/50
Attribute 4: First Flavor Choice
Attribute 1: Bottle Size 5ml
Attribute 6: Second Flavor Choice
I would guess about 80% of the time it sorts correctly, and 20% randomly in any order. I've even had the qty/product line show up in between the products.
I found an old thread about this from 2006 that has been closed, but had no answer.
Any ideas on how to fix this?
Thx
Re: Packing Slip attributes sorting randomly
I got exactly the same problem. It's 2013 now. Did you find the solution?
Thanks in advance.
Re: Packing Slip attributes sorting randomly
since the OP has not been around since 2011, chances are he won't answer.
Please start by providing us some more info, like ZC version an installed add ons. Otherwise we can only guess
Re: Packing Slip attributes sorting randomly
Hello there. I really need help. My ZC version is 1.5.1. No big add ons to mention.
I have created products with 7 attributes and products with 12 attributes.
My problem is: when I place an order, the attributes appear totally in random order in the ORDERS page, ORDER, INVOICE and PACKING SLIP. This happens specially when the order includes several products ( 2 or more of 7 attributes) or when the order has at least one product of 12 attributes.
The interesting thing about this, it's that the ORDER CONFIRMATION EMAIL displays the information in the correct sort order, in the same sort order it appears in the website.
Here you can see the page with the product with 12 attributes:
http://armytags.com/tienda/index.php...kndsirkgba6vq5
The page with a product of only 7 attributes:
http://armytags.com/tienda/index.php...=1&language=en
I want the attributes appear in the ORDERS in the exact same order they appear in the product page.
For your information I have already set the sort value of option names. The order is SILENCERS: 10, CHAINS: 20, LINE 1: 30, LINE 2: 40 and so on....
The same goes for OPTION VALUES. I created a sort order for: SILENCERS OPTIONS: Black (0), Clear (1), Blue (2) and so on. CHAINS: 24" (14), 27" (15), 30" (16).
The TEXT attributes has no options, however I have given a consecutive ORDER: LINE 1 (19), LINE 2 (20) and so on, just in case. I have even assigned order numbers of bigger value than the previous attributes: SILENCERS and CHAINS to make sure they will appear after the first two attributes.
I have seen this topic has been a recurrent question along the years, but there is not a thread with the solution. I am afraid it has to be with the algorithm of the processing of the cart or the code in orders.php or order.php
I have made several TEST orders and the only pattern I have noticed is when there are a lot of products with attributes involved, the system gets crazy and order the attributes in a random order. Something a noticed: when I order 3 products, the attributes of at least one product appears ok, but the ones of the others product display totally in a random order, with no pattern.
In this thread ( http://www.zen-cart.com/showthread.p...e-packing-slip )
this person mentions this piece of code:
if (isset($order->products[$i]['attributes']) && (sizeof($order->products[$i]['attributes']) > 0)) {
for ($j=0, $k=sizeof($order->products[$i]['attributes']); $j<$k; $j++) {
echo '<br><nobr><small> <i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'];
echo '</i></small></nobr>';
}
}
I don't know if it is related and the loop collapses when the number of attributes is over a certain number (attributes > 10). In my case this seems to happen. But I don't know how to interpretate the code, since I am not an expert in PHP.
In my investigation I also found this ( http://coding.derkeiler.com/Archive/.../msg00094.html )
The title is: " $j++ oddtities from PHP 4.4.8 to 5.2.0 "
This guy says:
"Hi,
Migrating an application from PHP 4.4.8 to 5.2.0 hosted under debian, I'm encountering a weird thing that look like a bug, but I don't know from where the problem is comming: me, debian patch, or php himself.
Try the following pretty stupid sample code below (command line oriented, replace \r\n by <br> to test it from a web server):
<?php
// PHP 4.4.8 give the following:
// 0 - 0 - 0
// 1 - 1 - 1
// 2 - 2 - 2
// ...and so on
//
// PHP 5.2.0 give the following:
// 0 - 0 -
// 1 - 1 - 0
// 2 - 2 - 1
// ...and so on
.
.
. (continues)
¿Will that be related to my problem?
I am not an expert in PHP programming, but I have the feeling that the problem is the algorithm or the PHP processing. Can anybody check that?
Thanks in advance for your tips and suggestions.
Re: Packing Slip attributes sorting randomly
I did a test order on your site and everything I can see is in order ... did the order itself for #10332 come out in the right method?
So far on my test site I cannot break the sort order of my attributes either ...
Re: Packing Slip attributes sorting randomly
Hi Linda. Thanks for you time.
I received your order. It arrived ok.
Products Ordered: 1
1 x Order STEEL (2 equal dog tags)
- Silencers Color: Blue
- Chain Length: 27"
- LINE 1: test 1
- LINE 2: test 2
- LINE 3: test 3
- LINE 4: test 4
- LINE 5: test 5
In a perfect world, all of the products in the order should arrive in this order. The crazyness happens when there is more than one product ordered ( 2 or more ) or when you place an order with one product of more than 7 attributes ( two dog tags different = 12 attributes).
I encourage you to test with more than one product or at least one product with two dog tags different.
Sincerely:
Alfonso
Re: Packing Slip attributes sorting randomly
Here is an example of what I get:
Products Ordered: 3
1 x Order SHINY (2 equal dog tags)
#### - Silencers Color: Red
#### - Chain Length: 27 "
#### - Line 1: 1
#### - Line 2: 1
#### - Line 3: 1
#### - Line 4: 1
#### - LINE 5: 1
1 x Order STEEL (2 equal dog tags)
#### - LINE 5: a
#### - Line 4: a
#### - Line 3: a
#### - Line 2: a
#### - Line 1: a
#### - Chain Length: 27 "
#### - Silencers Color: Black
1 x Order WWII (2 equal dog tags)
#### - Line 3: 1
#### - Line 4: 1
#### - LINE 5: 1
#### - Line 2: 1
#### - Line 1: 1
#### - Chain Length: 27 "
#### - Silencers Color: Green
The first product: OK.
The second one: INVERTED ORDER.
The third one: totally random... :(
Re: Packing Slip attributes sorting randomly
Weird ... I still cannot repeat this on my site ...
Could you add the three Products to your customer basket then go to phpMyAdmin and browse the table customers_basket_attributes and look to see how those attributes are stored?
Do they all have the field products_options_sort_order filled in?
Are you able to do a screen shot of that?
3 Attachment(s)
Re: Packing Slip attributes sorting randomly
Hi Linda.
This is what I get after I included 3 products with 26 attributes ( 2 of 7 and 1 of 12). I have never manipulated any value here. Are they ok? do you need another view?
Thanks again for your time and concern.
Attachment 12270Attachment 12271Attachment 12272
Re: Packing Slip attributes sorting randomly
I was kind of hoping to see all the fields for your customers_id for all of the products/attributes added to the customers_basket_attributes to see what is being put in each of the fields ...
Re: Packing Slip attributes sorting randomly
How can I show them to you? I don't know where to click.
Re: Packing Slip attributes sorting randomly
Let's say your customers_id was 2, you could do a search for:
Code:
SELECT *
FROM zen_customers_basket_attributes
WHERE customers_id = 2;
and obtain all the fields from the customers_basket_attributes for just customers_id 2 ...
2 Attachment(s)
Re: Packing Slip attributes sorting randomly
Ok I hope I did it ok. The first screen is the result of the search. The second one when I click on the first attribute. I don't know how to show a table with the values of all of them at the same time. I have to check them one by one.
Sincerely:
Alfonso
Attachment 12273Attachment 12274
Re: Packing Slip attributes sorting randomly
You have an odd phpMyAdmin that it does not display all the fields on 1 row per attribute ...
I was hoping to spot what might be causing this issue ...
Is this a clean install of Zen Cart v1.5.1 or an upgrade?
Re: Packing Slip attributes sorting randomly
Ok, my host is GoDaddy ( :( I know, apparently not the best host). You can ask their customer service to install the application and they did it. It is a fresh new installation.
Is everything ok in the SCR4? in product_options_sort_order dropdown Function menu shouldn't be something chosen?
Thanks again.
Re: Packing Slip attributes sorting randomly
Ok, now I am investigating more the SQL table and I have one question: I can see in SCR4 that the products_options_sort_order is defined as TEXT, and the value is 10.00001, where there should be a 10 alone.
Why is defined as text? shouldn't be defined as INT or MEDIUMINT or TINYINT (any numeric definition) so the table can read it as a number and to order the attributes in ascending order?
Will that be the problem? should I try to modify that definition?
2 Attachment(s)
Re: Packing Slip attributes sorting randomly
Ok. I could finally take a picture of the sort order of the product_option_sort_order attributes. It looks pretty messy to me. Obviously there is a mistake since I define order in integer numbers of 2 in Zen Cart admin attributes order ( SCR6), and they appear with 5 decimals and in not ascendent order. How can I fix this mess? How can I define the ascendent order? Attachment 12277Attachment 12278
Re: Packing Slip attributes sorting randomly
The Sort Order and what is store in the database table for the customers_basket_attributes will appear different, but they are looking more or less correct ...
1 Attachment(s)
Re: Packing Slip attributes sorting randomly
SOLVED, SOLVED, SOLVED!!!!!!!!!!!!!!!!!!
I nail it. Thanks Linda, for showing me where to look for the solution.
I am going to explain how I did it, step by step.
Firstable. I read here: (http://www.zen-cart.com/wiki/index.p...ket_attributes) the next, and I quote in BOLD:
"When an order is placed, the orders class takes the information in the currently active cart and transfers the order details from the cart into the orders_products_attributes table, constituting part of the order placed."
Then you go to that table (orders_products_attributes) and in OPERATIONS, you choose MODIFY ORDER BY OF THE TABLE, select (by default) " order_products_attributes_id " ONLY "Ascendent", press CONTINUE, and VOILA!!!!!! (See Picture)
Now all of your orders will magicly arrange and appear with the correct attributes order.
Again, thanks Linda, for showing me where to look for, and I share the solution with the Zen Cart community.
OLD PROBLEM AND BUG, AND MISTERY, SOLVED!!!!!!! IN 2013.
Attachment 12279
Re: Packing Slip attributes sorting randomly
Thanks for sharing the solution that worked for you ... :smile:
It is odd that you had to do that but I am glad you found this strange issue ...