Forums / General Questions / Group attributes on order confirmation and order information pages

Group attributes on order confirmation and order information pages

Started by mypctechs on 16 May 2011, 10:56 AM · Views: 1,004

Results 1 to 2 of 2
16 May 2011, 10:56 AM
#1
mypctechs avatar

mypctechs

New Zenner

Join Date:
Aug 2009
Location:
Phoenix, Arizona
Posts:
6
Plugin Contributions:
0

Group attributes on order confirmation and order information pages

Hello, I've searched around everywhere but can't quite find anything pertaining to this question. Please direct me if there's a module floating around that can help with what I need to do (Zen 1.3.9h).

I have a store under development with a LOT of attributes for one product. Most of them are grouped, and a lot of them allow multiple checkbox selections per group.

On the order summary during checkout and on the email confirmation, all of the options print out and it looks horrible. For example, let's say I have 30 attributes in 3 groups selected. The confirmation email looks something like this:

Products
1 X Product Cool Duster $999.99
GROUP A: Option 1
GROUP A: Option 2
GROUP A: Option 3
GROUP A: Option 4
GROUP B: Option 2
GROUP B: Option 5
GROUP B: Option 9
GROUP D: Option 1
GROUP E: Option 1
GROUP E: Option 2
GROUP E: Option 3
GROUP E: Option 4
Etc...

I'd rather this listed instead:
GROUP A: Option 1, Option 2, Option 3, Opetion 4
GROUP B: Option 2, Option 5....

I found the code in order.php to start changing this the way I would like.

this->products_ordered_attributes .= "\n\t" . 

That code can be modified pretty heavily to make it so that all of the individual options appear in a uniform way under the GROUP and the products_options_name doesn't appear more than once for each option being listed.

However, I still have this problem throughout the store (in the checkout summary, when visiting the client order details page). It looks like a ton of coding to make this change throughout the entire Zen Cart.

Has anyone already created a MOD that lists attributes in a cleaner way, grouped with the options name instead of listing each option name every time?

TIA


Andre Morris
seenBEST Web Design

17 May 2011, 4:51 AM
#2
mypctechs avatar

mypctechs

New Zenner

Join Date:
Aug 2009
Location:
Phoenix, Arizona
Posts:
6
Plugin Contributions:
0

Re: Group attributes on order confirmation and order information pages

This project is on a tight deadline so I coded something that works just for me. It's not fleshed out enough to post all of the code, so if someone finds this thread and wants to know how to do something like this you'll have to modify the following files.

I think this would make a cool mod if someone has the time to write it out. If you plan on doing it let me know if I can help!

includes\classes\order.php
This is the page that displays order details in a confirmation email. Find the line starting with:

$this->products_ordered_attributes .= "\n\t"
```. 

This line is running inside of a loop and displays each attribute one by one. Every time the loop runs you'll need to check the attribute name. I used something like this to check for OPTION A in the name of the attribute:

if (stristr($attributes_values->fields['products_options_name'],'OPTION A')) {


Then I wrote my own logic. If the option name was repeating from the last time in the loop, strip out the name and write a comma instead. 

**includes\templates\template_default\templates\tpl_account_history_info_default.php**
This is the code for the account history when a customer views what has been ordered before. Similar to above you'll need to check the option name through each instance of the loop.

echo '<li>' . $order->products[$i]['attributes'][$j]['option'] . TEXT_OPTION_DIVIDER . nl2br(zen_output_string_protected($order->products[$i]['attributes'][$j]['value'])) . '</li>';


**includes\templates\template_default\templates\tpl_checkout_confirmation_default.php**
This page displays the checkout confirmation pages. Replace each attribute instance of the loop the same as before.

  <li><?php echo $order->products[$i]['attributes'][$j]['option'] . ': ' . nl2br(zen_output_string_protected($order->products[$i]['attributes'][$j]['value'])); ?></li>

**includes\templates\template_default\templates\tpl_shopping_cart_default.php**
This is what shows when adding the product to the shopping cart. The code to hook into is:

<li><?php echo $value['products_options_name'] . TEXT_OPTION_DIVIDER . nl2br($value['products_options_values_name']); ?></li> ```

Andre Morris
seenBEST Web Design