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 101 to 120 of 273
This thread is locked. New replies are disabled.
2 Feb 2006, 10:11 AM
#101
longstockings avatar

longstockings

Zen Follower

Join Date:
Jul 2004
Posts:
198
Plugin Contributions:
0

Stock For Product With Different Attributes (OLD)

If possible I would prefer it if it showed the attributes with the amount in stock in brackets. If a javascript alert could be shown or something before the customer gets to the shopping cart I think that would be better.

I think having to add to your cart and the cart telling you the item is out of stock would be a waste of time and likely to annoy the customer.

We need to show when something is out of stock but also make sure that the option cannot be picked from the dropdown.

What does everyone else think?

UK based Zen Cart Web Designer here https://www.handcoded.co.uk

2 Feb 2006, 5:32 PM
#102
afx114 avatar

afx114

Zen Follower

Join Date:
Aug 2005
Posts:
144
Plugin Contributions:
0

Re: Stock For Product With Different Attributes (OLD)

longstockings:

We need to show when something is out of stock but also make sure that the option cannot be picked from the dropdown.
We've gone over this before, it's not that easy. The reason being, attributes are shown seperately on the product info page, and there's no way to know that a combo of attributes is out of stock until we know which combo the user wants (the user must set each attribute first).

This is tricky to do, it either requires a page reload whenever an attribute is picked (to check stock), or some sort of AJAX solution.

I do have an idea to handle this. Instead of showing a form option for each seperate attribute, it would show a dropdown offering all permutions of attribute. This way we could check stock on each permutation and show or not show it depending on its stock.

3 Feb 2006, 6:29 AM
#104
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)

bettysue:

Nice site Audra! Unique, well organized, and pleasing to the eye! In other words....I'm jealous...lol

b
Thanks, I needed that! Still so much to do and so much to learn about how to do it!

3 Feb 2006, 6:34 AM
#105
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)

chad:

Something like this: http://ajax.zervaas.com.au/examples/Countr...yRegionCityJax/ would probably work..
I've got to say, this certainly seems like the ideal way to go. Myself, I am a programming ignoramous. Is this "AJAX" that afx114 referred to earlier?

Audra

7 Feb 2006, 9:09 PM
#106
dafonz avatar

dafonz

Banned

Join Date:
Jun 2004
Posts:
40
Plugin Contributions:
0

Re: Stock For Product With Different Attributes (OLD)

longstockings:

If possible I would prefer it if it showed the attributes with the amount in stock in brackets. If a javascript alert could be shown or something before the customer gets to the shopping cart I think that would be better.

We need to show when something is out of stock but also make sure that the option cannot be picked from the dropdown.

What does everyone else think?

It would really help if you bothered to read the entire thread and saw that the request has already been made and the reasons for it not happening explained. Asking for it again.. ISN'T going to get it done any faster.

7 Feb 2006, 9:12 PM
#107
dafonz avatar

dafonz

Banned

Join Date:
Jun 2004
Posts:
40
Plugin Contributions:
0

Re: Stock For Product With Different Attributes (OLD)

afx114:

This is tricky to do, it either requires a page reload whenever an attribute is picked (to check stock), or some sort of AJAX solution.

I do have an idea to handle this. Instead of showing a form option for each seperate attribute, it would show a dropdown offering all permutions of attribute. This way we could check stock on each permutation and show or not show it depending on its stock.
The dropdown with the different permutations would work.. except for two things

a) it's a freaking nightmare for the customer in terms of usability (imagine 4 different attributes.. that's a lot of combinations...).
B) it's require modification of the core source files.. the add to cart function would be .. kinda hard to mess with imo.

AJAX on the other hand would work decently well as you could have a seperate ajax.php file which will handle the stock lookup. To degrade gravefully, you could put the existing code now between some noscript tags and have it work.

9 Feb 2006, 5:49 AM
#108
gyrm avatar

gyrm

New Zenner

Join Date:
Oct 2005
Posts:
5
Plugin Contributions:
0

Re: Stock For Product With Different Attributes (OLD)

I've been searching the forums and I can't seem to find the answer ... or at least the one I'm hoping for. I though I'd ask here since you all are attribute experts ;)

Is it possible to display a list of products by the value of an attribute? For example, if I assign a size attribute to a product, is there any way for me to list all products available in size 6?

