Forums / All Other Contributions/Addons / Stock For Product With Different Attributes (OLD)

Stock For Product With Different Attributes (OLD)

Locked

Started by dafonz on 30 Nov 2005, 8:52 PM · Views: 80,867

Results 261 to 273 of 273
This thread is locked. New replies are disabled.
29 Apr 2006, 6:34 PM
#261
audradh avatar

audradh

Zen Follower

Join Date:
Oct 2005
Location:
Eastern US
Posts:
429
Plugin Contributions:
0

Stock For Product With Different Attributes (OLD)

Scratch the above code that I posted. I cut and pasted Stephen's code that eliminates the confirm button (success, yay!)

I have now replaced the 2 snippets of code that should pre-populate the quantity field, but still no changes. At least I didn't break it!

Has anyone else gotten the pre-populate edit to work?

Thanks,
Audra

29 Apr 2006, 6:49 PM
#262
audradh avatar

audradh

Zen Follower

Join Date:
Oct 2005
Location:
Eastern US
Posts:
429
Plugin Contributions:
0

Re: Stock For Product With Different Attributes (OLD)

Sorry your cart is broken Mike. I'm afraid I won't be of much help. Have you checked to make sure the files referenced in the error actually exist?

The other thing I wonder about is the > DIR_FS_CATALOG_LANGUAGESenglish/meta_tags.php

Is it normal to have LANGUAGESenglish show up in an error without a / or something between them. I'm wondering if that is a typo somewhere in your code.

