Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Archived

This topic is now archived and is closed to further replies.

demastermind

Product attributes not showing in Shopping Cart Infobox Help!

Recommended Posts

Hello, It is bothersome that after I add an item to my cart (ex. Quantity: 3 Size: small ITEM NAME: Shirts) it only shows up in the shopping cart infobox as 3 x Shirts. If I then add 3 large Shirts, it will also show up as 3 x Shirts. This is a problem, though it was always that way. Only once you go the the Shopping cart page does it show the items like this:

 

Shirts

- Large

Qt: 3

 

Shirts

-Small

Qt: 3

 

What code would I have to add to the file for the infoboxes so that it defines it like this in the infobox:

 

3 x Shirts

-Large

 

3 x Shirts

- Small

 

It think it is as simple as putting in (define) and telling it to show the attributes selcted, but I have no clue on what to do. Can someone please help me with this? Thanks

By the way osC v2.3


My Installed Contributions:

1. Ultimate SEO URLs V 2-2.2d-X

2. Quantity Box on Product Info Page

3. httpbl4osc Version 1.1.0

4. QTpro for osc 2.3

5. Header Tags SEO V 3.0 (For 2.3)

6. DHTML State Selection for 2.3.1

And Good To Know:

I use a 960gs fluid style sheet.

I do have a honey pot on my website.

Store Version: 2.3

 

“Pain is temporary. Quitting lasts forever."

- Lance Armstrong

Share this post


Link to post
Share on other sites

Copy the relevant code from the cart page to the infobox module.

 

Thanks that will work, but I am clueless. I hope I am not asking to much but can someone show me what to take and where to put it?

 

The important part of the shopping cart file:

 

<div class="contentText">

<?php
   $any_out_of_stock = 0;
   $products = $cart->get_products();
   for ($i=0, $n=sizeof($products); $i<$n; $i++) {
// Push all attributes information in an array
     if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
       while (list($option, $value) = each($products[$i]['attributes'])) {
         echo tep_draw_hidden_field('id[' . $products[$i]['id'] . '][' . $option . ']', $value);
         $attributes = tep_db_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)$languages_id . "'
                                      and poval.language_id = '" . (int)$languages_id . "'");
         $attributes_values = tep_db_fetch_array($attributes);

         $products[$i][$option]['products_options_name'] = $attributes_values['products_options_name'];
         $products[$i][$option]['options_values_id'] = $value;
         $products[$i][$option]['products_options_values_name'] = $attributes_values['products_options_values_name'];
         $products[$i][$option]['options_values_price'] = $attributes_values['options_values_price'];
         $products[$i][$option]['price_prefix'] = $attributes_values['price_prefix'];
       }
     }
   }
?>

   <table border="0" width="100%" cellspacing="0" cellpadding="0">

<?php

   for ($i=0, $n=sizeof($products); $i<$n; $i++) {
     echo '      <tr>';

     $products_name = '<table border="0" cellspacing="2" cellpadding="2">' .
                      '  <tr>' .
                      '    <td align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">' . tep_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>' .
                      '    <td valign="top"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '"><strong>' . $products[$i]['name'] . '</strong></a>';

     if (STOCK_CHECK == 'true') {
       $stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity']);
       if (tep_not_null($stock_check)) {
         $any_out_of_stock = 1;

         $products_name .= $stock_check;
       }
     }

     if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
       reset($products[$i]['attributes']);
       while (list($option, $value) = each($products[$i]['attributes'])) {
         $products_name .= '<br /><small><i> - ' . $products[$i][$option]['products_options_name'] . ' ' . $products[$i][$option]['products_options_values_name'] . '</i></small>';
       }
     }

     $products_name .= '<br /><br />' . tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4"') . tep_draw_hidden_field('products_id[]', $products[$i]['id']) . tep_draw_button(IMAGE_BUTTON_UPDATE, 'refresh') . '   or <a href="' . tep_href_link(FILENAME_SHOPPING_CART, 'products_id=' . $products[$i]['id'] . '&action=remove_product') . '">remove</a>';

     $products_name .= '    </td>' .
                       '  </tr>' .
                       '</table>';

     echo '        <td valign="top">' . $products_name . '</td>' .
          '        <td align="right" valign="top"><strong>' . $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</strong></td>' .
          '      </tr>';
   }
?>

   </table>

 

The important part of the infobox file:

 

function execute() {
     global $cart, $new_products_id_in_cart, $currencies, $oscTemplate;

     $cart_contents_string = '';

     if ($cart->count_contents() > 0) {
       $cart_contents_string = '<table border="0" width="100%" cellspacing="0" cellpadding="0" class="ui-widget-content infoBoxContents">';
       $products = $cart->get_products();
       for ($i=0, $n=sizeof($products); $i<$n; $i++) {
         $cart_contents_string .= '<tr><td align="right" valign="top">';

         if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {
           $cart_contents_string .= '<span class="newItemInCart">';
         }

         $cart_contents_string .= $products[$i]['quantity'] . ' x ';

         if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {
           $cart_contents_string .= '</span>';
         }

         $cart_contents_string .= '</td><td valign="top"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">';

         if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {
           $cart_contents_string .= '<span class="newItemInCart">';
         }

         $cart_contents_string .= $products[$i]['name'];

         if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {
           $cart_contents_string .= '</span>';
         }

         $cart_contents_string .= '</a></td></tr>';

         if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {
           tep_session_unregister('new_products_id_in_cart');
         }
       }

       $cart_contents_string .= '<tr><td colspan="2" style="padding-top: 5px; padding-bottom: 2px;">' . tep_draw_separator() . '</td></tr>' .
                                '<tr><td colspan="2" align="right">' . $currencies->format($cart->show_total()) . '</td></tr>' .
                                '</table>';
     } else {
       $cart_contents_string .= '<div class="ui-widget-content infoBoxContents">' . MODULE_BOXES_SHOPPING_CART_BOX_CART_EMPTY . '</div>';
     }

     $data = '<div class="ui-widget infoBoxContainer">' .
             '  <div class="ui-widget-header infoBoxHeading"><a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '">' . MODULE_BOXES_SHOPPING_CART_BOX_TITLE . '</a></div>' .
             '  ' . $cart_contents_string .
             '</div>';


My Installed Contributions:

1. Ultimate SEO URLs V 2-2.2d-X

2. Quantity Box on Product Info Page

3. httpbl4osc Version 1.1.0

4. QTpro for osc 2.3

5. Header Tags SEO V 3.0 (For 2.3)

6. DHTML State Selection for 2.3.1

And Good To Know:

I use a 960gs fluid style sheet.

I do have a honey pot on my website.

Store Version: 2.3

 

“Pain is temporary. Quitting lasts forever."

- Lance Armstrong

Share this post


Link to post
Share on other sites

Copy the relevant code from the cart page to the infobox module.

 

I tried that and it is not that simple. I started editing and playing around with the code to try to get it to work but this is all I have so far. (see below code) (Only the "important part" of the infobox file is shown.)

 

With this code the infobox still works and all that shows up is this:

 

1 x NASA T- Shirt

-

(This above line is visualy formated like it is in the cart, but that "-" is all that shows up. (The code for that is below.)

 

Can anyone help?

 

         if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {
           $cart_contents_string .= '<span class="newItemInCart">';
         }

         $cart_contents_string .= $products[$i]['quantity'] . ' x ';

         if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {
           $cart_contents_string .= '</span>';
         }

         $cart_contents_string .= '</td><td valign="top"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">';

         if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {
           $cart_contents_string .= '<span class="newItemInCart">';
         }

         $cart_contents_string .= $products[$i]['name'];

         if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {
           $cart_contents_string .= '</span>';
         }

         $cart_contents_string .= '</a>';

 if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {
           $cart_contents_string .= '<span class="newItemInCart"><br /><small><i> - ';
         }

         $cart_contents_string .= $products[$i][$option]['products_options_name'] . ' ' . $products[$i][$option]['products_options_values_name'];

if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {
           $cart_contents_string .= '</i></small></span>';
         }

         $cart_contents_string .= '</td></tr>';



         if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {
           tep_session_unregister('new_products_id_in_cart');
         }
       }


My Installed Contributions:

1. Ultimate SEO URLs V 2-2.2d-X

2. Quantity Box on Product Info Page

3. httpbl4osc Version 1.1.0

4. QTpro for osc 2.3

5. Header Tags SEO V 3.0 (For 2.3)

6. DHTML State Selection for 2.3.1

And Good To Know:

I use a 960gs fluid style sheet.

I do have a honey pot on my website.

Store Version: 2.3

 

“Pain is temporary. Quitting lasts forever."

- Lance Armstrong

Share this post


Link to post
Share on other sites

Can someone please help me with this. I do not know if it is just a coding error or not.

 

This is the code that is currently there and causes the cart to show like this:

 

1 x NASA T- Shirt

-

-

 

It lists the correct amount of attributes, but it just won't show them.

 


   function execute() {
     global $cart, $new_products_id_in_cart, $currencies, $oscTemplate;

     $cart_contents_string = '';

     if ($cart->count_contents() > 0) {
       $cart_contents_string = '<table border="0" width="100%" cellspacing="0" cellpadding="0" class="ui-widget-content infoBoxContents">';
       $products = $cart->get_products();
       for ($i=0, $n=sizeof($products); $i<$n; $i++) {



          $cart_contents_string .= '<tr><td align="right" valign="top">';


         $cart_contents_string .= $products[$i]['quantity'] . ' x ';


         $cart_contents_string .= '</td><td valign="top"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">';


         $cart_contents_string .= $products[$i]['name'];


         $cart_contents_string .= '</a>';


   if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
       reset($products[$i]['attributes']);
       while (list($option, $value) = each($products[$i]['attributes'])) {
   $cart_contents_string .= '<br /><small><i> - ' . $products[$i][$option]['products_options_name'] . ' ' . $products[$i][$option]['products_options_values_name'] . ' </i></small>';
        }
         }   

         $cart_contents_string .= '</td></tr>';


         if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {
           tep_session_unregister('new_products_id_in_cart');
         }
       }

       $cart_contents_string .= '<tr><td colspan="2" style="padding-top: 5px; padding-bottom: 2px;">' . tep_draw_separator() . '</td></tr>' .
                                '<tr><td colspan="2" align="right">' . $currencies->format($cart->show_total()) . '</td></tr>' .
                                '</table>';
     } else {
       $cart_contents_string .= '<div class="ui-widget-content infoBoxContents">' . MODULE_BOXES_SHOPPING_CART_BOX_CART_EMPTY . '</div>';
     }

     $data = '<div class="ui-widget infoBoxContainer">' .
             '  <div class="ui-widget-header infoBoxHeading"><a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '">' . MODULE_BOXES_SHOPPING_CART_BOX_TITLE . '</a></div>' .
             '  ' . $cart_contents_string .
             '</div>';

     $oscTemplate->addBlock($data, $this->group);
   }

 

- Luc


My Installed Contributions:

1. Ultimate SEO URLs V 2-2.2d-X

2. Quantity Box on Product Info Page

3. httpbl4osc Version 1.1.0

4. QTpro for osc 2.3

5. Header Tags SEO V 3.0 (For 2.3)

6. DHTML State Selection for 2.3.1

And Good To Know:

I use a 960gs fluid style sheet.

I do have a honey pot on my website.

Store Version: 2.3

 

“Pain is temporary. Quitting lasts forever."

- Lance Armstrong

Share this post


Link to post
Share on other sites

×