Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / Restrictions for shipping / payment methods

Restrictions for shipping / payment methods

Locked

Views: 1,286

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
12 Oct 2009, 7:24 PM
#1
tundrasnake avatar

tundrasnake

New Zenner

Join Date:
May 2009
Posts:
7
Plugin Contributions:
0

Restrictions for shipping / payment methods

Hi guys, after a very long search i can't find the answer to this, and would really appreciate your help. I would like to have some restrictions to the available payment options, depending on the chosen shipping method.

For example: when COD is chosen as a shipping menthod, i would like the only available payment option to be COD.
If free shipping is chosen, i don't want COD to be available as a payment option (shipping cost applies to it).

I've got a new install of 1.3.8 - thank you for your time in advance.

12 Oct 2009, 7:33 PM
#2
ajeh avatar

ajeh

Oba-san

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

Re: Restrictions for shipping / payment methods

The Payment method can be checked with:
$_SESSION['payment']

The Shipping method can be checked with:
$_SESSION['shipping']['id']

You can use those to control the $this->enabled in the modules as to when they can or cannot display by setting the $this->enabled to true or false ...

NOTE: COD is a payment method not a shipping method ...

12 Oct 2009, 8:23 PM
#3
tundrasnake avatar

tundrasnake

New Zenner

Join Date:
May 2009
Posts:
7
Plugin Contributions:
0

Re: Restrictions for shipping / payment methods

Hi Ajeh thank you very much for the quick reply.

I'm afraid i need a lot more help than this. If i want to disable COD for freeshipper i guess i need to alter cod.php?
Could you please write the code for me and let me know in which line i should add it. Thank you very much.

12 Oct 2009, 10:38 PM
#4
ajeh avatar

ajeh

Oba-san

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

Re: Restrictions for shipping / payment methods

There lies a problem ...

The Free Shipping freeshipper is a shipping module that runs when a condition exists for shipping to be $0.00 such as Always Free Shipping or 0 weight, where 0 weight is defined as Free Shipping ...

Because of this, there isn't an easy way to disable Free Shipping freeshipper when the shipping is evaluated to be Free Shipping, just because the Payment Module is COD ...

Now you can, however, disable the COD option if the Free Shipping freeshipper has been selected ...

So, if the customer picks Free Shipping freeshipper from the checkout_shipping page, do you want the Payment Module COD to be disabled, or hidden?

13 Oct 2009, 5:38 AM
#5
tundrasnake avatar

tundrasnake

New Zenner

Join Date:
May 2009
Posts:
7
Plugin Contributions:
0

Re: Restrictions for shipping / payment methods

Hi Ajeh thank you for your reply again.

Let's forget freeshipper. Could you please tell me if the customer picks Flat or Freeoptions from the checkout_shipping page, how can i disabled or hide the Payment Module COD?

13 Oct 2009, 5:00 PM
#6
ajeh avatar

ajeh

Oba-san

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

Re: Restrictions for shipping / payment methods

To disable or hide the COD the payment module when Flat Rate flat is selected as the shipping method, you can change the function update_status in the file:
/includes/modules/payment/cod.php

to read:

// class methods
    function update_status() {
      global $order, $db;

      if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_COD_ZONE > 0) ) {
        $check_flag = false;
        $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_COD_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
        while (!$check->EOF) {
          if ($check->fields['zone_id'] < 1) {
            $check_flag = true;
            break;
          } elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
            $check_flag = true;
            break;
          }
          $check->MoveNext();
        }

        if ($check_flag == false) {
          $this->enabled = false;
        }
      }

// disable the module if the order only contains virtual products
      if ($this->enabled == true) {
        if ($order->content_type != 'physical') {
          $this->enabled = false;
        }
      }
// do not show COD when Flat Rate or Free Options is selected
if ($_SESSION['shipping']['id']  == 'flat_flat' || $_SESSION['shipping']['id']  == 'freeoptions_freeoptions') {
          $this->enabled = false;
          if ($_SESSION['payment'] == 'cod') {
            $_SESSION['payment'] = '';
          }
}

    }
13 Oct 2009, 6:41 PM
#7
tundrasnake avatar

tundrasnake

New Zenner

Join Date:
May 2009
Posts:
7
Plugin Contributions:
0

Re: Restrictions for shipping / payment methods

THANK YOU SO MUCH:clap::clap::clap::clap::clap:

13 Oct 2009, 7:54 PM
#8
ajeh avatar

ajeh

Oba-san

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

Re: Restrictions for shipping / payment methods

You are most welcome ... thanks for the update that this works for you ... :smile: