Forums / Built-in Shipping and Payment Modules / Restrict to add only one item in shopping cart

Restrict to add only one item in shopping cart

Locked

Views: 1,633

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
28 Apr 2010, 1:41 PM
#1
arunkarthik avatar

arunkarthik

New Zenner

Join Date:
Mar 2010
Location:
Ooty, India
Posts:
40
Plugin Contributions:
0

Restrict to add only one item in shopping cart

Hi,

I need to restrict the items added in shopping cart.

only one item should be added at a time!!

is there any fix?:unsure::unsure:

28 Apr 2010, 2:48 PM
#2
stevesh avatar

stevesh

Black Belt

Join Date:
Feb 2005
Location:
Lansing, Michigan USA
Posts:
19,793
Plugin Contributions:
2

Re: Restrict to add only one item in shopping cart

If you mean you only want your customers to be able to buy one item at a time (I'd be interested in the explanation for that), there's a mod here: http://www.zen-cart.com/index.php?main_page=product_contrib_info&products_id=1259 that limits the amount of an order. You might be able to adapt it (or use as is if all your products are the same price).

29 Apr 2010, 6:38 AM
#3
arunkarthik avatar

arunkarthik

New Zenner

Join Date:
Mar 2010
Location:
Ooty, India
Posts:
40
Plugin Contributions:
0

Re: Restrict to add only one item in shopping cart

Thanks For ur reply!! :smile:

Once when i fix it will update here ASAP!!!

29 Apr 2010, 8:36 AM
#4
arunkarthik avatar

arunkarthik

New Zenner

Join Date:
Mar 2010
Location:
Ooty, India
Posts:
40
Plugin Contributions:
0

Re: Restrict to add only one item in shopping cart

stevesh:

If you mean you only want your customers to be able to buy one item at a time (I'd be interested in the explanation for that), there's a mod here: http://www.zen-cart.com/index.php?main_page=product_contrib_info&products_id=1259 that limits the amount of an order. You might be able to adapt it (or use as is if all your products are the same price).

Your mod was to restrict the qty of items.

But my issue is to restrict no of products added...

for example, there are 3 prod A,B,C

The user must be able to checkout only product A.

If suppose he goes back and selects product B, it should not be added with prod A.

Instead only product B must be displayed.

Hope you got my issue!!

help needed!!

29 Apr 2010, 12:38 PM
#5
fairestcape avatar

fairestcape

Totally Zenned

Join Date:
Mar 2008
Location:
Cape Town & London (depends on the season)
Posts:
2,957
Plugin Contributions:
0

Re: Restrict to add only one item in shopping cart

arunkarthik:

Your mod was to restrict the qty of items.

But my issue is to restrict no of products added...

for example, there are 3 prod A,B,C

The user must be able to checkout only product A.

If suppose he goes back and selects product B, it should not be added with prod A.

Instead only product B must be displayed.

Hope you got my issue!!

help needed!!

I constructed that module, based on Andrew Berezin's excellent MINIMUM ORDER VALUE module.

While it might be possible to add more conditionals to that module, the format you are proposing may be quite a challenge.

PS: Please don't ask me to do it :D (I am very busy right now!)

And while I don't know why you are proposing to set these restrictions, it seems a sure fire way to me to drive customers AWAY from your business.

29 Apr 2010, 5:14 PM
#6
arunkarthik avatar

arunkarthik

New Zenner

Join Date:
Mar 2010
Location:
Ooty, India
Posts:
40
Plugin Contributions:
0

Re: Restrict to add only one item in shopping cart

fairestcape:

I constructed that module, based on Andrew Berezin's excellent MINIMUM ORDER VALUE module.

While it might be possible to add more conditionals to that module, the format you are proposing may be quite a challenge.

PS: Please don't ask me to do it :D (I am very busy right now!)

And while I don't know why you are proposing to set these restrictions, it seems a sure fire way to me to drive customers AWAY from your business.

Dude thanks for ur reply man!!!:hug:

by d way I'm not running this business!! I just work for ma client...

anyway will try this n let u know soon... :smile:

1 May 2010, 10:43 AM
#7
fairestcape avatar

fairestcape

Totally Zenned

Join Date:
Mar 2008
Location:
Cape Town & London (depends on the season)
Posts:
2,957
Plugin Contributions:
0

Re: Restrict to add only one item in shopping cart

if you download that module, look in the file called:

class.maximum_order_amount.php

You will see:-

  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 && MAX_ORDER_AMOUNT > 0) {
          if($_SESSION['cart']->show_total() > MAX_ORDER_AMOUNT) {
            $_SESSION['valid_to_checkout'] = false;
            $messageStack->add('shopping_cart', sprintf(TEXT_ORDER_OVER_MAX_AMOUNT, $currencies->format(MAX_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 && MAX_ORDER_AMOUNT > 0) {
          if($_SESSION['cart']->show_total() > MAX_ORDER_AMOUNT) {
            zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
          }
        }
        break;

Try doing this to the above section:

  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() != MAX_ORDER_AMOUNT) {
            $_SESSION['valid_to_checkout'] = false;
            $messageStack->add('shopping_cart', sprintf(TEXT_ORDER_OVER_MAX_AMOUNT, (MAX_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() !1) {
            zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
        }
        break;

In your admin configuration Maximum values, you will now set the Maximum Value Allowed to 1 .

You will also have to adjust your LANGUAGE DEFINES in that module, so that meaningful text appears in the alert messages, etc.

1 May 2010, 12:10 PM
#8
fairestcape avatar

fairestcape

Totally Zenned

Join Date:
Mar 2008
Location:
Cape Town &amp; London (depends on the season)
Posts:
2,957
Plugin Contributions:
0

Re: Restrict to add only one item in shopping cart

OOPS...

Small error:

Here's better code:

  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() != MAX_ORDER_AMOUNT) {
            $_SESSION['valid_to_checkout'] = false;
            $messageStack->add('shopping_cart', sprintf(TEXT_ORDER_OVER_MAX_AMOUNT, (MAX_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() != MAX_ORDER_AMOUNT) {
            zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
        }
        break;