Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Only selected options in cart?


Wendy James

Recommended Posts

Hi All

 

I have been trying to figure this out and searched to see if anyone else posted about it but can not find an answer or suggestion.

 

I have a cart where they only want the selected options of a product to show on the shopping cart page.

I am stumped on how to do it. I can get no options to show up which really isn't umm good : ) But can't sort out how to have only the selected ones to show.

 

Not sure if it would make any difference or not but I have QT Pro installed.

 

Any ideas or suggestions?

Thanks!

Wendy

Wendy James

 

Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.

Link to comment
Share on other sites

I cant imagine that the shopping cart is much different for QTpro.

 

In shopping_cart.php find:

 

'	<td class="productListing-data" valign="top"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '"><b>' . $products[$i]['name'] . '</b></a>';

 

Change it to:

 

'	<td class="productListing-data" valign="top"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '"><b>';

 

then find:

 

$products_name .= '<br><small><i> - ' . $products[$i][$option]['products_options_name'] . ' ' . $products[$i][$option]['products_options_values_name'] . '</i></small>';

 

and change it to:

 

$products_name .= '<br>' . $products[$i][$option]['products_options_name'] . ' ' . $products[$i][$option]['products_options_values_name'];

 

then find:

 

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

 

and change it to:

 

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

 

:*

 

Sonia

Link to comment
Share on other sites

It does NOT display the product name (try again)

 

Yes, it makes the options bold and link to the product - you can remove the link... and also the bold ;)

 

 

Sonia

Link to comment
Share on other sites

Well as much as I appreciate you trying to help, I think you missunderstood my post. The product name isn't the issue. That has to stay there.

 

He has items in his store with multible attributes. The store is adding 1 Option for each Attribute even if not selected.

 

So let's say he has 4 attributes. left 1st #, left 2nd #, right 1st # and right 2nd #

 

If someone is only selecting the left 2nd number then he does not want the "please select" attribute from appearing on the shopping cart page.

 

As it is now, for example, if only choosing the left 2nd # the cart shows

Product Name

- First Left Sleeve Number Please Select

- Second Left Sleeve Number 6

- First Right Sleeve Number Please Select

- Second Right Sleeve Number Please Select

 

I need to figure out how to have it so it just says

Product Name

- Second Left Sleeve Number 6

Wendy James

 

Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.

Link to comment
Share on other sites

Ahhh... I did misunderstand.... easy to do ;)

 

 

I think the problem is on product info - all the attributes are being posted and added to the cart, whether selected or not.

 

I am sure you will also wish to remove the 'please select' - you can do that in the cart with this:

 

 

str_replace('Please Select', '', $products[$i][$option]['products_options_name'])

 

You will probably wish to do the same at checkout.

 

 

Post the attributes section of product_info.php

 

 

 

Sonia

Link to comment
Share on other sites

This is the only code on the product info that has to do with attributes

 

//++++ QT Pro: End Changed Code

$products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'");

$products_attributes = tep_db_fetch_array($products_attributes_query);

