Results 1 to 8 of 8
  1. #1
    Join Date
    Mar 2010
    Posts
    66
    Plugin Contributions
    0

    Default One product, multible sizes

    Hello all.

    I just got my Zencart up and running so I have the most recent release.

    What I'm trying to do is get my products set up properly.

    I'm selling clothing. So I have a red shirt that comes in small, medium, and large. But I have limited quantities of each. Once I'm out of one size, that's it.

    I don't want to make 3 different products for each size with the same image, that's silly.

    So how do I get it so that my Option Value with the dropdown to say :
    Small (3 left)
    Medium (5 left)
    Large (1 left)

    or something along those lines. Even if I can't have the (#left) I would like to have the size automatically remove itself so I don't have customers buying something that I no longer have.

    Thanks!

    p.s. I'm a video game programmer by trade and php is very readable to me and so you can get all technical with me and stuff!

  2. #2
    Join Date
    Feb 2005
    Location
    Lansing, Michigan USA
    Posts
    20,021
    Plugin Contributions
    3

  3. #3
    Join Date
    Mar 2010
    Posts
    66
    Plugin Contributions
    0

    Default Re: One product, multible sizes

    Dude you are a cake of awesome with booyeah frosting!



  4. #4
    Join Date
    Mar 2010
    Posts
    66
    Plugin Contributions
    0

    Default Re: One product, multible sizes

    Problem;

    When I run out of a size, it doesn't hide that size from the drop down menu. It just gives a back order thing to the shopping cart.

    I can't have this since I have no backorder products at all.

    So how can I hide the size when stock = 0?

  5. #5
    Join Date
    Mar 2010
    Posts
    5
    Plugin Contributions
    0

    Default Re: One product, multible sizes

    I just finished hacking mine. I am not advising this but it works for my site and I can't find/wait for a better answer. Use at your own risk!

    I'm using ZC 1.3.8 and Stock By Attributes 1.4.9. This is for a dropdown menu with one attribute. I am not sure if this SQL is relevant to anything else.

    In the file includes/modules/attributes.php around line 76 you should find this:

    Code:
                    $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;
    I replaced it with this:
    Code:
    $sql = "select    pov.products_options_values_id,
    	pov.products_options_values_name,
    	pa.*
    	from      " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov
    ,products_with_attributes_stock ps
    	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 pa.products_attributes_id = ps.stock_attributes
    AND pa.products_id = ps.products_id
    AND ps.quantity > 0
    	and       pov.language_id = '" . (int)$_SESSION['languages_id'] . "' " .
    	$order_by;
    The funky indent is so you can see which lines I added.


    Note that I did not use a variable name for the products_with_attributes_stock. What this does is when the attributes are selected it does not include any with Quantity 0 or less. Since this result is used to build the dropdown menu items that are out of stock never show up.

    Again, this is pretty specific, but hopefully will help you solve your problem.

  6. #6
    Join Date
    Mar 2010
    Posts
    5
    Plugin Contributions
    0

    Default Re: One product, multible sizes

    Well I've discovered that SQL code only works for my first item.

    I think the idea is correct, just the manner in which the attributes by item are being returned is opaque to me, so I need to rework the SQL so I understand it (and can join on stock).

  7. #7

    Default Re: One product, multible sizes

    Quote Originally Posted by jage View Post
    Well I've discovered that SQL code only works for my first item.

    I think the idea is correct, just the manner in which the attributes by item are being returned is opaque to me, so I need to rework the SQL so I understand it (and can join on stock).
    If you're only looking to affect the drop-down box, you will need to find this line of code in attributes.php:

    Code:
    $options_menu[] = zen_draw_pull_down_menu('id[' . $products_options_names->fields['products_options_id'] . ']', $products_options_array, $selected_attribute, 'id="' . 'attrib-' . $products_options_names->fields['products_options_id'] . '"') . "\n";
    Before you modify it, I recommend you place it in an override folder, i.e., /includes/modules/[YOU TEMPLATE]/attributes.php, and edit that file.

    Notice that it uses a function called zen_draw_pull_down_menu(). That can be found in html_output.php in the functions folder. You'll need to either create a new function and modify it in html_output, or copy that function down to attributes.php and modify it. Basically, what I did was check to see for read-only or quantity, and stated that selection was [out of stock] in the drop-down box. There is CSS you need to add if you want to grey it out. You can see it in action at:

    http://www.randylion.com/index.php?m...roducts_id=142

    You could remove that selection by modifying the function. If you wanted to do this for radio buttons, that is elsewhere in attributes.php.

    Hope that points you in the right direction...
    Owner, Randylion
    http://www.randylion.com

  8. #8
    Join Date
    Mar 2010
    Posts
    5
    Plugin Contributions
    0

    Default Re: One product, multible sizes

    Yes my intention is not to get people off on the wrong track! I can't figure out how products_with_attributes_stock.stock_attributes can be related to products_attributes.options_values_id so I created a new column in products_with_attributes_stock called products_attributes_lookup_id and hand populated it.

    Again, I'm not saying this is a GOOD solution and I don't really understand a lot of the zen_cart coding choices but this is what got my single attribute drop down with stock working for the time being.

    Code:
    $sql = 'SELECT
    			pov.products_options_values_id,
    			pov.products_options_values_name,
    			pa.*
    		FROM
    			products_attributes pa
    		JOIN products_options_values pov ON
    			pa.options_values_id = pov.products_options_values_id
    		JOIN products_with_attributes_stock ps ON
    			(pa.options_values_id = ps.products_attributes_lookup_id
    				AND
    			pa.products_id = ps.products_id)
    		WHERE
    			pa.products_id = ' . (int)$_GET['products_id'] .'
    			AND pa.options_id = ' . (int)$products_options_names->fields['products_options_id'] . '
    			AND pov.language_id = ' . (int)$_SESSION['languages_id'] . '
    		' . $order_by;

 

 

Similar Threads

  1. Mutlitple sizes of one product
    By Marian in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 21 Jul 2011, 03:23 PM
  2. One Product - 4 sizes with 4 diff prices
    By zacharyrs in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 27 Jan 2009, 10:35 PM
  3. Adding multiple sizes or scents to one product
    By chachab in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 4 May 2008, 07:47 PM
  4. One product, different sizes / colors
    By richter in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 23 Apr 2007, 04:24 PM
  5. One product, multiple sizes
    By Clownfish in forum Setting Up Categories, Products, Attributes
    Replies: 4
    Last Post: 14 Jul 2006, 02:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg