Forums / Templates, Stylesheets, Page Layout / How can I show the attribute weight for each item in cart?

How can I show the attribute weight for each item in cart?

Locked

Views: 5,123

Results 21 to 40 of 41
This thread is locked. New replies are disabled.
3 Sep 2007, 11:27 PM
#21
fay808 avatar

fay808

New Zenner

Join Date:
Aug 2007
Posts:
35
Plugin Contributions:
0

How can I show the attribute weight for each item in cart?

I know its my string - I see how order.php is called from the before mentioned pages - I will keep trying how the string should call the products weight. Answering my own question. The string is not the same as in orders history. Will let you know if I make this work. Thx.

4 Sep 2007, 2:35 AM
#22
fay808 avatar

fay808

New Zenner

Join Date:
Aug 2007
Posts:
35
Plugin Contributions:
0

Re: How can I show the attribute weight for each item in cart?

So far working nicely: check out confirmation + email + order history all good BUT

In Admin: Orders + Invoice + Packing slip weights NOT showing up?

  if (isset($order->products[$i]['attributes']) && (($k = sizeof($order->products[$i]['attributes'])) > 0)) {
    for ($j = 0; $j < $k; $j++) {
      echo '<br><nobr><small> <i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . nl2br(zen_output_string_protected($order->products[$i]['attributes'][$j]['value'])) . nl2br(zen_output_string_protected($order->products[$i]['attributes'][$j]['weights']));

I am not sure if its this string above is the problem and repeats itself on all three or order.php mods

Any ideas? I am just about really almost there - my scripting is ok as you can tell -

the admin part is important we will be printing out the packing slip and will need the weights there really -

Thx Thx Thx :blink:

4 Sep 2007, 3:08 AM
#23
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How can I show the attribute weight for each item in cart?

Just curious ...

Each Product shows the total weight of the Product Weight plus the Attribute(s) Weight ... why do you need it broken out? :unsure:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

4 Sep 2007, 4:13 AM
#24
fay808 avatar

fay808

New Zenner

Join Date:
Aug 2007
Posts:
35
Plugin Contributions:
0

Re: How can I show the attribute weight for each item in cart?

Well as its an delivery service based on weights of produce into a box...I need to show the weights on the invoices, packing slip and order pages in admin. as we will print out the slips, take them to the warehouse and split orders based on the weight options. There are 5 box sizes and each one has a different weight etc. I suppose we could print out emails as it shows there now. However it will be helpful to include options with weights.

As below in the invoice, orders and packing slip the order shows like this:

1 x Small Produce Box

  • Baby Carrots:
  • Bananas:
  • Cali Pink Grapefruit:
  • Cantaloupe:

This is the email and order confirmation and history views with the new mod:

1 x Small Produce Box = $39.00
Baby Carrots 1 lbs.
Bananas 2 lbs.
Cali Pink Grapefruit 1 lbs.
Cantaloupe 2 lbs.

I scripted the string as above for the pages - its probably my order.php - tried a few ways to handle it - even changed the array to weights instead of weight as I though it would interfere with the existing weight array -still no go.

4 Sep 2007, 4:31 AM
#25
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How can I show the attribute weight for each item in cart?

In the
/admin/includes/classes/order.php

add it to the select then the build:

        $attributes = $db->Execute("select products_options, products_options_values, options_values_price,
                                           price_prefix, products_attributes_weight,
                                           product_attribute_is_free
                                    from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . "
                                    where orders_id = '" . (int)$order_id . "'
                                    and orders_products_id = '" . (int)$orders_products->fields['orders_products_id'] . "'");
        if ($attributes->RecordCount()>0) {
          while (!$attributes->EOF) {
            $this->products[$index]['attributes'][$subindex] = array('option' => $attributes->fields['products_options'],
                                                                     'value' => $attributes->fields['products_options_values'],
                                                                     'prefix' => $attributes->fields['price_prefix'],
                                                                     'price' => $attributes->fields['options_values_price'],
                                                                     'weight' => $attributes->fields['products_attributes_weight'],
                                                                     'product_attribute_is_free' =>$attributes->fields['product_attribute_is_free']);

            $subindex++;
            $attributes->MoveNext();
          }
        }

/admin/orders.php

reference it as:

$order->products[$i]['attributes'][$j]['weight']

NOTE: you can add prefix too if you like in there ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

4 Sep 2007, 4:41 AM
#26
fay808 avatar

fay808

New Zenner

Join Date:
Aug 2007
Posts:
35
Plugin Contributions:
0

Re: How can I show the attribute weight for each item in cart?

Thats pretty much what I did - still no go.

Is it odd that the tpl picks it up but not admin?

I called the array weights - email confirmation picks as the string below works, I know it doesn't need the special chars either really - copy and pasted

like this - i did not add the weight prefix - it will always be lbs so I inserted here:

      $this->products_ordered_attributes .= "\n\t" . $attributes_values->fields['products_options_name'] . ' ' . zen_decode_specialchars($this->products[$i]['attributes'][$j]['value']).  ' ' . zen_decode_specialchars($this->products[$i]['attributes'][$j]['weights']).  ' ' .  lbs .  '. ';
4 Sep 2007, 4:53 AM
#27
fay808 avatar

fay808

New Zenner

Join Date:
Aug 2007
Posts:
35
Plugin Contributions:
0

Re: How can I show the attribute weight for each item in cart?

This is what the ref on my page looks like - there are 2 references for the subindex - I coded both

$subindex = 0;
$attributes_query = "select products_options_id, products_options_values_id, products_options, products_options_values, products_attributes_weight, options_values_price, price_prefix from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . "
where orders_id = '" . (int)$order_id . "'
and orders_products_id = '" . (int)$orders_products->fields['orders_products_id'] . "'";

  $attributes = $db->Execute($attributes_query);
  if ($attributes->RecordCount()) {
    while (!$attributes->EOF) {
      $this->products[$index]['attributes'][$subindex] = array('option' => $attributes->fields['products_options'],
                                                               'value' => $attributes->fields['products_options_values'],
  														   'weights' => $attributes->fields['products_attributes_weight'],
                                                               'prefix' => $attributes->fields['price_prefix'],
                                                               'price' => $attributes->fields['options_values_price']);

      $subindex++;
      $attributes->MoveNext();
    }
  }
4 Sep 2007, 4:54 AM
#28
fay808 avatar

fay808

New Zenner

Join Date:
Aug 2007
Posts:
35
Plugin Contributions:
0

Re: How can I show the attribute weight for each item in cart?

This is how it looks in admin/orders.php

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'] . ': ' . nl2br(zen_output_string_protected($order->products[$i]['attributes'][$j]['value'])) . $order->products[$i]['attributes'][$j]['weights'];

By the way I used weight singular as well, it doesn't really matter if I build it with whatever name I want to right?

4 Sep 2007, 5:07 AM
#29
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How can I show the attribute weight for each item in cart?

You are in v1.3.7.1 correct?

Without any add-ons etc. in the admin in regard to attributes and such?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

4 Sep 2007, 12:49 PM
#30
fay808 avatar

fay808

New Zenner

Join Date:
Aug 2007
Posts:
35
Plugin Contributions:
0

Re: How can I show the attribute weight for each item in cart?

Hi Ajeh,

No addons - latest version - downloaded 2 weeks ago.

4 Sep 2007, 2:48 PM
#31
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How can I show the attribute weight for each item in cart?

Are you sure you made the changes in:
/admin/includes/classes/order.php

that I posted above?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

4 Sep 2007, 3:34 PM
#32
fay808 avatar

fay808

New Zenner

Join Date:
Aug 2007
Posts:
35
Plugin Contributions:
0

Re: How can I show the attribute weight for each item in cart?

Yes I made the changes as detailed.

Shall I upload the file? Have a look see.

4 Sep 2007, 3:35 PM
#33
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How can I show the attribute weight for each item in cart?

From here to the bottom of the order class:

while (!$orders_products->EOF) {
// convert quantity to proper decimals - account history

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

4 Sep 2007, 3:37 PM
#34
fay808 avatar

fay808

New Zenner

Join Date:
Aug 2007
Posts:
35
Plugin Contributions:
0

Re: How can I show the attribute weight for each item in cart?

attached

sorry read your post after sending zip

4 Sep 2007, 3:42 PM
#35
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How can I show the attribute weight for each item in cart?

Let's take a step back ...

Are you trying to change the order class in the admin or the catalog and for what file in the catalog or admin? :blink:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

4 Sep 2007, 3:47 PM
#36
fay808 avatar

fay808

New Zenner

Join Date:
Aug 2007
Posts:
35
Plugin Contributions:
0

Re: How can I show the attribute weight for each item in cart?

So far I have the tpl order history, tpl confirmation and email confirmation parsing weights.

Now I need in admin to view the invoice.php, orders.php, and packingslip.php with the weights.

For some reason it won't show up in the three admin pages - just the front end and email conf.

I am attaching the invoice.php part where it calls the array as an example, the same string applies on all three pages.

<?php for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) { echo ' <tr class="dataTableRow">' . "\n" . ' <td class="dataTableContent" valign="top" align="right">' . $order->products[$i]['qty'] . ' x</td>' . "\n" . ' <td class="dataTableContent" valign="top">' . $order->products[$i]['name']; if (isset($order->products[$i]['attributes']) && (($k = sizeof($order->products[$i]['attributes'])) > 0)) { for ($j = 0; $j < $k; $j++) { echo '<br><nobr><small> <i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . nl2br(zen_output_string_protected($order->products[$i]['attributes'][$j]['value'])) . $order->products[$i]['attributes'][$j]['weights']; if ($order->products[$i]['attributes'][$j]['price'] != '0') echo ' (' . $order->products[$i]['attributes'][$j]['prefix'] . $currencies->format($order->products[$i]['attributes'][$j]['price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . ')'; if ($order->products[$i]['attributes'][$j]['product_attribute_is_free'] == '1' and $order->products[$i]['product_is_free'] == '1') echo TEXT_INFO_ATTRIBUTE_FREE; echo '</i></small></nobr>'; } } echo ' </td>' . "\n" . ' <td class="dataTableContent" valign="top">' . $order->products[$i]['model'] . '</td>' . "\n"; echo ' <td class="dataTableContent" align="right" valign="top">' . zen_display_tax_value($order->products[$i]['tax']) . '%</td>' . "\n" . ' <td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format($order->products[$i]['final_price'], true, $order->info['currency'], $order->info['currency_value']) . ($order->products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->format($order->products[$i]['onetime_charges'], true, $order->info['currency'], $order->info['currency_value']) : '') . '</b></td>' . "\n" . ' <td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format(zen_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) . ($order->products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->format(zen_add_tax($order->products[$i]['onetime_charges'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) : '') . '</b></td>' . "\n" . ' <td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format($order->products[$i]['final_price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . ($order->products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->format($order->products[$i]['onetime_charges'], true, $order->info['currency'], $order->info['currency_value']) : '') . '</b></td>' . "\n" . ' <td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format(zen_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . ($order->products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->format(zen_add_tax($order->products[$i]['onetime_charges'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) : '') . '</b></td>' . "\n"; echo ' </tr>' . "\n"; } ?>
  <tr>
    <td align="right" colspan="8"><table border="0" cellspacing="0" cellpadding="2">
<?php for ($i = 0, $n = sizeof($order->totals); $i < $n; $i++) { echo ' <tr>' . "\n" . ' <td align="right" class="'. str_replace('_', '-', $order->totals[$i]['class']) . '-Text">' . $order->totals[$i]['title'] . '</td>' . "\n" . ' <td align="right" class="'. str_replace('_', '-', $order->totals[$i]['class']) . '-Amount">' . $order->totals[$i]['text'] . '</td>' . "\n" . ' </tr>' . "\n"; } ?>
4 Sep 2007, 3:55 PM
#37
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How can I show the attribute weight for each item in cart?

Check which file you are editing for the order class:
/admin/includes/classes/order.php

There are TWO order class files ... one in the catalog and one in the admin ...

Whatever you attached is NOT an Admin class file from v1.3.7.1 ... or even v1.3.7 ...

Did you overwrite it with the order class from the catalog perhaps?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

4 Sep 2007, 4:02 PM
#38
fay808 avatar

fay808

New Zenner

Join Date:
Aug 2007
Posts:
35
Plugin Contributions:
0

Re: How can I show the attribute weight for each item in cart?

Oh man I am kicking myself right now!!!!!!

Let me code this and see if it works - duhhhh

No wonder - in my previous posts I was thinking there must of been another file to add the arrays for admin and of course its order.php in admin - hello!

blah

stay tuned - thanks for the reply and the consistent help -

amazing!

4 Sep 2007, 4:04 PM
#39
fay808 avatar

fay808

New Zenner

Join Date:
Aug 2007
Posts:
35
Plugin Contributions:
0

Re: How can I show the attribute weight for each item in cart?

And I misread your post linked above - sorry man!

4 Sep 2007, 4:44 PM
#40
fay808 avatar

fay808

New Zenner

Join Date:
Aug 2007
Posts:
35
Plugin Contributions:
0

Re: How can I show the attribute weight for each item in cart?

So of course it worked!

Your code is beautiful and easy to mod - thank you.

Expect a donation asap.

Ajeh, again, great to be in your presence.

Thank you.

:bigups:

so happy to be out of this simple confusion I was in - have a fabulous day, month , life !