Zen Cart Logo
Forums / Managing Customers and Orders / Limitlimited order methods only for certain product or sub-categories

Limitlimited order methods only for certain product or sub-categories

Views: 1,059

Results 1 to 8 of 8
9 Dec 2012, 12:05 PM
#1
kobra8 avatar

kobra8

Zen Follower

Join Date:
Mar 2009
Location:
Serbia
Posts:
350
Plugin Contributions:
0

Limitlimited order methods only for certain product or sub-categories

Hi,
Can please some help, how to solve this problem?
Some products can not be ordered together but separately.

I have use onlu Money Order Module for completion of orders. And some product can't ordes together

I have thread
limitlimited shipped methods only with one categories
http://www.zen-cart.com/showthread.php?138712-limitlimited-shipped-methods-only-with-one-categories/page3

but that is for shipped methods, I don't use shipped methods only Money Order Module.

:blush:
Thanks

9 Dec 2012, 4:08 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Limitlimited order methods only for certain product or sub-categories

What is it that you really want to do on the situation?

Example: something like this code:

    // do not show if products from master_categories_id 3 and 39 are in the cart together
    global $cart;
    if (!IS_ADMIN_FLAG && ($_SESSION['cart']->in_cart_check('master_categories_id','3') > 0 && $_SESSION['cart']->in_cart_check('master_categories_id','39') > 0)) {
      $this->enabled = false;
    }

can be used to stop a payment or shipping module to prevent an order that contains Products from both categories_id 3 and 39 when the Products use the master_categories_id 3 and 39 ...

But, this allows the customer to enter the checkout ...

Are you really wanting to prevent that as well as post a message on the shopping_cart as to why the checkout is unavailable until the Products causing the issue are changed?

Are you really running an out dated Zen Cart for this shop? Or are you in the process of upgrading it?

9 Dec 2012, 6:54 PM
#3
kobra8 avatar

kobra8

Zen Follower

Join Date:
Mar 2009
Location:
Serbia
Posts:
350
Plugin Contributions:
0

Re: Limitlimited order methods only for certain product or sub-categories

Hi Ajeh, thanks on reply

I have product in master_categories and sub_categories that can not be ordered together in one order.

  1. Code that stop a payment module (Money Order Module) to prevent an order that contains Products from both categories_id 3 and 39
    Yes, that it would be a great situation to prevent that as well as post a message on the shopping_cart as to why the checkout is unavailable until the Products causing the issue are changed

  2. Yes, I run out dated Zen Cart for my shop 1.3.8.a.
    Becouse I have 15 plug in end if I update ZC I will run over the code and made a mess in the shop.

Thanks

9 Dec 2012, 7:35 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Limitlimited order methods only for certain product or sub-categories

First ... think out what happens on a checkout ...

1 Things added to cart

2 4 pages to test for this as a security
a. shopping cart
b. checkout_shipping
c. checkout payment
d. checkout_confirmation

Goal: Alert customer that checkout is not possible if true

If on shopping_cart, you want a message triggered ...

If on the checkout_ pages, you want to return to shopping cart and the message triggered ...

So there needs to be a shopping_cart content test that triggers on the 4 pages with 3 of the pages returning to the shopping_cart to display the message ...

For the 3 checkout pages, you can add to the header_php.php files the code in RED:

[B]// bof: invalid products together
  if (($_SESSION['cart']->in_cart_check('master_categories_id','3') > 0 && $_SESSION['cart']->in_cart_check('master_categories_id','39') > 0)) {
    $messageStack->add_session('header', 'Invalid Products together', 'error');
    zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
  }
// eof: invalid products together

[/B]// Stock Check

The shopping_cart header_php.php code is slightly different:

if (!$_SESSION['valid_to_checkout']) {
  $messageStack->add('shopping_cart', ERROR_CART_UPDATE . $_SESSION['cart_errors'] , 'caution');
}

[B]// bof: invalid products together
  if (($_SESSION['cart']->in_cart_check('master_categories_id','3') > 0 && $_SESSION['cart']->in_cart_check('master_categories_id','39') > 0)) {
    $messageStack->add('shopping_cart', 'Invalid Products together', 'error');
  }
// eof: invalid products together
[/B]

Now, how you want to explain this is up to you on the messageStack ...

You may even want to customize it further to mark the conflicting products similar to the out of stock flag, but you will need to do additional coding for the shopping_cart header_php.php and possibly the template to do so ...

10 Dec 2012, 9:18 AM
#5
kobra8 avatar

kobra8

Zen Follower

Join Date:
Mar 2009
Location:
Serbia
Posts:
350
Plugin Contributions:
0

Re: Limitlimited order methods only for certain product or sub-categories

Hi,
In shopping_cart, to a message triggered if put product that can not be ordered together in one order.
And that he could not continue to checkout_ pages

What code to put
header_php or shopping_cart ?

Explain this with messageStack. I think that's enough on the page shopping_cart to show message that products in the basket (shopping_cart) can not be ordered together but separately.

Thanks

10 Dec 2012, 2:23 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Limitlimited order methods only for certain product or sub-categories

If you look at the code that I posted, the first code goes in the 3 files:
/includes/modules/pages/checkout_shipping/header_php.php
/includes/modules/pages/checkout_payment/header_php.php
/includes/modules/pages/checkout_confirmation/header_php.php

above the line:

// Stock Check

For the file:
/includes/modules/pages/shopping_cart/header_php.php

the second code in RED goes below the code:

if (!$_SESSION['valid_to_checkout']) {
  $messageStack->add('shopping_cart', ERROR_CART_UPDATE . $_SESSION['cart_errors'] , 'caution');
}

The massageStack will display the message to the customer when they either add a Product that makes to the cart where there are Products from both categories_id 3 and 39 where the master_categories_id on the Products are using 3 and 39 and will display a message and return to the shopping_cart if they try to checkout ...

11 Dec 2012, 8:52 PM
#7
kobra8 avatar

kobra8

Zen Follower

Join Date:
Mar 2009
Location:
Serbia
Posts:
350
Plugin Contributions:
0

Re: Limitlimited order methods only for certain product or sub-categories

Works like a dream. Thanks Ajeh, you are awesome.

I wish you a happy new year and good health.

Kobra

12 Dec 2012, 1:05 AM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Limitlimited order methods only for certain product or sub-categories

You are most welcome ... thanks for the update that this was able to work for you ... :smile:

Have a great holiday!