Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

From Product to Cart : options not showing


patator

Recommended Posts

Hello

 

Here is my problem, to populate/repopulate the attributes drop down list in the product_info.php, I either use the tep_draw_pull_down_menu or a javascript function. When the attributes list are populated from the tep_draw_pull_down_menu, the attributes will show in the cart.

If I populate the attributes using the javascript and add the product to the cart, the attributes won't show in the cart.

 

Could somebody tell me how the attributes are sent from the product_info to the cart : hidden fields ? how to fill them?

 

 

Options populated with tep_draw_pull_menu

Options populated from js and not showing in the cart

 

 

Please, give me some clue on what to work on.....

Thanks for reading this post

Patrice :'(

PS : sorry for reposting the question, but I'm really stuck and I'm desperate for little help :(

Link to comment
Share on other sites

Sorry to bump again but could somebody help me ?

Is it my question too specific or not clear enough ?

I just would like to know how to populate the attribute array which is sent to the cart, without using the tep_draw_pull_down_menu ?

 

Thanks

Patfullydesperateforanswers

:(

 

Hello

 

Here is my problem, to populate/repopulate the attributes drop down list in the product_info.php, I either use the tep_draw_pull_down_menu or a javascript function. When the attributes list are populated from the tep_draw_pull_down_menu, the attributes will show in the cart.

If I populate the attributes using the javascript and add the product to the cart, the attributes won't show in the cart.

 

Could somebody tell me how  the attributes are sent from the product_info to the cart : hidden fields ? how to fill them?

Options  populated with tep_draw_pull_menu

Options populated from js and not showing in the cart

Please, give me some clue on what to work on.....

Thanks for reading this post

Patrice :'(

PS : sorry for reposting the question, but I'm really stuck and I'm desperate for little help :(

Link to comment
Share on other sites

Hi Peter,

Yes they are showing (on my screen at list, ie6). What browser do you use ?

If I select Right hand, I can access to the different lofts. When I select the loft and add the product to the cart, the cart doesn't show the selected attribute.

Are you sure you can't access to the attributes after selecting either RH o LH ? (no offence.... :-" )

 

Thanks

Pat

 

Hi,

 

The product attributes aren't showing here though:

 

http://www.clubfitting.net/snake-eyes-quick-strike-p-97.html

 

and that is before the 'add to cart'.

 

Peter

Link to comment
Share on other sites

Hi,

 

Yes they are showing (on my screen at list, ie6). What browser do you use ?

 

Mozilla 1.7.5, one of the latest versions of Mozilla, and of course the same would happen in Netscape also I would say. The source code generated is:

 

<tr>
           <td class="product_info_attributs" valign="middle" >Hand</td>
	 <td class="product_info_attributs" valign="middle" align="right">
                       <select id=id[24] name="SelType" onChange="getFaceAngleList(this.value)">      </select></td></tr>

 

... no options between the "<select>....</select" tags.

 

If I select Right hand, I can access to the different lofts. When I select the loft and add the product to the cart, the cart doesn't show the selected attribute.

Are you sure you can't access to the attributes after selecting either RH o LH ? (no offence.... :-" )

 

Well, I could be dreaming, ... hang on, I'll pinch myself, ...ouch, ...no I'm not dreaming and there are no options showing. I ran the JS console, and this was the message:

 

Error: frm has no properties

Source File: http://www.clubfitting.net/snake-eyes-quick-strike-p-97.html

Line: 42

 

Peter

Link to comment
Share on other sites

Should be working now my dear !

I installed Mozilla and figured our what was the problem : the form generated by tep_draw_form had a name but no ID and because the JS function is using the getdocumentbyid function, it was not working...I don't know why it was working in ie, though.....Microsoft !

 

Pichyourselfagainafterme

:P

 

Hi,

Mozilla 1.7.5, one of the latest versions of Mozilla, and of course the same would happen in Netscape also I would say. The source code generated is:

 

<tr>
? ? ? ? ? ?<td class="product_info_attributs" valign="middle" >Hand</td>
?	<td class="product_info_attributs" valign="middle" align="right">
? ? ? ? ? ? ? ? ? ? ? ?<select id=id[24] name="SelType" onChange="getFaceAngleList(this.value)"> ? ? ?</select></td></tr>

 

... no options between the "<select>....</select" tags.

Well, I could be dreaming, ... hang on, I'll pinch myself, ...ouch, ...no I'm not dreaming and there are no options showing. I ran the JS console, and this was the message:

Peter

Link to comment
Share on other sites

Hi,

 

Should be working now my dear !

I installed Mozilla and figured our what was the problem : the form generated by tep_draw_form had a name but no ID and because the JS function is using the getdocumentbyid function, it was not working...I don't know why it was working in ie, though.....Microsoft !

 

Pichyourselfagainafterme

:P

 

Yes, the 'id' is important, and actually a web standard, but then M$ don't follow the standards. :lol:

 

It's working fine in Mozilla, right hand - 5 options and left hand - 3 options. What you could do when people try and add it to the cart, is see if the second dropdown value selected is 'empty', which means they have left the first option as "--SELECT --" , and then if it is empty, don't let them add it to the cart (go back).

 

Peter

Link to comment
Share on other sites

Peter,

 

That will be my next issue, I think I already found a script to do that.

As you understand, my BIG problem now is when I add a product to the cart, it does'nt show the attributes selected from the pulldown menu generated by the javascript.

I don't knwo what to do. :'(

Pat

 

Hi,

Yes, the 'id' is important, and actually a web standard, but then M$ don't follow the standards.    :lol:

 

It's working fine in Mozilla, right hand - 5 options and left hand - 3 options. What you could do when people try and add it to the cart, is see if the second dropdown value selected is 'empty', which means they have left the first option as "--SELECT --" , and then if it is empty, don't let them add it to the cart (go back).

 

Peter

Link to comment
Share on other sites

Hi,

 

As you understand, my BIG problem now is when I add a product to the cart, it does'nt show the attributes selected from the pulldown menu generated by the javascript.

I don't knwo what to do. :'(

 

If you follow the 'model' of how other fields are added to the cart, like form 'cart_quantity', the field products_id has a value of 97.

 

Peter

Link to comment
Share on other sites

If I take the example of an attribute wich appears in the cart (ie : shaft rigidity), I can see :

<td class="productListing-data"><table border="0" cellspacing="2" cellpadding="2">  <tr>    <td class="productListing-data" align="center"><a href="http://www.clubfitting.net/product_info.php?products_id=81{18}16">

18 is the option rigidity

16 is the attribute stiff

Graphite shafts with attribute appearing in the cart

 

I can't figure out how to send the attribute id to the cart (hidden fields, function..... ?), when :

the option for hand selection would be : 24

the attribute for the RH/LH would be : 44/45

 

the option for the loft would be :6

the attribute for the loft could be 42,74,75,76,77,78....

 

This options are not populated in the combobox thanks to the tep_draw_pull_down_menu but from the javascript, this is why I think the attributes are not added to the cart

 

Pat

Link to comment
Share on other sites

Hi,

 

If I take the example of an attribute wich appears in the cart (ie : shaft rigidity), I can see :

<td class="productListing-data"><table border="0" cellspacing="2" cellpadding="2">  <tr>    <td class="productListing-data" align="center"><a href="http://www.clubfitting.net/product_info.php?products_id=81{18}16">

18 is the option rigidity

16 is the attribute stiff

Graphite shafts with attribute appearing in the cart

 

I can't figure out how to send the attribute id to the cart (hidden fields, function..... ?), when :

the option for hand selection would be : 24

the attribute for the RH/LH would be : 44/45

 

the option for the loft would be :6

the attribute for the loft could be 42,74,75,76,77,78....

 

This options are not populated in the combobox thanks to the tep_draw_pull_down_menu but from the javascript, this is why I think the attributes are not added to the cart

 

Pat

 

You can only send what is in the form, that is the value of each field. The example given, you can send (field name) id[18] and a value of 16. If you need to send other values to the cart, either add more hidden fields, or do some sql in the 'add cart' to find out more information on the actual attribute options.

 

Peter

Link to comment
Share on other sites

You've got it Pete !

but the question is where and how, I'm not as good at php as you are...

do you have a clue on how to do it ?

(how are added the attribute hidden field in the product_info.php file ?)

 

I'm sure we'll find a solution

Pat

If you need to send other values to the cart, either add more hidden fields, or do some sql in the 'add cart' to find out more information on the actual attribute options.

Link to comment
Share on other sites

Hi,

 

but the question is where and how, I'm not as good at php as you are...

 

Yeh, but I'm not good at anything. :lol:

 

do you have a clue on how to do it ?

(how are added the attribute hidden field in the product_info.php file ?)

 

Well, it makes a bit hard because the site must use some URL re-writing, to rewrite PHP files to 'somefilename.html' (personally, doing that is not necessary, as some would have us believe, .... anyway off-topic a bit), but I have to assume when you "add to cart" that it is like (normal) osCommerce, it submits product_info.php

 

Now, for the fields that are passed ..............

 

'products_id' is evaluated like ...... $HTTP_GET_VARS['products_id']

 

and you will notice in any sql queries , it is (int)$HTTP_GET_VARS['products_id']

 

so, if you have a hidden field called 'flex' , then the code in product_info.php would be:

 

$flex = $HTTP_GET_VARS['flex'];

 

(You will have to change your hidden field names (like id[18] ) to a common name like 'flex' or 'product_option1' or something, so that product_info.php will always be able to evaluate it.)

 

Your product_info.php will be modified no doubt, but lines 122 to 123 are

 

$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);

 

so the array '$products_attributes' would be where all the attributes are for _that_ product. Match the attribute value retrieved from the form submission, to the value found in the array (if you don't find it, something is amiss).

 

Hope that gets you started,

 

Peter

Link to comment
Share on other sites

Hello

 

I'm must be stupid. Despite your big support Peter, I can't make it work.....I tried different things but no chance.

Could you (or somebody who reads this post) give a example (for instance the name of the field containing the loft attribute is SelLoft

 

Thanks..

Patrice :'( :'(

 

 

Hi,

Yeh, but I'm not good at anything.    :lol:

Well, it makes a bit hard because the site must use some URL re-writing, to rewrite PHP files to 'somefilename.html'  (personally, doing that is not necessary, as some would have us believe, .... anyway off-topic a bit), but I have to assume when you "add to cart" that it is like (normal) osCommerce, it submits product_info.php

 

Now, for the fields that are passed ..............

 

'products_id' is evaluated like ......  $HTTP_GET_VARS['products_id']

 

and you will notice in any sql queries , it is (int)$HTTP_GET_VARS['products_id']

 

so, if you have a hidden field called 'flex' , then the code in product_info.php would be:

 

$flex = $HTTP_GET_VARS['flex'];

 

(You will have to change your hidden field names (like id[18] ) to a common name like 'flex' or 'product_option1' or something, so that product_info.php will always be able to evaluate it.)

 

Your product_info.php will be modified no doubt, but lines 122 to 123 are

 

$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);

 

so the array '$products_attributes' would be where all the attributes are for _that_ product. Match the attribute value retrieved from the form submission, to the value found in the array (if you don't find it, something is amiss).

 

Hope that gets you started,

 

Peter

Link to comment
Share on other sites

If I take the example of an attribute wich appears in the cart (ie : shaft rigidity), I can see :

<td class="productListing-data"><table border="0" cellspacing="2" cellpadding="2"> ?<tr> ? ?<td class="productListing-data" align="center"><a href="http://www.clubfitting.net/product_info.php?products_id=81{18}16">

18 is the option rigidity

16 is the attribute stiff

Graphite shafts with attribute appearing in the cart

 

I can't figure out how to send the attribute id to the cart (hidden fields, function..... ?), when :

the option for hand selection would be : 24

the attribute for the RH/LH would be : 44/45

 

the option for the loft would be :6

the attribute for the loft could be 42,74,75,76,77,78....

 

This options are not populated in the combobox thanks to the tep_draw_pull_down_menu but from the javascript, this is why I think the attributes are not added to the cart

 

Pat

 

You need to pass the option ids (i.e. 24 for hand selection and 44 for right-handed) from the javascript into your form fields. To start, where you have name="SelHand" in your form, that's where it needs to be ID[24]. Then, when you pass the loft degrees, you also need the option attribute for them, from the js array. I didn't disect all the js there, there's a lot of it, but that's where I would start looking, try to pass the right info from the js into the form.

 

My working example without js for 2 options looks like this in html:

 

<td class="main" colspan="2">Available Options:</td>
           </tr>
           <tr>
             <td class="main">First Color:</td>
             <td class="main"><select name="id[1]"><option value="15">Ice Blue</option><option value="14">Peacock Blue</option><option value="16">Orchid</option></select></td>
           </tr>
           <tr>
             <td class="main">Second Color:</td>
             <td class="main"><select name="id[6]"><option value="20">--none--</option><option value="16">Orchid</option><option value="15">Ice Blue</option><option value="14">Peacock Blue</option></select></td>

 

Where 1 is the attribute for the option "first color" and 6 for "second color", and the colors attributes are 15,16, and 17.

 

Hope that points you in the right direction.

Link to comment
Share on other sites

Ok, I think I got the js sorted out here:

<script language="JavaScript">
<!--  hide from older browsers
function FaceAngle(RH,LH,Angle)
{this.RH = RH;
this.LH = LH;
this.Angle = Angle;
this.Attribute = Attribute;
}

var FaceAngleList = new Array();
FaceAngleList[0] = new FaceAngle ('44','45','14?','42')
FaceAngleList[1] = new FaceAngle ('44','45','18?','74')
FaceAngleList[2] = new FaceAngle ('44','45','22?','75')
FaceAngleList[3] = new FaceAngle ('44','NO_LEFT','26?','76')
FaceAngleList[4] = new FaceAngle ('44','NO_LEFT','30?','77')
function showInfo(x)
{
document.getElementById('id6').value=x;
}

function getHands(frm)
{
frm.id24.options[frm.id24.options.length] = new Option('--SELECT--', 'Selection');
frm.id24.options[frm.id24.options.length] = new Option('RIGHT HAND', '44');
frm.id24.options[frm.id24.options.length] = new Option('LEFT HAND', '45');
}

function getFaceAngleList(Hand)
{
document.getElementById('id24').value=Hand;
var current = (frm.id6.value) ? FaceAngleList[frm.id6.value].name : '';
for(i = frm.id6.length - 1; i >= 0; i--)
{
frm.id6.options[i] = null;
}
for(i = 0; i < FaceAngleList.length; i++)
{
var Face = FaceAngleList[i];
 if(Face.RH == Hand || Face.LH == Hand)
{
frm.id6.options[frm.id6.options.length] = new Option(Face.Angle, Face.Attribute, (Face.Angle==current), (Face.Angle==current));
}
}
}


 var frm = null;
     function init()
     {
       frm = document.getElementById('cart_quantity');
       getHands(frm);
       getFaceAngleList(frm.id24.value);
     }
// -->
 </script>

 

There are a lot of changes; just watch that the option and attribute id's are correct for your product database.

 

The select statements will look like:

 <select id="id24" name="id[24]" onChange="getFaceAngleList(this.value)"></select>

and

<select id="id6" name="id[6]" onChange="showInfo(this.value)"></select>

 

This worked in my testing, and is much cleaner, I think, than trying to pass hidden fields (not to mention easier to adapt to new products!).

Link to comment
Share on other sites

Opps, missed a change:

 

function FaceAngle(RH,LH,Angle)
{this.RH = RH;
this.LH = LH;
this.Angle = Angle;
this.Attribute = Attribute;
}

should actually be:

 

function FaceAngle(RH,LH,Angle,Attribute)
{this.RH = RH;
this.LH = LH;
this.Angle = Angle;
this.Attribute = Attribute;
}

Link to comment
Share on other sites

At the time you were sending me the post, a friend of mine gave me a hand and fixed the problem exactly in the same way than you did....

 

 

THANKKKKSSS a lot to Peter and yourself for your help and your support.....

 

Thanks a lot

Patrice :D

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...