Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Show attributes in shopping cart sidebox?

Show attributes in shopping cart sidebox?

Views: 6,937

Results 1 to 20 of 30
16 Mar 2008, 11:42 PM
#1
htsean avatar

htsean

New Zenner

Join Date:
Mar 2008
Posts:
50
Plugin Contributions:
0

Show attributes in shopping cart sidebox?

Attributes are displayed as bullet tabs when viewed from the shopping cart, but are not displayed in the shopping cart sidebox. Would it be possible to add code to the tpl_shopping_cart.php file to display product attributes in the shopping cart sidebox?

17 Mar 2008, 3:56 PM
#3
htsean avatar

htsean

New Zenner

Join Date:
Mar 2008
Posts:
50
Plugin Contributions:
0

Re: Show attributes in shopping cart sidebox?

Thank you for that post, I think I may have found what I was looking for in that thread. In order to add model numbers to the shopping cart sidebox, you would find this code:

$content .= $products[$i]['name'] . '</span></a></li>' . "\n";  

and replace to this:

$content .= $products[$i]['name'] . ' (' . $products[$i]['model'] . ')</span></a></li>' . "\n";  

It seems like all I would have to do was find the variable for product attributes and add it on like $products[$i]['attributes']. Anyone know?

19 Mar 2008, 4:18 PM
#4
htsean avatar

htsean

New Zenner

Join Date:
Mar 2008
Posts:
50
Plugin Contributions:
0

Re: Show attributes in shopping cart sidebox?

bump.

I'm still trying to figure out how to get user-picked attributes to display in the shopping cart sidebox. Similar to the style that attributes display in the normal shopping cart.

20 Mar 2008, 5:03 AM
#6
htsean avatar

htsean

New Zenner

Join Date:
Mar 2008
Posts:
50
Plugin Contributions:
0

Re: Show attributes in shopping cart sidebox?

thx for the response haredo, the question sounds about the same, which is that i want the product's chosen attributes to appear next to the product name in the shopping cart sidebox.

kobra's answer didn't explain how to display a product's attributes along with the product in the shopping cart sidebox, like it does in the normal shopping cart, though. For example:

Brown Jacket
-XL
-w/ hood

but in the shopping cart sidebox, it will display as:

1 ea.- Brown Jacket

with no viewable attributes. I would like it to display in the sidebox as:

1 ea.- Brown Jacket
-XL
-w/ hood

21 Mar 2008, 1:33 AM
#7
htsean avatar

htsean

New Zenner

Join Date:
Mar 2008
Posts:
50
Plugin Contributions:
0

Re: Show attributes in shopping cart sidebox?

i'll pay someone to code this for me if the price is reasonable.. if i don't get this done, i'm gonna get canned. :frusty:

I think it would be a great addition to the downloads section too.

21 Mar 2008, 7:44 PM
#8
onebigfire avatar

onebigfire

New Zenner

Join Date:
Mar 2008
Posts:
1
Plugin Contributions:
0

Re: Show attributes in shopping cart sidebox?

I would like this feature too.

It would be great if it would update after each attribute was selected.

For example, if I were selling t-shirts... when the user clicked a radio button to select the size, it would show that attribute in the sidebar. When they selected a color, the sidebar would update, and so on.

Thanks everyone. I just joined this site and I love it!

26 Apr 2008, 2:09 AM
#9
alanekilauea avatar

alanekilauea

New Zenner

Join Date:
Jul 2007
Posts:
17
Plugin Contributions:
0

Re: Show attributes in shopping cart sidebox?

I think I've got it! :clap:
I've got my cart showing the option values in the shoppingcart sidebox.

Edit includes/templates/your_template/sideboxes/tpl_shopping_cart.php

Line 34, replace:

$content .= $products[$i]['name'] . '</span></a></li>' . "\n";

With:

$content .= $products[$i]['model'] . '</span></a>';	//or $products[$i]['name']   
// BOF Display Attributes //	   
  if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
    reset($products[$i]['attributes']);	
    foreach ($products[$i]['attributes'] as $option => $value) {
        while (list($option, $value) = each($products[$i]['attributes'])) {
          $attributes_query = "select popt.products_options_name, poval.products_options_values_name,
                                          pa.options_values_price, pa.price_prefix
                                   from " . TABLE_PRODUCTS_OPTIONS . " popt,
                                        " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval,
                                        " . TABLE_PRODUCTS_ATTRIBUTES . " pa
                                   where pa.products_id = '" . (int)$products[$i]['id'] . "'
                                   and pa.options_id = '" . (int)$option . "'
                                   and pa.options_id = popt.products_options_id
                                   and pa.options_values_id = '" . (int)$value . "'
                                   and pa.options_values_id = poval.products_options_values_id
                                   and popt.language_id = '" . (int)$_SESSION['languages_id'] . "'
                                   and poval.language_id = '" . (int)$_SESSION['languages_id'] . "'";

          $attributes = $db->Execute($attributes_query);

          $content .= ','. $attributes->fields['products_options_values_name'];  
		  }    
     }
  }