Anyway, being a complete programming ignoramous (you've been warned) those are the two things that I would look at first.

Also, since your store is broke, if nobody shows up here shortly you may find that this is a post that is better suited to the general questions forum. I know cross-posting is frowned upon, but I'm not sure that your error is related to this mod even if that is what you were working on when you, aah, when it broke.

GL,
Audra

and, yes, when you finally get this working you ARE gonna love it!

29 Apr 2006, 7:16 PM
#263
audradh avatar

audradh

Zen Follower

Join Date:
Oct 2005
Location:
Eastern US
Posts:
429
Plugin Contributions:
0

Re: Stock For Product With Different Attributes (OLD)

joostvdl:

A Java script that checks the different combinations that are available:

<script type="text/javascript" language="JavaScript"> function changeCategory(vl) { switch(vl) {  case "6":    strn = '<select name="id[2]"><option value="5">Extra Large</option><option value="5">Extra Large</option><option value="4">Large</option><option value="4">Large</option><option value="3">Medium</option><option value="3">Medium</option></select>';        break;  case "8":    strn = '<select name="id[2]"><option value="5">Extra Large</option><option value="5">Extra Large</option><option value="4">Large</option><option value="4">Large</option><option value="3">Medium</option><option value="3">Medium</option><option value="15">Xs</option></select>';        break; }   document.getElementById('2').innerHTML='';   document.getElementById('2').innerHTML=strn;     return false; } </script>
> 
> and the dropdown lists:
> 
> ```
           <tr>
              <td class="main">Kleur:</td>
              <td class="main"><span id="1"><select name="id[1]"  id="superid" onChange="changeCategory(this.value)"><option value="8">Groen</option><option value="6">Roze</option></select></span></td>
            </tr>
            <tr>
              <td class="main">Maat:</td>
              <td class="main"><span id="2"><select name="id[2]"><option value="5">Extra Large</option><option value="5">Extra Large</option><option value="4">Large</option><option value="4">Large</option><option value="3">Medium</option><option value="3">Medium</option><option value="15">Xs</option></select></span></td>
            </tr>
              <td class="main"><a href="/conversion.php" target="new">Onbekende maat? Klik hier voor de maat<br>conversietabel (link opent in een nieuw venster).</a></td>
<script type="text/javascript" language="JavaScript">
vll = document.getElementById('superid').options[document.getElementById('superid').selectedIndex].value;
changeCategory(vll);
</script>

With this javascript there is no need for AJAX.

But I hav not yet integrated this in the mod. So any help should be great.

Joost
Does anyone know, is this JS that Joostdvl posted the JS from s_mack that works w/ multiple attributes rather than single? I'm thinking that it is because Joostdvl mentions not needing AJAX anymore.

Anybody?
(I'm getting so confused by this thread! Usually when it gets away from me I just sit tight and wait for a new mod version, but it looks like this one may be awhile, not that I am complaining, just confused :huh: )

Thx,
Audra

30 Apr 2006, 7:18 AM
#264
joostvdl avatar

joostvdl

New Zenner

Join Date:
Nov 2005
Posts:
23
Plugin Contributions:
0

Re: Stock For Product With Different Attributes (OLD)

Hi All

I have creeated a solution, but I have to clean it up now so It is uasable for more of you.

So give me a couple of days and I'will post my solution.

30 Apr 2006, 7:39 PM
#265
kgmmusic avatar

kgmmusic

New Zenner

Join Date:
Nov 2005
Posts:
76
Plugin Contributions:
0

Re: Stock For Product With Different Attributes (OLD)

I have installed this contibution and have a question...

If I use combined atrributes with this mod (size=radio)+(color=dropdown) should they both show up with all available options?

I tried this and got the radio buttons OK but the dropdown menu was blank (no options) - shouldn't I see all of the available colors in the dropdown?

What does the multiple attributes look like in the store's front end? (screeenshot)

I edited the code to display the stock number, will this work with multiple attributes?

Thanks in advance for all the help!

1 May 2006, 6:40 AM
#266
audradh avatar

audradh

Zen Follower

Join Date:
Oct 2005
Location:
Eastern US
Posts:
429
Plugin Contributions:
0

Re: Stock For Product With Different Attributes (OLD)

Thanks Joostvdl, looking forward to it!

kgmmusic,

**If I use combined atrributes with this mod (size=radio)+(color=dropdown) should they both show up with all available options?
**

Yes.

What does the multiple attributes look like in the store's front end? (screeenshot

Take a look at my site for examples of what multiple attribute options using dropdown looks like. Most of my products fit that criteria.

Of note, it is possible in Zen to have multiple product attributes without this mod. What this mod does is allow you to maintain stock levels for items based upon their attributes. For example,

1 large red shirt
2 med green shirts
1 small green shirt

as opposed to

4 shirts

Did you have the attributes working properly before adding this mod?

Here is a discussion about adding attributes:
http://www.zen-cart.com/modules/ipb/index....=ST&f=44&t=6511

HTH,
Audra

2 May 2006, 6:50 PM
#267
svanis avatar

svanis

Zen Follower

Join Date:
May 2005
Location:
Sweden
Posts:
145
Plugin Contributions:
0

Re: Stock For Product With Different Attributes (OLD)

Great contrib! Got it working real sweet as far as i can see.. :P

Now I need help with another thing and this thread seems to be the best place since it "semi-has-to-do" with this. I want the "total in stock" to be displayed as "In stock" or "2-3 days delivery from distributor".

I've got this working with the actual attributes dropdown but my php skills won't take me that far in life.. :P

I need someone to help me with writing a simple if saying that if "total stock = 0" it will fetch ```
TEXT_ATTRIBUTES_NOT_IN_STOCK

else if

$products_quantity . TEXT_PRODUCT_QUANTITY


Thx!
3 May 2006, 2:47 AM
#268
tajul_ashyqin avatar

tajul_ashyqin

Zen Follower

Join Date:
Apr 2006
Location:
Labuan Island
Posts:
362
Plugin Contributions:
1

Re: Stock For Product With Different Attributes (OLD)

im getting excited for what can joostvdl may come with...i hope it is a new stock-by-attributes mod that compatible with ZC v1.3...!i just installed the mod under ZC v.1.2.7 & it is working perfectly!

"Whether you think you can, or you think you can't... YOU ARE RIGHT."
GOOD LUCK !!!

3 May 2006, 2:51 AM
#269
tajul_ashyqin avatar

tajul_ashyqin

Zen Follower

Join Date:
Apr 2006
Location:
Labuan Island
Posts:
362
Plugin Contributions:
1

Re: Stock For Product With Different Attributes (OLD)

actually,i intend not to use the ZC v1.3 because its incapability to trace stock-by-attributes...i hope somebody can make a solution to this... :(

"Whether you think you can, or you think you can't... YOU ARE RIGHT."
GOOD LUCK !!!

3 May 2006, 6:22 AM
#270
audradh avatar

audradh

Zen Follower

Join Date:
Oct 2005
Location:
Eastern US
Posts:
429
Plugin Contributions:
0

Re: Stock For Product With Different Attributes (OLD)

Svanis:

Great contrib! Got it working real sweet as far as i can see.. :P

Now I need help with another thing and this thread seems to be the best place since it "semi-has-to-do" with this. I want the "total in stock" to be displayed as "In stock" or "2-3 days delivery from distributor".

I've got this working with the actual attributes dropdown but my php skills won't take me that far in life.. :P

I need someone to help me with writing a simple if saying that if "total stock = 0" it will fetch ```
TEXT_ATTRIBUTES_NOT_IN_STOCK

else if

$products_quantity . TEXT_PRODUCT_QUANTITY

> 
> Thx!
 I think Ringy has added this functionality to his cart. For me his post in this thread is back around page 20 or so. 

Ringy, am I correct that your changes will only work for single attribute products? BTW, if I am wrong about that I would love a copy of your code.


Best,
Audra :D
3 May 2006, 6:56 AM
#271
svanis avatar

svanis

Zen Follower

Join Date:
May 2005
Location:
Sweden
Posts:
145
Plugin Contributions:
0

Re: Stock For Product With Different Attributes (OLD)

audradh:

I think Ringy has added this functionality to his cart. For me his post in this thread is back around page 20 or so.

Ringy, am I correct that your changes will only work for single attribute products? BTW, if I am wrong about that I would love a copy of your code.

Best,
Audra :D
Just to clarify, I am digging around in tpl_product_info_display.php.. All I need is to show the in stock quantity or basically just say 2-3 days dispatch.

Also another thing, isn't it possible to inherit all variants from the original product attributes? As it is now there is alot of extra work adding the variants.

6 May 2006, 5:37 AM
#272
audradh avatar

audradh

Zen Follower

Join Date:
Oct 2005
Location:
Eastern US
Posts:
429
Plugin Contributions:
0

Re: Stock For Product With Different Attributes (OLD)

grayson:

Here's an addition that will display the actual stock amounts for each attribute next to the attribute name. You can see it in action on this product in my store.

Open includes/modules/pages/product_info/main_template_vars_attributes.php and make the following changes:
Replace

       $sql = "select    pov.products_options_values_id,
                         pov.products_options_values_name,
                         pa.*
               from      " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov
               where     pa.products_id = '" . (int)$_GET['products_id'] . "'
               and       pa.options_id = '" . (int)$products_options_names->fields['products_options_id'] . "'
               and       pa.options_values_id = pov.products_options_values_id
               and       pov.language_id = '" . (int)$_SESSION['languages_id'] . "' " .
               $order_by;

> by
> ```
        $sql = "select    pov.products_options_values_id,
                          pov.products_options_values_name,
                          pwas.quantity,
                          pa.*
                from      " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pwas
                where     pa.products_id = '" . (int)$_GET['products_id'] . "'
                and       pa.options_id = '" . (int)$products_options_names->fields['products_options_id'] . "'
                and       pa.options_values_id = pov.products_options_values_id
                and       pwas.stock_attributes = pa.products_attributes_id
                and       pov.language_id = '" . (int)$_SESSION['languages_id'] . "' " .
                $order_by;

Next, in that same file replace:

         if ($products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_FILE or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_TEXT or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_CHECKBOX or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_RADIO or $products_options->RecordCount() == 1 or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_READONLY) {
           $products_options_value_id = $products_options->fields['products_options_values_id'];
           if ($products_options_names->fields['products_options_type'] != PRODUCTS_OPTIONS_TYPE_TEXT and $products_options_names->fields['products_options_type'] != PRODUCTS_OPTIONS_TYPE_FILE) {
             $products_options_details = $products_options->fields['products_options_values_name'];
           } else {
             // don't show option value name on TEXT or filename
             $products_options_details = '';
           }
           if ($products_options_names->fields['products_options_images_style'] >= 3) {
             $products_options_details .= $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '<br />' . $products_options_display_weight : '');
             $products_options_details_noname = $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '<br />' . $products_options_display_weight : '');
           } else {
             $products_options_details .= $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '' . $products_options_display_weight : '');
             $products_options_details_noname = $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '' . $products_options_display_weight : '');
           }
         }