if ($products_attributes['total'] > 0) {

//++++ QT Pro: Begin Changed code

$products_id=(preg_match("/^\d{1,10}(\{\d{1,10}\}\d{1,10})*$/",$HTTP_GET_VARS['products_id']) ? $HTTP_GET_VARS['products_id'] : (int)$HTTP_GET_VARS['products_id']);

require(DIR_WS_CLASSES . 'pad_' . PRODINFO_ATTRIBUTE_PLUGIN . '.php');

$class = 'pad_' . PRODINFO_ATTRIBUTE_PLUGIN;

$pad = new $class($products_id);

echo $pad->draw();

//++++ QT Pro: End Changed Code

 

but there are several files for QT Pro. I believe the code I need to find and work on is in the pad_base.php

 

This is the only code from there that handles the attributes, I think.

I am going to check the QT Pro thread to see if anyone has alread tried this.

 

 

function _build_attributes_array($build_stocked, $build_nonstocked) {

global $languages_id;

global $currencies;

global $cart;

 

if (!($build_stocked | $build_nonstocked)) return null;

 

if ($build_stocked && $build_nonstocked) {

$stocked_where='';

}

elseif ($build_stocked) {

$stocked_where="and popt.products_options_track_stock = '1'";

}

elseif ($build_nonstocked) {

$stocked_where="and popt.products_options_track_stock = '0'";

}

 

$products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name, popt.products_options_comment, popt.products_options_link, popt.products_options_track_stock from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$this->products_id . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' " . $stocked_where . " order by popt.products_options_id");

$attributes=array();

while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {

$products_options_array = array();

$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$this->products_id . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'");

while ($products_options = tep_db_fetch_array($products_options_query)) {

$products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']);

if ($products_options['options_values_price'] != '0') {

$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($this->products_tax_class_id)) .')';

}

}

if ( $products_options_name['products_options_link'] != "" ) {

$link = DIR_WS_DETAILS . $products_options_name['products_options_link'];

if ( $products_options_name['products_options_comment'] != "" ) {

echo '• <a href="java script:popupDetailsWindow(\'' . tep_href_link($link) . '\')" class="popup">' . $products_options_name['products_options_comment'] . '</a><br>';

} else {

echo '<a href="java script:popupDetailsWindow(\'' . tep_href_link($link) . '\')" class="popup">' . TEXT_DEFAULT_OPTION_LINK_TEXT . '</a>';

}

} else {

if ( $products_options_name['products_options_comment'] != "" ) {

echo $products_options_name['products_options_comment'];

}

}

if (isset($cart->contents[$this->products_id]['attributes'][$products_options_name['products_options_id']]))

$selected = $cart->contents[$this->products_id]['attributes'][$products_options_name['products_options_id']];

else

$selected = 0;

$attributes[]=array('oid'=>$products_options_name['products_options_id'],

'oname'=>$products_options_name['products_options_name'],

'ovals'=>$products_options_array,

'link'=>$products_options_name['products_options_link'],

'comment'=>$products_options_name['products_options_comment'],

'default'=>$selected);

}

return $attributes;

}

Wendy James

 

Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.

Link to comment
Share on other sites

You don't have to go through all of that. This guy shouldn't even be using QT Pro. It doesn't work for what he needs but someone else had made the site so I am dealing with messed up code and contributions that aren't needed and so on.

 

I think I am just going to suggest I start it off from scratch. Much less of a headache. Doubt he will go for it but worth a shot. : )

Wendy James

 

Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.

Link to comment
Share on other sites

Ok - this works, but will apply to ALL your attributes, so if you have a product where all attributes MUST be selected it will cause problems.

 

First the 'Please Select'. This should not be an attribute added in admin, but should go here:

 

In /includes/classes/pad_base.php find:

 

$products_options_array = array();

 

change it to:

 

$products_options_array = array(array('id' =>'0', 'text'=>'Please Select'));

 

then in /includes/classes/shopping_cart.php find:

 

				$this->contents[$products_id_string]['attributes'][$option] = $value;
// insert into database
			if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id_string) . "', '" . (int)$option . "', '" . (int)$value . "')");

 

change it to:

 

				  if ($value > 0) { 
			$this->contents[$products_id_string]['attributes'][$option] = $value;
// insert into database
			if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id_string) . "', '" . (int)$option . "', '" . (int)$value . "')");
		   }

 

Thats it. Note however that this allows the customer to add a product without any attributes selected. A further check can go into shopping_cart.php if needed :)

 

 

Sonia

Link to comment
Share on other sites

Thanks, I appreciate you doing that.

I'll tell him about the issue that may come up. He can get a coder (which I soooooooooooooooooo am not) to come up with something to work around that. I am so beyond sick of this site and will be glad when it's done.

Wendy James

 

Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...