Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / COD for only one shipper?

COD for only one shipper?

Locked

Views: 3,236

Results 1 to 17 of 17
This thread is locked. New replies are disabled.
19 May 2007, 6:35 PM
#1
tat2nu avatar

tat2nu

Zen Follower

Join Date:
Jan 2005
Posts:
178
Plugin Contributions:
0

COD for only one shipper?

I have had a lot of problems with USPS accepting bad checks on my COD packages so I only want to offer COD with UPS because I can specify "money order only". For now I have the USPS COD rate at $1000.00 just so people will not use it but that doesn't look very professional so I would like to eliminate the COD option for USPS completely. I am currently using version 1.2.6 live but I am also building a fresh site with 1.3.7 so a solution that would work for both would be great.

Sincere thanks,
Marc
https://www.needlejig.com

19 May 2007, 7:09 PM
#2
ajeh avatar

ajeh

Oba-san

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

Re: COD for only one shipper?

This can be done by editing the COD module:
/includes/modules/payment/cod.php

Find this code:

// disable the module if the order only contains virtual products
      if ($this->enabled == true) {
        if ($order->content_type != 'physical') {
          $this->enabled = false;
        }
      }

Change to this code:

// turn off COD for USPS Shipping
        if (substr_count($_SESSION['shipping']['id'], 'ups') == 1) {
          $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;
        }
      }
19 May 2007, 7:10 PM
#3
ajeh avatar

ajeh

Oba-san

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

Re: COD for only one shipper?

er ... might change ups to usps ... :blush:

I was testing other things ... :cool:

19 May 2007, 9:29 PM
#4
tat2nu avatar

tat2nu

Zen Follower

Join Date:
Jan 2005
Posts:
178
Plugin Contributions:
0

Re: COD for only one shipper?

Thanks Ajeh, It works perfect if I modify

/includes/modules/payment/cod.php

but if I try and use an override folder like

/includes/modules/payment/custom/cod.php

it does not work?

Can you explain why? I would rather not have to modify the cod.php at every upgrade if I do not have to.

Thanks again,
Marc

20 May 2007, 3:27 AM
#5
ajeh avatar

ajeh

Oba-san

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

Re: COD for only one shipper?

There are no overrides directories for the Shipping, Payment and Order Totals at this time ...

We would have to start drinking if there were ... very very early in the day ... :eek:

20 May 2007, 6:15 AM
#6
tat2nu avatar

tat2nu

Zen Follower

Join Date:
Jan 2005
Posts:
178
Plugin Contributions:
0

Re: COD for only one shipper?

Ok, I will just have to note those changes so that I can make them on any future upgrades. Thanks once again for all of your help.

Marc

9 Jun 2007, 6:54 AM
#7
ronwong avatar

ronwong

Zen Follower

Join Date:
Jan 2006
Posts:
223
Plugin Contributions:
0

Re: COD for only one shipper?

Hi, I am trying to do the same for table rate.

But it does not seem to work.

The code:

// turn off COD for USPS Shipping
if (substr_count($_SESSION['shipping']['id'], 'table') == 1) {
$this->enabled = false;
}

is the 'shipping' and 'id' be as it is shown above or changed to something else? What is this 'id'?

14 Jun 2007, 1:40 PM
#8
ronwong avatar

ronwong

Zen Follower

Join Date:
Jan 2006
Posts:
223
Plugin Contributions:
0

Re: COD for only one shipper?

any help on this? basically I want it such that if customer choose 'table' shipping, COD will not appear, so they have to pay by bank transfer etc.

my exact codes are:

// turn off COD for table
if (substr_count($_SESSION['shipping']['id'], 'table') == 1) {
$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;
}
}
}

18 Jun 2007, 2:29 AM
#9
ajeh avatar

ajeh

Oba-san

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

Re: COD for only one shipper?

The Table Rate has the $_SESSION['shipping']['id'] of table_table ... vs the USPS or UPS setting of usps_something and ups_something ...

So you need to use:

// turn off COD for Table Rate Shipping
        if (substr_count($_SESSION['shipping']['id'], 'table') == 2) {
          $this->enabled = false;
        }
7 Aug 2007, 11:26 AM
#10
100asa avatar

100asa

Totally Zenned

Join Date:
Oct 2006
Location:
Italy
Posts:
636
Plugin Contributions:
0

Re: COD for only one shipper?

I'm sorry, I don't understand... I want enable cod only for "zone"
where I see the number of shipping ?

'shipping']['id'], 'table') == 2)

7 Aug 2007, 12:44 PM
#11
100asa avatar

100asa

Totally Zenned

Join Date:
Oct 2006
Location:
Italy
Posts:
636
Plugin Contributions:
0

Re: COD for only one shipper?

I've solved with
if (substr_count($_SESSION['shipping']['id'], 'assegnato') == true) {
$this->enabled = false;
}

and now work fine.

7 Aug 2007, 1:58 PM
#12
ajeh avatar

ajeh

Oba-san

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

Re: COD for only one shipper?

substr_count means how many times does the word appear ...

true means 1 which may appear to work but is incorrect ... try 1 and see if that works for this assegnato method ...

29 Dec 2007, 3:37 PM
#13
bobtabin avatar

bobtabin

New Zenner

Join Date:
Dec 2007
Posts:
15
Plugin Contributions:
0

Re: COD for only one shipper?

I would like to enable COD for certain customers. How would I detect the customer within the COD table? I might have to extend the customer table to include a COD value. Any suggestions?

Thanks!

29 Dec 2007, 4:01 PM
#14
ajeh avatar

ajeh

Oba-san

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

Re: COD for only one shipper?

Hate when I write this whole thing up then hit the wrong key and lose it all ... :blink:

In brief, add a new field customers_cod int 1 to customers table ...

Add control in /admin/customers.php for this field ...

Where the login sets the $_SESSION['customer_id'] you can get and set the $_SESSION['customer_cod'] and use that to test if the COD can show or not ...

Easy Smeazy, eh? :cool:

30 Dec 2007, 2:37 AM
#15
bobtabin avatar

bobtabin

New Zenner

Join Date:
Dec 2007
Posts:
15
Plugin Contributions:
0

Re: COD for only one shipper?

Thanks! Below is the approach I took after reading your suggestions. One question, if I wanted to create a VIPCOD payment module by duplicating the cod.php file into a vipcod.php file, what do I need to modify within the vipcod.php (and any other files) in other for the additional payment module to be recongnized by Zen Cart admin? Here's my code:

VIPCOD - Done in Zen Cart 1.3.8a:

  1. Modified the customers table and added int(1) (default=0) field named customers_cod

  2. Modified: /public_html/store/includes/modules/pages/login/header_php.php

    Replaced:

    $check_customer_query = "SELECT customers_id, customers_firstname, customers_lastname, customers_password,
    customers_email_address, customers_default_address_id,
    customers_authorization, customers_referral
    FROM " . TABLE_CUSTOMERS . "
    WHERE customers_email_address = :emailAddress";

    With:

    $check_customer_query = "SELECT customers_id, customers_firstname, customers_lastname, customers_password,
    customers_email_address, customers_default_address_id,
    customers_authorization, customers_referral, customers_cod
    FROM " . TABLE_CUSTOMERS . "
    WHERE customers_email_address = :emailAddress";

    Added:

     $_SESSION['customer_cod'] = $check_customer->fields['customers_cod'];
    

    After:

     $_SESSION['customer_zone_id'] = $check_country->fields['entry_zone_id'];
    
  3. Modified: /public_html/store/includes/modules/payment/cod.php

    Added:

    //--------------------------------------------------------------------------------
    // MODDED - BT 12-29-2007 - Only customers that do not have the default 0 in the
    // custom customers_cod field in the customers table are allowed to pay COD
    if ($_SESSION['customer_cod'] == 0) $this->enabled = false;
    //--------------------------------------------------------------------------------

    After:

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

  4. Now, only customers with customers_cod = 1 (or any value other than 0) will have COD available to them.

NOTE: This value is loaded as a SESSION variable only during logon. Therefore, if a customer is currently
logged on, they must log off and then back on for the value to be re-read into memory.

Bob Tabin
12-29-2007

30 Dec 2007, 4:29 AM
#16
bobtabin avatar

bobtabin

New Zenner

Join Date:
Dec 2007
Posts:
15
Plugin Contributions:
0

Re: COD for only one shipper?

I created a Contribution for my basic VIPCOD payment module. I appreciate everyone's assistance!

Future enhancements could include editing the customers_cod value via the Admin page (instead via the DB directly) and support for the vipcod.php code to read the database customers_cod directly so that it can read updates read-time.

Bob Tabin