> by
> ```
          if ($products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_FILE or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_TEXT or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_CHECKBOX or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_RADIO or $products_options->RecordCount() == 1 or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_READONLY) {
            $products_options_value_id = $products_options->fields['products_options_values_id'];
            if ($products_options_names->fields['products_options_type'] != PRODUCTS_OPTIONS_TYPE_TEXT and $products_options_names->fields['products_options_type'] != PRODUCTS_OPTIONS_TYPE_FILE) {
//              $products_options_details = $products_options->fields['products_options_values_name'];
// gbm - replaced original line above to display attribute stock amount beside attribute
              $products_options_details = $products_options->fields['products_options_values_name'] . ' [' . $products_options->fields['quantity'] . ' '. TEXT_ATTRIBUTES_PIECES . ']';
            } else {
              // don't show option value name on TEXT or filename
              $products_options_details = '';
            }
            if ($products_options_names->fields['products_options_images_style'] >= 3) {
              $products_options_details .= $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '<br />' . $products_options_display_weight : '');
//              $products_options_details_noname = $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '<br />' . $products_options_display_weight : '');
// gbm - replaced original line above to display attribute stock amount beside attribute
              $products_options_details_noname = ' [' . $products_options->fields['quantity'] . ' '. TEXT_ATTRIBUTES_PIECES . '] ' . $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '<br />' . $products_options_display_weight : '');
            } else {
              $products_options_details .= $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '' . $products_options_display_weight : '');
//              $products_options_details_noname = $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '' . $products_options_display_weight : '');
// gbm - replaced original line above to display attribute stock amount beside attribute
              $products_options_details_noname = ' [' . $products_options->fields['quantity'] . ' '. TEXT_ATTRIBUTES_PIECES . '] ' . $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '' . $products_options_display_weight : '');
            }
          }

Then open includes/languages/english/your_template/product_info.php and add the following line:

define('TEXT_ATTRIBUTES_PIECES','pieces');

> Repeat for all languages in your store.
 This post by Grayson earlier in the thread might be of use to you.

> **Also another thing, isn't it possible to inherit all variants from the original product attributes? As it is now there is alot of extra work adding the variants. **

Yes. Choose attributes for the original product. You will then find a copy option that will allow you to choose another product to copy the attributes to.

I believe that you can also globally do this, although I have not personally used that feature. Be sure to backup if copying globally.

Not sure if I'm answering your questions. HTH,
Audra
6 May 2006, 9:42 AM
#273
svanis avatar

svanis

Zen Follower

Join Date:
May 2005
Location:
Sweden
Posts:
145
Plugin Contributions:
0

Re: Stock For Product With Different Attributes (OLD)

Thanks for the reply audra but thats not what I'm asking for. I want the stock for attributes to be autopopulated with 0, this meaning that I don't have to open every single variant of a product but only the ones I actually have in stock.

I might sound lazy but having approx. 2000 products with attributes (an average of 5 attributes/product) will give me alot to do just inserting variants.

I'm just running a small business where the majority of my products are available at suppliers.

Pre-filling the variants with 0 would help me out alot! :P