Forums / Setting Up Categories, Products, Attributes / How to sell different products from same category?

How to sell different products from same category?

Locked

Views: 1,553

Results 1 to 7 of 7
This thread is locked. New replies are disabled.
12 May 2010, 3:38 PM
#1
aletiger avatar

aletiger

New Zenner

Join Date:
Apr 2010
Location:
Italy
Posts:
20
Plugin Contributions:
0

How to sell different products from same category?

I have a problem with my new store...I make an example to explain my needs!

Suppose that I want to sell wine bottles. I can ship only 6 bottles per box, but the bottles can be different.
So it is possible for the customer to buy 2 bottles of white wine and 4 bottles of red wine?

The only condition I must control is the fact that the customer will add 6 or multiple bottles of wine in the cart, it doesn't matter which kind of bottles.

It is possible to do that? I can create a single category called Wine and then set up the example above?

Thanks for any suggestion...:frusty:

12 May 2010, 8:16 PM
#2
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: How to sell different products from same category?

Something like I do HERE ?

The cart total HAS TO BE in multiples of 6.

Add some wine to the cart, say, 5 bottles, then try to check out.

You cannot check out unless you have 6, 12, 18, 24, 30, 36 (all multiples of 6) items in the cart.

One drawback is that you can ONLY have single bottles with my system. If you also have CASES, then the cart sees one CASE of wine as 1 item.

My system works by counting the total ITEMS in the cart, and that number MUST be divisible by 6.

20 years a Zencart User

17 May 2010, 4:00 PM
#3
aletiger avatar

aletiger

New Zenner

Join Date:
Apr 2010
Location:
Italy
Posts:
20
Plugin Contributions:
0

Re: How to sell different products from same category?

schoolboy:

Something like I do HERE ?

The cart total HAS TO BE in multiples of 6.

Add some wine to the cart, say, 5 bottles, then try to check out.

You cannot check out unless you have 6, 12, 18, 24, 30, 36 (all multiples of 6) items in the cart.

One drawback is that you can ONLY have single bottles with my system. If you also have CASES, then the cart sees one CASE of wine as 1 item.

My system works by counting the total ITEMS in the cart, and that number MUST be divisible by 6.

Exactly this, have you used a public mod or modified the original code for your needs?
It is possible to do that ONLY for a specific category?

I sell wine, but also other products that don't need to be sold in multiples.

22 May 2010, 1:00 PM
#4
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: How to sell different products from same category?

Aletiger:

I sell wine, but also other products that don't need to be sold in multiples.

... Then my method will not be suitable.

My method looks at the total quantity of items in the cart - it does not matter what these items are... There is no mechanism in my method to separate out wine bottles from any other items. If the cart ITEM total is not equal to a multiple of 6, then the customer cannot proceed to checkout.

It would require a LOT of additional code writing to get the cart to consider ONLY wine bottles for this qty restriction, and I don't believe that my core code will achieve this.

If it helps however. the base module I used is Andrew Berezin's MINIMUM ORDER.

