Thank you, maybe using that module I'll be able to adapt it to my needs.
Thank you, both of you, for your help.
Thank you, maybe using that module I'll be able to adapt it to my needs.
Thank you, both of you, for your help.
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
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...
To add the new product type to your database, run this query from your SQL Patch page in admin:
sample function codes I've used for checking the product type: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( ));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)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; }
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...
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...
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!
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!