I just don't think doing this through category linking is a good approach.

Please check out my current project:
MoSudoku - Enlightened Sudoku - Free, Open Source

13 Feb 2006, 7:34 AM
#109
dafonz avatar

dafonz

Banned

Join Date:
Jun 2004
Posts:
40
Plugin Contributions:
0

Re: Stock For Product With Different Attributes (OLD)

gyrm:

I've been searching the forums and I can't seem to find the answer ... or at least the one I'm hoping for. I though I'd ask here since you all are attribute experts ;)

Is it possible to display a list of products by the value of an attribute? For example, if I assign a size attribute to a product, is there any way for me to list all products available in size 6?

I just don't think doing this through category linking is a good approach.
Nope.. not possible

14 Feb 2006, 2:27 PM
#110
grayson avatar

grayson

Totally Zenned

Join Date:
Oct 2005
Location:
Netherlands
Posts:
516
Plugin Contributions:
0

Re: Stock For Product With Different Attributes (OLD)

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.

14 Feb 2006, 3:31 PM
#111
ringy avatar

ringy

New Zenner

Join Date:
Dec 2005
Posts:
62
Plugin Contributions:
0

Re: Stock For Product With Different Attributes (OLD)

grayson - you are a mind reader! I would like to adapt your code such that instead of displaying number of pieces in stock, I'd like to do the following:

  1. check if an attribute variant is in stock
  2. if it is, then display an image or words stating something like "24hr dispatch" next to the attribute variant
  3. if attribute is out of stock, then display something like "2-3 days dispatch" next to the attribute variant

Since my suppliers can get most items to me within two days, I don't want to lose a sale if the customer doesn't mind waiting a few days more. It also gets around the "tell the customer they're out of stock before adding to cart" debate......

This is particularly important for me as I cannot stock all variants of a product but can order and dispatch them quickly should a customer want them.

So, in summary, is it possible to create some code that checks the attribute stock level and displays the appropriate message? To help clarify, here is an example I am trying to replicate.

Final point is that I only expect to have one attribute array (eg size OR colour, not both).

Looking forward to your help ::tup

14 Feb 2006, 3:37 PM
#112
ringy avatar

ringy

New Zenner

Join Date:
Dec 2005
Posts:
62
Plugin Contributions:
0

Re: Stock For Product With Different Attributes (OLD)

Another more general point....

Is it possible to maintain attribute stocks using Easy Populate?

Cheers!

14 Feb 2006, 3:50 PM
#113
grayson avatar

grayson

Totally Zenned

Join Date:
Oct 2005
Location:
Netherlands
Posts:
516
Plugin Contributions:
0

Re: Stock For Product With Different Attributes (OLD)

Ringy, that's a fairly simple change. First add in the changes I suggsted above. Then modify further as follows.

In main_template_vars_attributes.php, replace the line:

       $products_options_details = $products_options->fields['products_options_values_name'] . ' [' . $products_options->fields['quantity'] . ' '. TEXT_ATTRIBUTES_PIECES . ']';

with

       if ($products_options->fields['quantity']) > 0) {
        $products_options_details = $products_options->fields['products_options_values_name'] . ' [' . TEXT_ATTRIBUTES_IN_STOCK . ']';
       } else {
        $products_options_details = $products_options->fields['products_options_values_name'] . ' [' . TEXT_ATTRIBUTES_NOT_IN_STOCK . ']';
       }

Then a few lines below that, replace the line

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

with

       if ($products_options->fields['quantity']) > 0) {
        $products_options_details_noname = ' [' . TEXT_ATTRIBUTES_IN_STOCK . ']' . $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '<br />' . $products_options_display_weight : '');
       } else {
        $products_options_details_noname = ' [' .  TEXT_ATTRIBUTES_NOT_IN_STOCK . ']' . $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '<br />' . $products_options_display_weight : '');
       }

and a few lines down from that, replace the line

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

with

       if ($products_options->fields['quantity']) > 0) {
       $products_options_details_noname = ' [' . TEXT_ATTRIBUTES_IN_STOCK . '] ' . $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '' . $products_options_display_weight : '');
       } else {
       $products_options_details_noname = ' [' . TEXT_ATTRIBUTES_NOT_IN_STOCK . '] ' . $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '' . $products_options_display_weight : '');
}

Then add two define() statements to your languages/english/your_template/product_info.php to define TEXT_ATTRIBUTES_IN_STOCK and TEXT_ATTRIBUTES_NOT_IN_STOCK. (Repeat for any other languages you have.)

NOTE: I have not tested this, so don't run it on a live store until you've tested it first. There could be a typo in there ;).

14 Feb 2006, 4:21 PM
#114
ringy avatar

ringy

New Zenner

Join Date:
Dec 2005
Posts:
62
Plugin Contributions:
0

Re: Stock For Product With Different Attributes (OLD)

Thanks for such a speedy response grayson......will give this a try ASAP.

Will let you know how it goes.....

14 Feb 2006, 5:31 PM
#115
cslhypnotech avatar

cslhypnotech

Zen Follower

Join Date:
Aug 2005
Posts:
133
Plugin Contributions:
0

Re: Stock For Product With Different Attributes (OLD)

ringy:

grayson - you are a mind reader! I would like to adapt your code such that instead of displaying number of pieces in stock, I'd like to do the following:

  1. check if an attribute variant is in stock
  2. if it is, then display an image or words stating something like "24hr dispatch" next to the attribute variant
  3. if attribute is out of stock, then display something like "2-3 days dispatch" next to the attribute variant

Since my suppliers can get most items to me within two days, I don't want to lose a sale if the customer doesn't mind waiting a few days more. It also gets around the "tell the customer they're out of stock before adding to cart" debate......

This is particularly important for me as I cannot stock all variants of a product but can order and dispatch them quickly should a customer want them.

So, in summary, is it possible to create some code that checks the attribute stock level and displays the appropriate message? To help clarify, here is an example I am trying to replicate.

Final point is that I only expect to have one attribute array (eg size OR colour, not both).

Looking forward to your help ::tup
I would like to see this as well; doesn't seem like it would be too hard to accomplish.

14 Feb 2006, 6:01 PM
#117
afx114 avatar

afx114

Zen Follower

Join Date:
Aug 2005
Posts:
144
Plugin Contributions:
0

Re: Stock For Product With Different Attributes (OLD)

I'll be posting my updated package soon. Note that all of the changes are in the back-end admin, making the entry/maintenance of stock #'s a snap. I've made no changes to the way this mod operates on the front end. That'll be next...

14 Feb 2006, 6:07 PM
#118
cslhypnotech avatar

cslhypnotech

Zen Follower

Join Date:
Aug 2005
Posts:
133
Plugin Contributions:
0

Re: Stock For Product With Different Attributes (OLD)

grayson:

Cslhypno, see my second post above; it's there.
Parse error: parse error, unexpected '>' in /path/to/my/stuff/includes/modules/pages/product_info/main_template_vars_attributes.php on line 193

This is after doing both updates.

14 Feb 2006, 6:12 PM
#119
cslhypnotech avatar

cslhypnotech

Zen Follower

Join Date:
Aug 2005
Posts:
133
Plugin Contributions:
0

Re: Stock For Product With Different Attributes (OLD)

grayson:

So......if you look on line 193, what do you see? :)

It's in the second mod, not the first; as I said, I didn't test the second one, and there might be typos in it ;) .

If you post your lines 190-195 or so, I'll take a look.
Ah, sorry, I'm runnin' a little slow today.. Here's 193-203

       if ($products_options->fields['quantity']) > 0) {
        $products_options_details = $products_options->fields['products_options_values_name'] . ' [' . TEXT_ATTRIBUTES_IN_STOCK . ']';
       } else {
        $products_options_details = $products_options->fields['products_options_values_name'] . ' [' . TEXT_ATTRIBUTES_NOT_IN_STOCK . ']';
       }
      } 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 : '');
14 Feb 2006, 6:15 PM
#120
grayson avatar

grayson

Totally Zenned

Join Date:
Oct 2005
Location:
Netherlands
Posts:
516
Plugin Contributions:
0

Re: Stock For Product With Different Attributes (OLD)

So......if you look on line 193, what do you see? :)

It's in the second mod, not the first; as I said, I didn't test the second one, and there might be typos in it ;) .

If you post your lines 190-195 or so, I'll take a look.