// EOF Display Attributes //	  
	  $content .= '</li>' . "\n";

I'm not a programmer so there may be a more elegant solution but it works and I'm happy.

Alane

26 Apr 2008, 2:14 AM
#10
haredo avatar

haredo

Totally Zenned

Join Date:
Apr 2006
Location:
Texas
Posts:
6,176
Plugin Contributions:
0

Re: Show attributes in shopping cart sidebox?

A,
Can we see a link to a site with this killer .php code please...

26 Apr 2008, 2:24 AM
#11
alanekilauea avatar

alanekilauea

New Zenner

Join Date:
Jul 2007
Posts:
17
Plugin Contributions:
0

Re: Show attributes in shopping cart sidebox?

It's on a client site that will be released next week but I think he'd be pissed if I linked it publicly at this point in the development. I will definitely make the link available here once the site is published May 1. I will PM you the link.
Alane

26 Apr 2008, 2:25 AM
#12
haredo avatar

haredo

Totally Zenned

Join Date:
Apr 2006
Location:
Texas
Posts:
6,176
Plugin Contributions:
0

Re: Show attributes in shopping cart sidebox?

A,
No need, I inserted the .php code, Works like a charm..

Thanks for your hard work:smile:

26 Apr 2008, 2:45 AM
#13
alanekilauea avatar

alanekilauea

New Zenner

Join Date:
Jul 2007
Posts:
17
Plugin Contributions:
0

Re: Show attributes in shopping cart sidebox?

Glad I got to contribute something for the community!
Alane

1 May 2008, 7:28 AM
#14
htsean avatar

htsean

New Zenner

Join Date:
Mar 2008
Posts:
50
Plugin Contributions:
0

Re: Show attributes in shopping cart sidebox?

alanekilauea, I can't thank you enough! I'm sure the zen-cart community is gonna be very glad ;)

the curiously MISSING feature of the shopping cart sidebox is finally resolved!

1 May 2008, 6:31 PM
#15
htsean avatar

htsean

New Zenner

Join Date:
Mar 2008
Posts:
50
Plugin Contributions:
0

Re: Show attributes in shopping cart sidebox?

I just got a chance to install the new code and it works great, this was exactly what I wanted.

But now the only thing is the formatting is a little awkward. Right now it looks something like this:

1 ea. Shirt, Blue, w/ Hood

The product's name and all the attributes are connected into a single line, which inevitably starts spilling into the next line and becomes illegible.

I tried messing around and got it so that each attribute has it's own line and indented so that it looks like this:

1 ea. Shirt
Blue
w/ Hood

But I can't seem to isolate the actual attribute text for customization. What I'm actually trying to do is put the attributes in bullet points like in the shopping cart (not the sidebox). Can't seem to get this to work, any ideas?

1 May 2008, 7:22 PM
#16
htsean avatar

htsean

New Zenner

Join Date:
Mar 2008
Posts:
50
Plugin Contributions:
0

Re: Show attributes in shopping cart sidebox?

Ok, I won't need to use the <ul><li> tags for bullet points cuz I just worked my way around it instead. Here's what I did:

With Alane's code pasted in at line 34, line 55 was where I added all my tags for text formatting. Here's my modified line 55:

          $content .= '<ul><div style="font-size:75%;">   ' . "-" . $attributes->fields['products_options_values_name'] . '</div></ul>';

With that setup, my attribute format in the shopping cart sidebox now look like this:

1 ea. Sweatshirt

-Purple

-w/ Hood

Without those huge line breaks between the attributes.

1 May 2008, 7:42 PM
#17
haredo avatar

haredo

Totally Zenned

Join Date:
Apr 2006
Location:
Texas
Posts:
6,176
Plugin Contributions:
0

Re: Show attributes in shopping cart sidebox?

Ht,
Thank for the small coding..

Please post me the complete file

  1. Just use the [PHP] at the front of the .php file and use ending tag also
1 May 2008, 7:47 PM
#18
htsean avatar

htsean

New Zenner

Join Date:
Mar 2008
Posts:
50
Plugin Contributions:
0

Re: Show attributes in shopping cart sidebox?

