Zen Cart Logo
Forums / Setting Up Categories, Products, Attributes / Dependant Attributes - Can I do this?

Dependant Attributes - Can I do this?

Locked

Views: 20,157

Results 41 to 60 of 65
This thread is locked. New replies are disabled.
4 May 2009, 8:43 PM
#41
suzr avatar

suzr

New Zenner

Join Date:
Apr 2009
Posts:
12
Plugin Contributions:
0

Dependant Attributes - Can I do this?

I'm experimenting with this right now, and it (sort of) works..

I see the selection boxes, the first one is fully populated, but the second one doesn't include all possible variants..

Right now I'm just a bit too tired of setting up everything that I can't really see straight and follow the code, so please give me some advice here..
:(

The generated selection box code on the page is this:

<!--bof Attributes Module -->
<div id="productAttributes">
  <table border="0" cellspacing="0" cellpadding="2">
    <tr>
      <td class="main" colspan="2"><b>Glöm inte att välja: </b></td>
    </tr>
    <tr>
      <td align="right" class="main"><b>Storlek:</b></td>
      <td class="main"><select name="id[1]" onchange="i1(this.form);">
          <option value="0" selected="selected">First select Storlek</option>
          <option value="1">8½</option>
          <option value="2">9</option>
          <option value="3">9½</option>
          <option value="4">10</option>
          <option value="5">10½</option>
          <option value="6">11</option>
        </select></td>
    </tr>
    <tr>
      <td align="right" class="main"><b>Färg:</b></td>
      <td class="main"><select name="id[2]">
          <option value="0" selected="selected">Next select Färg</option>
        </select></td>
    </tr>
    <tr>
      <td colspan="2"> 
        <script type="text/javascript" language="javascript"><!--
  var stk={1:{8:1,9:1,13:1},2:{8:1,9:1,13:1},3:{8:1,9:1,13:1},4:{8:1,9:1,13:1},5:{8:1,9:1,13:1},6:{8:1,9:1,13:1}};
  var txt2={8:'Svart ',9:'Barely black ',11:'Platina ',12:'Choklad ',13:'Brons '};
  function i1(frm) {
    frm['id[2]'].length=1;
    for (opt in stk[frm['id[1]'].value]) {
      frm['id[2]'].options[frm['id[2]'].length]=new Option(txt2[opt],opt);
    }
  }
  i1(document.cart_quantity);
  function chksel() {
    var ok=true;
    if (this['id[1]'].value==0) ok=false;
    if (this['id[2]'].value==0) ok=false;
    if (!ok) alert('Du måste välja vilken storlek, färg med mera du vill ha.');
    return ok;
  }
  document.cart_quantity.onsubmit=chksel;
//--></script></td>
    </tr>
  </table>
  <br class="clearBoth" />
</div>
<!--eof Attributes Module -->

But the database contains the proper values, and as far as I can see, quite some more options to choose from in the second selection box.

stock_id ; products_id ; stock_attributes ; quantity ;
1 ; 4 ; 1,7 ; 500000
2 ; 4 ; 2,7 ; 500000
3 ; 4 ; 3,7 ; 500000
4 ; 4 ; 4,7 ; 500000
5 ; 4 ; 5,7 ; 500000
6 ; 4 ; 6,7 ; 500000
7 ; 4 ; 1,8 ; 500000
8 ; 4 ; 2,8 ; 500000
9 ; 4 ; 3,8 ; 500000
10 ; 4 ; 4,8 ; 500000
11 ; 4 ; 5,8 ; 500000
12 ; 4 ; 6,8 ; 500000
13 ; 4 ; 11,1 ; 500000
14 ; 4 ; 11,2 ; 500000
15 ; 4 ; 11,3 ; 500000
16 ; 4 ; 11,4 ; 500000
17 ; 4 ; 11,5 ; 500000
18 ; 4 ; 11,6 ; 500000
19 ; 4 ; 10,1 ; 500000
20 ; 4 ; 10,2 ; 500000
21 ; 4 ; 10,3 ; 500000
22 ; 4 ; 10,4 ; 500000
23 ; 4 ; 10,5 ; 500000
24 ; 4 ; 10,6 ; 500000
25 ; 4 ; 1,9 ; 500000
26 ; 4 ; 2,9 ; 500000
27 ; 4 ; 3,9 ; 500000
28 ; 4 ; 4,9 ; 500000
29 ; 4 ; 5,9 ; 500000
30 ; 4 ; 6,9 ; 500000

:shocking:

5 May 2009, 6:38 AM
#42
suzr avatar

suzr

New Zenner

Join Date:
Apr 2009
Posts:
12
Plugin Contributions:
0

Re: Dependant Attributes - Can I do this?

I think I'm on to something...

In pad_multiple_dropdowns.php there's a query in the beginning that I understand is to get the combinations available, it reads:

$attribute_stock_query = $db->Execute("
SELECT quantity FROM products_with_attributes_stock AS a LEFT JOIN products_attributes AS b
ON (b.options_id=". (int)$attributes[$o]['oid'] ."
AND b.options_values_id=".(int)$attributes[$o]['ovals'][$a]['id'].")
WHERE a.products_id = '" . (int)$this->products_id . "'
AND a.stock_attributes = b.products_attributes_id
AND a.quantity > 0 order by b.products_options_sort_order
");

And I think the problem is in the 'a.stock_attributes = b.products_attributes_id' part..
a.stock_attributes is a comma delimited varchar field,
b.products_attributes_id is a integer field in the database.. It's like comparing apples to bananas.

Like in my case, the query tried to test if the integer 11 is equal to the string "11,6" - Which it can't be of course.

I need to dig more in this..

5 May 2009, 5:55 PM
#43
suzr avatar

suzr

New Zenner

Join Date:
Apr 2009
Posts:
12
Plugin Contributions:
0

Re: Dependant Attributes - Can I do this?

Seems like the biggest problem is how the stock_attributes is populated when using some of the "All" alternatives when adding attributes in admin/products_with_attributes_stock.php

For some reason, the values are added in the wrong order.. Instead of (example) adding:
0,4,13
0,4,14

the values are added as:
0,13,4
0,14,4

which confuses the parser when reading in the values for populating the selection boxes. Highly annoying since I have some 60-70 combinations per article to enter..

5 May 2009, 7:03 PM
#44
suzr avatar

suzr

New Zenner

Join Date:
Apr 2009
Posts:
12
Plugin Contributions:
0

Re: Dependant Attributes - Can I do this?

Can't say if it's "correct", but editing admin/products_with_attributes_stock.php seems to work for me.

Section:

if(sizeof($attributes) > 1) {
	sort($attributes);
	$stock_attributes = implode(',', $attributes);
} else {
	$stock_attributes = $attributes[0];

Comment out the array sort:
// sort($attributes);

15 May 2009, 6:12 PM
#45
digidiva_kathy avatar

digidiva_kathy

Zen Follower

Join Date:
May 2006
Posts:
323
Plugin Contributions:
0

Re: Dependant Attributes - Can I do this?

I am also having this error:

1146 Table 'jus0912702071770.products_with_attributes_stock' doesn't exist
in:
[SELECT quantity FROM products_with_attributes_stock AS a LEFT JOIN products_attributes AS b ON (b.options_id=3 AND b.options_values_id=5) WHERE a.products_id = '1' AND a.stock_attributes = b.products_attributes_id AND a.quantity > 0 order by b.products_options_sort_order]

I have added this to database_tables.php
define('TABLE_PRODUCTS_STOCK', DB_PREFIX . 'products_with_attributes_stock');

the table is in my database (zen_products_with_attributes_stock), but still the error...help? Please?

22 Jun 2009, 5:14 PM
#46
edeades avatar

edeades

New Zenner

Join Date:
May 2009
Posts:
25
Plugin Contributions:
0

Re: Dependant Attributes - Can I do this?

I have read through this thread and cannot find the answer to my issue. I have installed the stocks by attributes 4.7 and it was working. I then installed the dynamic dropdowns and I am receiving this error,

1146 Table 'tablename_zc1.products_with_attributes_stock' doesn't exist
in:
[select quantity from products_with_attributes_stock where products_id = '2' AND quantity > 0]

When I check my database, I see this table.

Please help.

23 Jun 2009, 8:39 AM
#47
skybluepunk avatar

skybluepunk

New Zenner

Join Date:
Oct 2008
Posts:
28
Plugin Contributions:
0

Re: Dependant Attributes - Can I do this?

Hi Jade,

I noticed that on this Monkey Pants page [http://www.monkeypantskids.com/fuzzi-bunz-perfect-size-diaper-p-5.html] each colour swatch is shown 3 times. Is this because each colour is in stock in each size?

The repeated swatches effect does not appear to be happening on other pages, such as [http://www.monkeypantskids.com/thirsties-diaper-cover-p-8.html]. Have you coded this page differently to prevent it happening?

Also, you asked about displaying stock quantities against attributes - have you had any luck getting this to work?

Thanks!

2 Jan 2010, 8:11 PM
#48
jerryclunsford avatar

jerryclunsford

New Zenner

Join Date:
Jan 2010
Location:
Lake Nocona, Texas
Posts:
9
Plugin Contributions:
0

Re: Dependant Attributes - Can I do this?

I can not find the dependent attributes module in the free software add ons. Can some one tell where it is?
Jerry

2 Jan 2010, 8:36 PM
#49
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Dependant Attributes - Can I do this?

jerryclunsford:

I can not find the dependent attributes module in the free software add ons. Can some one tell where it is?I suspect that you mean this.

2 Jan 2010, 8:49 PM
#50
jerryclunsford avatar

jerryclunsford

New Zenner

Join Date:
Jan 2010
Location:
Lake Nocona, Texas
Posts:
9
Plugin Contributions:
0

Re: Dependant Attributes - Can I do this?

kuroi:

I suspect that you mean this.

I have found and installed the The above mentioned mod.
in another post it was stated you had to install it and the Dependant Attributes mod.
Please forgive my ignorance I am new to this. Are they in the same package?
Jerry

2 Jan 2010, 8:53 PM
#51
jerryclunsford avatar

jerryclunsford

New Zenner

Join Date:
Jan 2010
Location:
Lake Nocona, Texas
Posts:
9
Plugin Contributions:
0

Re: Dependant Attributes - Can I do this?

VCSharpin:

There are two steps to the install. First you have to install the stock_by_attributes module. Then you have to install the dependent attributes module.

I did not install the other stock_by_attributes module first. It's in the instructions for the dependent attributes module, but it's easy to miss.

This is what I was Going By.
Jerry

2 Jan 2010, 8:58 PM
#52
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Dependant Attributes - Can I do this?

jerryclunsford:

I have found and installed the The above mentioned mod.
in another post it was stated you had to install it and the Dependant Attributes mod.
Please forgive my ignorance I am new to this. Are they in the same package?No, they're the same thing. As your post immediately above shows, you were reading about the need to install the "stock by attributes" (SbyA) with this package, since this package depends on the data collected and entered by SbyA.

2 Jan 2010, 9:07 PM
#53
jerryclunsford avatar

jerryclunsford

New Zenner

Join Date:
Jan 2010
Location:
Lake Nocona, Texas
Posts:
9
Plugin Contributions:
0

Re: Dependant Attributes - Can I do this?

OK, Thanks got it now. Up too late last night when I first read all this.
I didn't pay enough attention to the requirements for Dynamic Drop Downs for Stock by Attributes. Now will I have to uninstall the Dynamic Drop Downs for Stock by Attributes, install the stock by attributes and re-install the Dynamic Drop Downs for Stock by Attributes? Or can I simply install the Stock by attributes?
Jerry

2 Jan 2010, 10:03 PM
#54
jerryclunsford avatar

jerryclunsford

New Zenner

Join Date:
Jan 2010
Location:
Lake Nocona, Texas
Posts:
9
Plugin Contributions:
0

Re: Dependant Attributes - Can I do this?

Kuroi,
I am attempting to install Stock By Attributes. In in the install instructions it says to
"Prepare the package for upload to your server by renaming the following folders to match your template name: includes/modules/YOUR_TEMPLATE and includes/templates/YOUR_TEMPLATE."
I do not see a folder includes/modules/YOUR_TEMPLATE. I did find includes/templates/YOUR_TEMPLATE and have changed it. The only file in the package under includes/templates is pages. I do have a file in includes/modules for my template can I simply place the pages folder there? Sorry but I am very new to this.

2 Jan 2010, 11:07 PM
#55
jerryclunsford avatar

jerryclunsford

New Zenner

Join Date:
Jan 2010
Location:
Lake Nocona, Texas
Posts:
9
Plugin Contributions:
0

Re: Dependant Attributes - Can I do this?

It looks like I have Products with attributes installed. Not sure if it works yet. Time for a Break !!! I will read its operational instructions after and test it then re-install Dynamic Drop Downs for products with attributes.
Thank you
Jerry
P.S. I just put the pages folder in includes/modules/YOUR_TEMPLATE folder.

3 Jan 2010, 1:50 AM
#56
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: Dependant Attributes - Can I do this?

You all should read through the Dynamic Dropdowns support thread.. You will see that the module DOES NOT work, and the mod author appears to no longer be supporting it..

3 Jan 2010, 3:37 AM
#57
jerryclunsford avatar

jerryclunsford

New Zenner

Join Date:
Jan 2010
Location:
Lake Nocona, Texas
Posts:
9
Plugin Contributions:
0

Re: Dependant Attributes - Can I do this?

Thank You for the information. I can stop trying to get it to work now. It seems like it would save time if said on download that it doesn't work.
Jerry

3 Jan 2010, 5:10 AM
#58
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: Dependant Attributes - Can I do this?

jerryclunsford:

Thank You for the information. I can stop trying to get it to work now. It seems like it would save time if said on download that it doesn't work.
JerryYou're welcome..

You can certainly upload an update to the module that lets people know it doesn't work.. The modules like the application are all built and maintained by volunteers so it's unlikely that the module will be updated with this data unless the community takes the initiative to do so.. That's why it's always strongly recommended that you backup before installing.. I personally recommend building a test store to test modules before applying them to your live shop.. Gives you an opportunity to test things out to see how/if they work..

5 Jan 2010, 6:13 PM
#59
jerryclunsford avatar

jerryclunsford

New Zenner

Join Date:
Jan 2010
Location:
Lake Nocona, Texas
Posts:
9
Plugin Contributions:
0

Re: Dependant Attributes - Can I do this?

I always build tests for the website. Even when only adding pages. I would rather do that and check it than have someone go the site and have something not work or not work as I intended it to.
It appears that this is going to take a LONG time to set up go get close to what I want.
The website is for a Trailer Sales and Manufacturer. The Shopping cart will be used to give the visitor a price estimate for the trailer they are considering purchasing. There are many types and models of trailers. Each in various lengths with optional equipment. Some of the Optional equipment is price by the foot according to the length of the trailer. While other options can be purchased in multiples e.g. 4" D Rings for tie downs.
I looks likes without something like the dependent attributes it will take a while to get something that is functional and as clean as I would like.
Once again Thank You for keeping me from wasting more time on something that doesn't work.
Jerry

17 Mar 2010, 2:27 PM
#60
josh597 avatar

josh597

New Zenner

Join Date:
Mar 2010
Posts:
8
Plugin Contributions:
0

Re: Dependant Attributes - Can I do this?

I'm all of a sudden getting this as well.

This happened right after I installed the dynamic dropdowns for stock by attibutes 1.3.4.

1146 Table 'klkrefle_zen.TABLE_PRODUCTS_STOCK' doesn't exist
in:
[SELECT quantity FROM TABLE_PRODUCTS_STOCK AS a LEFT JOIN products_attributes AS b ON (b.options_id=1 AND b.options_values_id=5) WHERE a.products_id = '4' AND a.stock_attributes = b.products_attributes_id AND a.quantity > 0 order by b.products_options_sort_order]

My site is http://www.klkreflectiveimages.com/zen

I have already installed Stock By Attributes and it is running fine.
I've followed all of the steps from the above posts, but nothing is working.

Please help... I'm dead in the water