Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Help with diplaying quantity for attributes (QTpro)


ricroma

Recommended Posts

Hi,

 

sorry to bother, but I would like some help. I'm not an expert so sorry if I won't be too much precise.

Well, after a long struggle I've came up with the e-store for my business: http://store.koti.it/catalog

The most is done, but I still need some tuning. This one in particular:

 

I've implemented the QTpro module that allow me to set a quantity to each attributes of a product. Here it is an example.

Now, what I what to do is to show the quantity available for each attribute INSIDE the drop down menu, rather than in the table underneath.

 

Something like: Color: pink (3 pcs) .

 

I've tried to mess around with the php files provided in the module, but my results were ridiculous.

I think I've detected the code lines that generates the drop down menu:

 

$out.='<p><strong style="margin-right: 10px">'.$attributes[$o]['oname'].":</strong>".tep_draw_pull_down_menu('id['.$attributes[$o]['oid'].']',array_values($attributes[$o]['ovals']),$attributes[$o]['default'], "onchange="stkmsg(this.form);"")."</p>n";

 

With some few extra strokes is it possible to implement the attribute quantity in the drop down menu?

 

Can anyone help?

 

My final objective is to add also a form field where the costumer could enter a desired quantity to order. But to do so, they should first of all now how many items are available.

 

Hope you can help, thanks a lot in advance!

 

Ricroma

 

EDIT: down here I attach all the code of the file:

 

<?php
/*
  QT Pro Version 4.1

  pad_multiple_dropdowns.php

  Contribution extension to:
	osCommerce, Open Source E-Commerce Solutions
	http://www.oscommerce.com

  Copyright (c) 2004, 2005 Ralph Day
  Released under the GNU General Public License

  Based on prior works released under the GNU General Public License:
	QT Pro prior versions
	  Ralph Day, October 2004
	  Tom Wojcik aka TomThumb 2004/07/03 based on work by Michael Coffman aka coffman
	  FREEZEHELL - 08/11/2003 [email protected] Copyright (c) 2003 IBWO
	  Joseph Shain, January 2003
	osCommerce MS2
	  Copyright (c) 2003 osCommerce

  Modifications made:
	  11/2004 - Created
	  12/2004 - Fix _draw_out_of_stock_message_js to add semicolon to end of js stock array
	  03/2005 - Remove '&' for pass by reference from parameters to call of
				_build_attributes_combinations.  Only needed on method definition and causes
				error messages on some php versions/configurations

*******************************************************************************************

  QT Pro Product Attributes Display Plugin

  pad_multiple_dropdowns.php - Display stocked product attributes first as one dropdown for each attribute.

  Class Name: pad_multiple_dropdowns

  This class generates the HTML to display product attributes.  First, product attributes that
  stock is tracked for are displayed, each attribute in its own dropdown list.  Then attributes that
  stock is not tracked for are displayed, each attribute in its own dropdown list.

  Methods overidden or added:

	_draw_stocked_attributes			draw attributes that stock is tracked for
	_draw_out_of_stock_message_js	   draw Javascript to display out of stock message for out of
										stock attribute combinations
*/
 require_once(DIR_WS_CLASSES . 'pad_base.php');
 class pad_multiple_dropdowns extends pad_base {

/*
Method: _draw_stocked_attributes

draw dropdown lists for attributes that stock is tracked for

Parameters:

  none

Returns:

  string:		 HTML to display dropdown lists for attributes that stock is tracked for

*/
function _draw_stocked_attributes() {
  global $languages_id;

  $out='';

  $attributes = $this->_build_attributes_array(true, false);
  if (sizeof($attributes)>0) {
	for($o=0; $o<sizeof($attributes); $o++) {
	  $s=sizeof($attributes[$o]['ovals']);
	  for ($a=0; $a<$s; $a++) {
		$attribute_stock_query = tep_db_query("select products_stock_quantity from " . TABLE_PRODUCTS_STOCK . " where products_id = '" . (int)$this->products_id . "' AND products_stock_attributes REGEXP '(^|,)" . (int)$attributes[$o]['oid'] . "-" . (int)$attributes[$o]['ovals'][$a]['id'] . "(,|$)' AND products_stock_quantity > 0");
		$out_of_stock=(tep_db_num_rows($attribute_stock_query)==0);
		if ($out_of_stock && ($this->show_out_of_stock == 'True')) {
		  switch ($this->mark_out_of_stock) {
			case 'Left':   $attributes[$o]['ovals'][$a]['text']=TEXT_OUT_OF_STOCK.' - '.$attributes[$o]['ovals'][$a]['text'];
						   break;
			case 'Right':  $attributes[$o]['ovals'][$a]['text'].=' - '.TEXT_OUT_OF_STOCK;
						   break;
		  }
		}
		elseif ($out_of_stock && ($this->show_out_of_stock != 'True')) {
		  unset($attributes[$o]['ovals'][$a]);
		}
	  }
	  $out.='<p><strong style="margin-right: 10px">'.$attributes[$o]['oname'].":</strong>".tep_draw_pull_down_menu('id['.$attributes[$o]['oid'].']',array_values($attributes[$o]['ovals']),$attributes[$o]['default'], "onchange="stkmsg(this.form);"")."</p>n";
	}	  
	$out.=$this->_draw_out_of_stock_message_js($attributes);

	return $out;
  }
}
?>

Edited by ricroma
Link to comment
Share on other sites

Hi Riccardo

 

Sorry I can’t help you with your problem, but when I test your site there is a problem when add 1, 2 shows in the cart when adding 2 psc 3 are showing in your cart.

 

Actually my need for my site is to make a list like yours how did you make that? Is that from the Qtpro?

What I need is instead of quantity in stock of each attributes, than I need a box where quantity per attributes can be added (so the customer can order 3 red 2 yellow 5 green)

Link to comment
Share on other sites

Hi,

sorry for answering late, been busy.

What do you mean exactly by "make a list like yours"?

If you mean the table after the drop down menu, that is an option of the QTpro module, you just need to enable it from the admin panel. I'm really not an expert, so someone else can be more precise.

As far as the problem with quantity added in the cart it has been fixed.

 

Thanks for the reply, anyway!

 

Ricroma

Link to comment
Share on other sites

Hi Ricroma,

 

Thanks for your respond.

Yes that is the table I was thinking about.

I now find a contribution that makes all the listing and adding of each attributes, but now need the grid for listing it nice like yours.

Link to comment
Share on other sites

Hi again,

 

well... I repeat I'm no expert so I cannot help you in implementing new stuff into the code. What I can do is telling you what I did in order to have the result you see.

 

0) BACKUP!

 

1) installed QTpro contribution. For newbie like I am it may look difficult (and I was really scare to screw things up), but once instructions are strictly followed, the module works great.

 

2) In the Oscommerce Admin Panel -> Configuration -> Prod Info (QTPro) you can find different options to set up the module for your website. Among them you will also find: "Display table with stock information", once you set this to "true" you will have your table in the product_info page.

 

If you're asking me how to implement the table into the other contribution you've found, I cannot answer, because I have no idea!

 

In your previous post your said:

What I need is instead of quantity in stock of each attributes, than I need a box where quantity per attributes can be added (so the customer can order 3 red 2 yellow 5 green)

 

That's all I can tell you right now...

 

Ciao!

Edited by Mark Evans
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...