I just altered the algorithm slightly so that instead of using GREATER THAN as the condition, I used MODULUS (http://php.net/manual/en/language.operators.arithmetic.php), where the value of the key operand is read off the database - just as it is in andrew's module.

20 years a Zencart User

22 May 2010, 1:05 PM
#5
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: How to sell different products from same category?

Thev FILE to look at in Andrew's module is:

class.multiple_order_amount.php.

Open HIS version of that file and compare it with MY version below.

(In PHP the MODULUS function is expressed as a % sign)

See if you can see where my alterations are !

<?php
/**
 * class.multiple_order_amount.php
 *
 * @copyright Copyright 2009 Schoolboy (Zencart Forum User)
 * @copyright Portions Copyright 2005-2007 Andrew Berezin eCommerce-Service.com
 * @copyright Portions Copyright 2003-2006 Zen Cart Development Team
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: config.multiple_order_amount.php 1.0 02.02.2009 18:00 Schoolboy $
 */

/**
 * Observer class used to check if cart total items is a multiple of a stated value
 *
 */
class multiple_order_amount extends base {
  /**
   * constructor method
   *
   * Attaches our class to the ... and watches for 4 notifier events.
   */
  function multiple_order_amount() {
    global $zco_notifier;
//      $_SESSION['cart']->attach($this, array('NOTIFIER_CART_GET_PRODUCTS_START', 'NOTIFIER_CART_GET_PRODUCTS_END'));
    $zco_notifier->attach($this, array('NOTIFY_HEADER_END_SHOPPING_CART', 'NOTIFY_HEADER_START_CHECKOUT_SHIPPING', 'NOTIFY_HEADER_START_CHECKOUT_PAYMENT', 'NOTIFY_HEADER_START_CHECKOUT_CONFIRMATION'));
  }
  /**
   * Update Method
   *
   * Called by observed class when any of our notifiable events occur
   *
   * @param object $class
   * @param string $eventID
   */
  function update(&$class, $eventID) {
    global $messageStack;
    global $currencies;
    switch ($eventID) {
      case 'NOTIFIER_CART_GET_PRODUCTS_END':
      case 'NOTIFY_HEADER_END_SHOPPING_CART':
        if ($_SESSION['cart']->count_contents() > 0 && MULT_ORDER_AMOUNT > 0) {
          if(($_SESSION['cart']->count_contents() % (MULT_ORDER_AMOUNT)) != 0) {
            $_SESSION['valid_to_checkout'] = false;
            $messageStack->add('shopping_cart', sprintf(TEXT_ORDER_OVER_MULT_AMOUNT, (MULT_ORDER_AMOUNT)) . '<br />', 'caution');
          }
        }
        break;
      case 'NOTIFY_HEADER_START_CHECKOUT_SHIPPING':
      case 'NOTIFY_HEADER_START_CHECKOUT_PAYMENT':
      case 'NOTIFY_HEADER_START_CHECKOUT_CONFIRMATION':
        if ($_SESSION['cart']->count_contents() > 0 && MULT_ORDER_AMOUNT > 0) {
          if(($_SESSION['cart']->count_contents() % (MULT_ORDER_AMOUNT)) != 0) {
            zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
          }
        }
        break;
      default:
        break;
    }
  }
}
?>

20 years a Zencart User

23 May 2010, 9:46 AM
#6
aletiger avatar

aletiger

New Zenner

Join Date:
Apr 2010
Location:
Italy
Posts:
20
Plugin Contributions:
0

Re: How to sell different products from same category?

Thanks,
I understood well your method and I found it very interesting.
I think that it will be possibile for me to modify the algorithm to filter the categories I need before doing the MODULUS operation.

In next days I will give you a try!

Thanks,
Ale

23 May 2010, 8:30 PM
#7
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: How to sell different products from same category?

Just to help you a bit more, let me unpick the important parts of this section:

        if ($_SESSION['cart']->count_contents() > 0 && MULT_ORDER_AMOUNT > 0) {
          if(($_SESSION['cart']->count_contents() % (MULT_ORDER_AMOUNT)) != 0) {
            $_SESSION['valid_to_checkout'] = false;
            $messageStack->add('shopping_cart', sprintf(TEXT_ORDER_OVER_MULT_AMOUNT, (MULT_ORDER_AMOUNT)) . '<br />', 'caution');
    ```php

if ($_SESSION['cart']->count_contents() > 0 && MULT_ORDER_AMOUNT > 0)

If the cart item total is greater than ZERO, ***and*** the value specified in the Multiple Order Field is greater than zero, then this condition is active.
-------------------------------------------------------------

```php
          if(($_SESSION['cart']->count_contents() % (MULT_ORDER_AMOUNT)) != 0)

If the MODULUS of the Multiple Order amount is NOT EQUAL to zero, then don't allow checkout, and show an alert. (You obviously know that MODULUS of a number is the REMAINDER left over after a division operation.

EG: 25 divided by 6 = 4 remainder 1

1 is NOT EQUAL to zero, so it's stop the prodecure to checkout.

Only when a remainder IS zero, will checkout be allowed.

20 years a Zencart User