Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 27
  1. #11
    Join Date
    Mar 2009
    Posts
    19
    Plugin Contributions
    0

    Default Re: Constarints for product quantities?

    Thank you, maybe using that module I'll be able to adapt it to my needs.
    Thank you, both of you, for your help.

  2. #12
    Join Date
    Jun 2005
    Location
    Cumbria, UK
    Posts
    10,269
    Plugin Contributions
    3

    Default Re: Constarints for product quantities?

    If you succeed, I'd really like to know the solution, as I too am building a wineshop with the same challenge!
    20 years a Zencart User

  3. #13
    Join Date
    Mar 2009
    Posts
    19
    Plugin Contributions
    0

    Default Re: Constarints for product quantities?

    Quote Originally Posted by gjh42 View Post
    In the product editing page in admin, you can set

    Product Qty Units: []

    to 6, and customers will only be allowed to buy that product in groups of 6.
    That's not what I want, the customer can buy 3 products A 1 products B and 1 product C, the important thing is that that sum is a multiple of 6 (only for some products, not for all).

  4. #14
    Join Date
    Sep 2004
    Location
    Western Massachusetts
    Posts
    2,945
    Plugin Contributions
    5

    Default Re: Constarints for product quantities?

    Quote Originally Posted by ccppll View Post
    Interesting tip, I'll try it! I think this could be ok, but now I would like to go a bit further: is it possible to add an hidden attribute to a product in order to be able to choose which products must be taken into account when doing this calculation? I mean, my goal is to check if the user has bought a number of products multiple of 6, but not all products must be subject to this limit. I could hard-code this list in the class, but it would be better if I could select them in the admin section.
    The best way to approach this would be to create a new product type that uses the same handler page as a normal product. Then you use that new product type only for items that have the qty 6 limit, rather than try to use a hidden attribute. Your custom code then just needs to check the product type, rather than against a list of product ids or extra fields/attributes.

    I don't think the qty-units setting in admin will help you, because that sets the order units just for the single product, which is not what you are trying to achieve.
    Neville
    An assumption is what you arrive at when you get tired of thinking...

  5. #15
    Join Date
    Mar 2009
    Posts
    19
    Plugin Contributions
    0

    Default Re: Constarints for product quantities?

    Quote Originally Posted by gjh42 View Post
    [In the product editing page in admin, you can set

    Product Qty Units: []

    to 6, and customers will only be allowed to buy that product in groups of 6.

    I don't know for sure if this forbids changing the quantity to an odd number once in the shopping cart, but I think that aspect is covered too.]

    Nevermind, eyes too bleary to see the "different kinds of wine" aspect of your question... no wonder knowledgeable people weren't giving that answer... :) Time for bed.
    Quote Originally Posted by bunyip View Post
    The best way to approach this would be to create a new product type that uses the same handler page as a normal product. Then you use that new product type only for items that have the qty 6 limit, rather than try to use a hidden attribute. Your custom code then just needs to check the product type, rather than against a list of product ids or extra fields/attributes.

    I don't think the qty-units setting in admin will help you, because that sets the order units just for the single product, which is not what you are trying to achieve.

    Mmmm, could I have a sample of this?

    thanks

  6. #16
    Join Date
    Sep 2004
    Location
    Western Massachusetts
    Posts
    2,945
    Plugin Contributions
    5

    Default Re: Constarints for product quantities?

    To add the new product type to your database, run this query from your SQL Patch page in admin:
    Code:
    INSERT INTO `product_types` ( `type_id` , `type_name` , `type_handler` , `type_master_type` , `allow_add_to_cart` , `default_image` , `date_added` , `last_modified` ) VALUES ('', 'Product - Wine', 'product', '1', 'Y', '', NOW( ) , NOW( ));
    sample function codes I've used for checking the product type:
    Code:
    // function to lookup product_type for product-wine
    function get_wine_product_type_id() {
        global $db;
    	
    	$sql = "select type_id from " . TABLE_PRODUCT_TYPES . " where type_name = 'Product - Wine'";
    	$type_query = $db->Execute($sql);
    	$wine_product_type = $type_query->fields['type_id'];
    	
    	return $wine_product_type;
    }
    
    // function to lookup a product's product_type
    function get_products_product_type_id($products_id) {
        global $db;
    	
    	$sql = "select products_type from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'";
    	$type_query = $db->Execute($sql);
    	$product_type_id = $type_query->fields['products_type'];
    	
    	return $product_type_id;
    }
    Then you could change the product type of your existing products that need to be this type directly from phpmyadmin - replace the value in the products_type field of the products table with the newe value (if you haven't previously added a new product type, the new one will be 6)
    Last edited by bunyip; 12 Mar 2009 at 03:39 PM. Reason: additional content
    Neville
    An assumption is what you arrive at when you get tired of thinking...

  7. #17
    Join Date
    Mar 2009
    Posts
    19
    Plugin Contributions
    0

    Default Re: Constarints for product quantities?

    Quote Originally Posted by bunyip View Post
    To add the new product type to your database, run this query from your SQL Patch page in admin:
    Code:
    INSERT INTO `product_types` ( `type_id` , `type_name` , `type_handler` , `type_master_type` , `allow_add_to_cart` , `default_image` , `date_added` , `last_modified` ) VALUES ('', 'Product - Wine', 'product', '1', 'Y', '', NOW( ) , NOW( ));
    sample function codes I've used for checking the product type:
    Code:
    // function to lookup product_type for product-wine
    function get_wine_product_type_id() {
        global $db;
    	
    	$sql = "select type_id from " . TABLE_PRODUCT_TYPES . " where type_name = 'Product - Wine'";
    	$type_query = $db->Execute($sql);
    	$wine_product_type = $type_query->fields['type_id'];
    	
    	return $wine_product_type;
    }
    
    // function to lookup a product's product_type
    function get_products_product_type_id($products_id) {
        global $db;
    	
    	$sql = "select products_type from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'";
    	$type_query = $db->Execute($sql);
    	$product_type_id = $type_query->fields['products_type'];
    	
    	return $product_type_id;
    }
    So type_handler is product, that is, it uses the same product class? Or should I override it? And, regarding the functions you posted, where could i add them? And where to call them?

    Thanks

  8. #18
    Join Date
    Sep 2004
    Location
    Western Massachusetts
    Posts
    2,945
    Plugin Contributions
    5

    Default Re: Constarints for product quantities?

    yes, if you keep the type_handler the same, you don't need to create a whole new bunch of files in admin or the catalog.
    If for example you set the handler to product_wine, you'd need to duplicate the folder admin/includes/modules/product, and add new pages and templates on the catalog side. You'd really only want to do that if you intended to add specific product fields into the database for standardizing display, or perhaps adding new product filters, etc.
    As for the functions, add them into a new file (eg wine_functions.php) in the includes/functions/extra_functions folder.
    You'd call them when writing your code for quantity checking:
    eg:
    Code:
    if (get_products_product_type_id($products_id) == get_wine_product_type_id()) { 
    check quantities code
    } else {
    do nothing
    }
    Neville
    An assumption is what you arrive at when you get tired of thinking...

  9. #19
    Join Date
    Mar 2009
    Posts
    19
    Plugin Contributions
    0

    Default Re: Constarints for product quantities?

    Hi! After some discussion with the costumer, he decided to change the way to handle things. He now wants to send only groups of 6 bottles of the same wine. So, now I just use quantity units to 6 and that's all. I would like to know if it would be possible to change a bit the way it's done. For example, why does zen cart lets me add 5 bottles to my cart if I must buy 6? Also, wouldn't it be possible to add the product unit instead of the single bottle? I mean, since I must add 6 or 12 etc bottles, but I would like to keep the price of a single bottle etc, is there a way to add not single bottles but groups of 6 bottles? So the number in the product quantity would be the number of units...

    Thanks!

  10. #20
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Constarints for product quantities?

    If you set the Units to 6, then the add to cart quantity box is 6 ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

 

 
Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. Combining product quantities for volume discount
    By Sylvanite in forum Setting Up Categories, Products, Attributes
    Replies: 8
    Last Post: 21 Jun 2016, 09:53 PM
  2. Unlimited product quantities for certain products
    By jcun45 in forum Setting Up Categories, Products, Attributes
    Replies: 5
    Last Post: 27 Dec 2010, 06:33 PM
  3. adding the Quantities for product attributes
    By ridelow in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 9 Oct 2008, 01:39 PM
  4. Using fractions for product quantities
    By kits1 in forum Templates, Stylesheets, Page Layout
    Replies: 10
    Last Post: 9 May 2008, 11:19 PM
  5. Mulitple Quantities for One Product
    By rcarlyle in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 23 Mar 2008, 07:24 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