Results 1 to 8 of 8
  1. #1
    Join Date
    May 2009
    Posts
    7
    Plugin Contributions
    0

    Default 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.

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default 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 ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  3. #3
    Join Date
    May 2009
    Posts
    7
    Plugin Contributions
    0

    Default 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.

  4. #4
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default 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?
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  5. #5
    Join Date
    May 2009
    Posts
    7
    Plugin Contributions
    0

    Default 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?

  6. #6
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default 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:
    Code:
    // 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'] = '';
              }
    }
    
        }
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  7. #7
    Join Date
    May 2009
    Posts
    7
    Plugin Contributions
    0

    Default Re: Restrictions for shipping / payment methods

    THANK YOU SO MUCH

  8. #8
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Restrictions for shipping / payment methods

    You are most welcome ... thanks for the update that this works for you ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

 

 

Similar Threads

  1. Replies: 6
    Last Post: 16 Jul 2015, 04:29 AM
  2. Skip Shipping and Payment Methods
    By thatstevensguy in forum Customization from the Admin
    Replies: 2
    Last Post: 3 Oct 2011, 02:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg