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

    Default Constarints for product quantities?

    Hi all!
    I'm new to this forum. I'm setting up a shop with Zen cart 1.3.8. It's a wine related shop. The owner has some constraints on the number of products, because, for shipping reasons, 0,75 l bottles (classic wine bottles) must be sent in groups of 6. Now, he does not want to be able to sell only 6-bottle pack of the same wine, but the costumer must be able to buy differnt bottle of wine, while the sum of the number of 0,75 bottles must be a multiple of 6. He can also buy other kinds of products, but there are no constraints on those. Is it possible to add such a control during checkout? I mean, display an alert when the user sees the cart before checkout?

    Thank you very much for all you help!

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

    Default Re: Constarints for product quantities?

    I think Scott Wilson (swguy) has a Cart Validation technique to ensure that products in the cart are equal to a multiple of a given number (in your case "6"), before the customer can proceed to checkout.

    PM swguy.
    20 years a Zencart User

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

    Default Re: Constarints for product quantities?

    I would like some more informations about this, I think I can add something to extra_cart_actions, but I would like to know hot to forbid checkout if cart is not validated, I could'nt find a tutorial or some documentation on how to do this. Any help is appreciated.
    Thanks

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

    Default Re: Constarints for product quantities?

    I've managed to do somethng similar to what I want, well actually it does exactly what I wanted. It's pretty simple, I just need to modify the Get_products method of the shopping_cart class, but the problem is that in this way I modified core files, which will be obiouvsly replaced in caso of an update, wouldn't it be possible to do the same by simply adding some extension, without modifying zen cart files?

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

    Default Re: Constarints for product quantities?

    Tell us which files you modified, and how and what code you added, and we'll be able to see if there's over-ride potential...
    20 years a Zencart User

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

    Default Re: Constarints for product quantities?

    I modified the file /includes/classes/shopping_cart.php, but I would like to know how to do it without touching core files. I think I could do something with extra cart functions but I don't know how to do it. In that file I modified the get_products functions, setting valid = false if the check (ie product_number / 6 == 0) is false. But I don't know how to do the same without using this file. Also, doing this is ok, since it shows the checkout button but if I click it it send me again to the shopping cart, I would like to know how to hide it if the cart is not valid.

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

    Default Re: Constarints for product quantities?

    Although the class files are generally considered 'core' files, there is a way to override them using the auto_loader system, which does have an override capability.

    Take your modified shopping_cart class file for example.

    Make a copy of includes/auto_loaders/config.core.php and save it into the includes/auto_loaders/overrides/ folder.

    Now edit that new copy, and replace this code
    Code:
      $autoLoadConfig[0][] = array('autoType'=>'class',
                                    'loadFile'=>'shopping_cart.php');
    with this
    Code:
      $autoLoadConfig[0][] = array('autoType'=>'class',
                                    'loadFile'=>'my_shopping_cart.php');
    When you edit the file includes/classes/shopping_cart.php, save the edited file as includes/classes/my_shopping_cart.php and voila! you are now using an 'override' copy that won't get overwritten during an upgrade.

    I have used this technique for various class files that I've had reason to modify.
    Neville
    An assumption is what you arrive at when you get tired of thinking...

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

    Default Re: Constarints for product quantities?

    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.

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

    Default Re: Constarints for product quantities?

    See if you can "clone" Andrew Berezin's "Minimum Order" module. His module displays an alert ($messageStack) if the conditional is not met.

    In the case of Andrew's module, the store owner sets a minimum MONETARY value that must be in the shopping cart before it can proceed to checkout - let's say the shop owner says if the value of the order must total £10, he sets the value "10" in admin.

    If a shopper's cart is LESS than £10, the alert warning is displayed.

    I'm no PHP coder, so I wouldn't know what code to use to parse the item-count, but I'm sure this would be a piece of cake for a coder.

    Something like:

    PHP Code:
              if($_SESSION['cart']->count_contents() % CART_MULTIPLE_AMOUNT == 0) {
                
    $_SESSION['valid_to_checkout'] = false;
                
    $messageStack->add('shopping_cart'sprintf(TEXT_ORDER_NOT_A_MULTIPLE, (CART_MULTIPLE_AMOUNT)) . '<br />''caution'); 
    ... where I use the php modulus expression (%) rather than "/" (divided by) and CART_MULTIPLE_AMOUNT is the value the shop owner expresses in the database via the Admin Panel. In your case, 6 .

    As I say, I don't now how to parse the "count_contents" value...
    20 years a Zencart User

  10. #10
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Constarints for product quantities?

    [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.
    Last edited by gjh42; 12 Mar 2009 at 10:23 AM.

 

 
Page 1 of 3 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