Forums / Addon Payment Modules / Enable only certain payment/shipping methods for wholesale/retail customers

Enable only certain payment/shipping methods for wholesale/retail customers

Views: 1,873

Results 1 to 7 of 7
21 May 2015, 4:42 AM
#1
bislewl avatar

bislewl

Totally Zenned

Join Date:
Dec 2011
Location:
Wisconsin, USA
Posts:
674
Plugin Contributions:
12

Enable only certain payment/shipping methods for wholesale/retail customers

Received this via PM (please always ask questions in the forum so everyone can benefit):

PM_SENDER:

Hi,

I'm about to install Dual Pricing on zen cart store to have one group of retail customers and one group of wholesalers with different product prices..

The problem is that I'd like to offer only some shipping options and payments options to wholesalers.
In this thread https://www.zen-cart.com/showthread.php?214123-Dual-Pricing-V1-8-separate-shipping-rates-for-wholesale-retail-other-questions

I see that you have an add-on for table shipping module.
I'd like to modify other modules (and payment modules) adding to them some code to run a check at the beginning based on the fact that $_SESSION['customer_whole'] is 0 for customers and 1 for wholesalers in Dual Pricing.

The problem is that I'd not know how to set that check.
Could you please help me with the code?

Thank you very much,
PM_SENDER

The way I would do this would be to modify the includes/modules/payment/ or includes/modules/shipping/ files.

I'll use money order payment method for the example:

Change something like:

$this->enabled = ((MODULE_PAYMENT_MONEYORDER_STATUS == 'True') ? true : false);

if enabling for wholesale customers ONLY:

$this->enabled = ((MODULE_PAYMENT_MONEYORDER_STATUS == 'True' && $_SESSION['customer_whole'] == 1) ? true : false);

or for retail ONLY:

$this->enabled = ((MODULE_PAYMENT_MONEYORDER_STATUS == 'True' && $_SESSION['customer_whole'] != 1) ? true : false);

NOTE how it is != 1 versus == 0

24 May 2015, 12:17 AM
#2
ilmarchez avatar

ilmarchez

Zen Follower

Join Date:
Aug 2009
Posts:
128
Plugin Contributions:
0

Re: Enable only certain payment/shipping methods for wholesale/retail customers

Hi, thank you very much for your help!
I'm having some issues implementing your solution with freeoptions shipping module.

In fact, if I change the PHP code:

if (zen_get_shipping_enabled($this->code)) {
          $this->enabled = ((MODULE_SHIPPING_FREEOPTIONS_STATUS == 'True') ? true : false);

to this:

      if (zen_get_shipping_enabled($this->code)) {
          $this->enabled = ((MODULE_SHIPPING_FREEOPTIONS_STATUS == 'True' && $_SESSION['customer_whole'] != 1) ? true : false);

Thoe module is never displayed to any type of customer and in addition, it is not showed in the admin>modules>shipping
What is wrong?

Thank you

24 May 2015, 12:40 AM
#3
ilmarchez avatar

ilmarchez

Zen Follower

Join Date:
Aug 2009
Posts:
128
Plugin Contributions:
0

Re: Enable only certain payment/shipping methods for wholesale/retail customers

Hi, I fixed it moving position of the statement. Thank you.

8 Jul 2015, 10:01 PM
#4
ilmarchez avatar

ilmarchez

Zen Follower

Join Date:
Aug 2009
Posts:
128
Plugin Contributions:
0

Re: Enable only certain payment/shipping methods for wholesale/retail customers

Hi,

I'd like to set a minimum order value to proceed checkout (let's say $200) only for wholesaler, not for regular customers.
I think that your code already used for shipping methods would be a starting point for this.

Do you have any idea of the code and where to put it?
The need is to either don't show any checkout button or whatever is easier to wholesalers whose order is less than $200.

Thank you very much for your help.

bislewl:

Received this via PM (please always ask questions in the forum so everyone can benefit):

The way I would do this would be to modify the includes/modules/payment/ or includes/modules/shipping/ files.

I'll use money order payment method for the example:

Change something like:

$this->enabled = ((MODULE_PAYMENT_MONEYORDER_STATUS == 'True') ? true : false);

> 
> if enabling for wholesale customers ONLY:
> ```php
$this->enabled = ((MODULE_PAYMENT_MONEYORDER_STATUS == 'True' && $_SESSION['customer_whole'] == 1) ? true : false);

or for retail ONLY:

$this->enabled = ((MODULE_PAYMENT_MONEYORDER_STATUS == 'True' && $_SESSION['customer_whole'] != 1) ? true : false);

> 
> **NOTE how it is != 1 versus == 0**
9 Jul 2015, 1:59 AM
#5
bislewl avatar

bislewl

Totally Zenned

Join Date:
Dec 2011
Location:
Wisconsin, USA
Posts:
674
Plugin Contributions:
12

Re: Enable only certain payment/shipping methods for wholesale/retail customers

ilmarchez:

Hi,

I'd like to set a minimum order value to proceed checkout (let's say $200) only for wholesaler, not for regular customers.
I think that your code already used for shipping methods would be a starting point for this.

Do you have any idea of the code and where to put it?
The need is to either don't show any checkout button or whatever is easier to wholesalers whose order is less than $200.

Thank you very much for your help.

You can use this module and then modify for wholesale
https://www.zen-cart.com/downloads.php?do=file&id=402

9 Jul 2015, 10:00 AM
#6
ilmarchez avatar

ilmarchez

Zen Follower

Join Date:
Aug 2009
Posts:
128
Plugin Contributions:
0

Re: Enable only certain payment/shipping methods for wholesale/retail customers

Thank you. How should I modify the code of the module to have it applying the minimum order condition only to wholesale?

Thanks again for all.

bislewl:

You can use this module and then modify for wholesale
https://www.zen-cart.com/downloads.php?do=file&id=402

16 Jul 2015, 3:29 AM
#7
bislewl avatar

bislewl

Totally Zenned

Join Date:
Dec 2011
Location:
Wisconsin, USA
Posts:
674
Plugin Contributions:
12

Re: Enable only certain payment/shipping methods for wholesale/retail customers

ilmarchez:

Thank you. How should I modify the code of the module to have it applying the minimum order condition only to wholesale?

Thanks again for all.

Change lines like these:

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

to

if ($_SESSION['cart']->count_contents() > 0 && MIN_FIRST_ORDER_AMOUNT > 0 && $_SESSION['customer_whole'] == 1) {

and

if($_SESSION['cart']->show_total() < MIN_FIRST_ORDER_AMOUNT) {

to

if($_SESSION['cart']->show_total() < MIN_FIRST_ORDER_AMOUNT && $_SESSION['customer_whole'] == 1) {

That should only flag orders that are wholesale... where $_SESSION['customer_whole'] == 1