<?php
/**
 * Side Box Template
 *
 * @package templateSystem
 * @copyright Copyright 2003-2007 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: tpl_shopping_cart.php 7192 2007-10-06 13:30:46Z drbyte $
 */
  $content ="";

  $content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">';
  if ($_SESSION['cart']->count_contents() > 0) {
  $content .= '<div id="cartBoxListWrapper">' . "\n" . '<ul>' . "\n";
    $products = $_SESSION['cart']->get_products();
    for ($i=0, $n=sizeof($products); $i<$n; $i++) {
      $content .= '<li>';

      if (isset($_SESSION['new_products_id_in_cart']) && ($_SESSION['new_products_id_in_cart'] == $products[$i]['id'])) {
        $content .= '<span class="cartNewItem">';
      } else {
        $content .= '<span class="cartOldItem">';
      }

      $content .= $products[$i]['quantity'] . BOX_SHOPPING_CART_DIVIDER . '</span><a href="' . zen_href_link(zen_get_info_page($products[$i]['id']), 'products_id=' . $products[$i]['id']) . '">';

      if (isset($_SESSION['new_products_id_in_cart']) && ($_SESSION['new_products_id_in_cart'] == $products[$i]['id'])) {
        $content .= '<span class="cartNewItem">';
      } else {
        $content .= '<span class="cartOldItem">';
      }

      $content .= $products[$i]['name'] . '</span></a></li><br>' . "\n";
	  // BOF Display Attributes //	   
  if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
    reset($products[$i]['attributes']);	
    foreach ($products[$i]['attributes'] as $option => $value) {
        while (list($option, $value) = each($products[$i]['attributes'])) {
          $attributes_query = "select popt.products_options_name, poval.products_options_values_name,
                                          pa.options_values_price, pa.price_prefix
                                   from " . TABLE_PRODUCTS_OPTIONS . " popt,
                                        " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval,
                                        " . TABLE_PRODUCTS_ATTRIBUTES . " pa
                                   where pa.products_id = '" . (int)$products[$i]['id'] . "'
                                   and pa.options_id = '" . (int)$option . "'
                                   and pa.options_id = popt.products_options_id
                                   and pa.options_values_id = '" . (int)$value . "'
                                   and pa.options_values_id = poval.products_options_values_id
                                   and popt.language_id = '" . (int)$_SESSION['languages_id'] . "'
                                   and poval.language_id = '" . (int)$_SESSION['languages_id'] . "'";

          $attributes = $db->Execute($attributes_query);

          $content .= '<ul><div style="font-size:75%;">   ' . "-" . $attributes->fields['products_options_values_name'] . '</div></ul>';  
		  }    
     }
  }
// EOF Display Attributes //

      if (isset($_SESSION['new_products_id_in_cart']) && ($_SESSION['new_products_id_in_cart'] == $products[$i]['id'])) {
        $_SESSION['new_products_id_in_cart'] = '';
      }
    }
    $content .= '</ul>' . "\n" . '</div>';
  } else {
    $content .= '<div id="cartBoxEmpty">' . BOX_SHOPPING_CART_EMPTY . '</div>';
  }

  if ($_SESSION['cart']->count_contents() > 0) {
    $content .= '<hr />';
    $content .= '<div class="cartBoxTotal">' . $currencies->format($_SESSION['cart']->show_total()) . '</div>';
    $content .= '<br class="clearBoth" />';
  }

  if (isset($_SESSION['customer_id'])) {
    $gv_query = "select amount
                 from " . TABLE_COUPON_GV_CUSTOMER . "
                 where customer_id = '" . $_SESSION['customer_id'] . "'";
   $gv_result = $db->Execute($gv_query);

    if ($gv_result->RecordCount() && $gv_result->fields['amount'] > 0 ) {
      $content .= '<div id="cartBoxGVButton"><a href="' . zen_href_link(FILENAME_GV_SEND, '', 'SSL') . '">' . zen_image_button(BUTTON_IMAGE_SEND_A_GIFT_CERT , BUTTON_SEND_A_GIFT_CERT_ALT) . '</a></div>';
      $content .= '<div id="cartBoxVoucherBalance">' . VOUCHER_BALANCE . $currencies->format($gv_result->fields['amount']) . '</div>';
    }
  }
  $content .= '</div>';
?>
1 May 2008, 7:48 PM
#19
haredo avatar

haredo

Totally Zenned

Join Date:
Apr 2006
Location:
Texas
Posts:
6,176
Plugin Contributions:
0

Re: Show attributes in shopping cart sidebox?

HT,
SWEET,,, SWEET,,, Thanks for the added work...:smile:

1 May 2008, 7:50 PM
#20
htsean avatar

htsean

New Zenner

Join Date:
Mar 2008
Posts:
50
Plugin Contributions:
0

Re: Show attributes in shopping cart sidebox?

hehe, thx, but the big thanks has to go to Alane ;)