Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

How to delete 1 method of payment in only 1 shipping method?


6 replies to this topic

#1 uglukha

  • Community Member
  • 9 posts
  • Real Name:Ugluk
  • Gender:Male
  • Location:Warsaw, Poland

Posted 01 December 2009, 15:16

Hello,
I have few shipping methods in oscommerce shop. After you choose shipping method, u choose payment method. I have setup few payment methods, everything works fine.

But I would like to setup in 1 of the shiping methods available only 1 payment method. How to achieve that? For all shipping methods there are available all payment methods, and I can't find anything in admin panel to change it.

In other words, this how it looks now:
Shipping method 1 -> Payment method 1 or 2
Shipping method 2 -> Payment method 1 or 2


and i would love to see this:
Shipping method 1 -> Payment method 1 or 2
Shipping method 2 -> Payment method 1 (only 1)


any help appreciated,
thx,
kind regards
             _       _    _           
            | |     | |  | |          
 _   _  __ _| |_   _| | _| |__   __ _ 
| | | |/ _` | | | | | |/ / '_ \ / _` |
| |_| | (_| | | |_| |   <| | | | (_| |
 \__,_|\__, |_|\__,_|_|\_\_| |_|\__,_|
        __/ |                         
       |___/  

#2 berkedam

  • Community Member
  • 885 posts
  • Real Name:john
  • Gender:Male

Posted 01 December 2009, 22:07

You try this contribution: http://addons.oscommerce.com/info/1042
The one from 4 Jan 2007 might do the job it's working for me
(i don't know the more recent one)
"If you're working on something new, then you are necessarily an amateur."

#3 burt

  • Community Sponsor
  • 6,967 posts
  • Real Name:G Burton
  • Gender:Male
  • Location:UK/DEV/on

Posted 01 December 2009, 22:24

Each method of shipping has it's own ID. For example, "Per Item" is item_item.
So, find the ID that you need to use as the exclude, then add the following code to the payment module that you wish to stop working if that ID is being used:

if ($shipping['id'] == 'XXX') $this->enabled = false;

Add that before the last } in the update_status() function. Also add $shipping to the global scope of the same function.

As an example, if I wanted to stop using the payment module cc.php IF "per item" shipping is used, the function would be changed FROM this:

function update_status() {
      global $order;

      if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_CC_ZONE > 0) ) {
        $check_flag = false;
        $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_CC_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");
        while ($check = tep_db_fetch_array($check_query)) {
          if ($check['zone_id'] < 1) {
            $check_flag = true;
            break;
          } elseif ($check['zone_id'] == $order->billing['zone_id']) {
            $check_flag = true;
            break;
          }
        }

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

TO this:

function update_status() {
      global $order, $shipping;

      if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_CC_ZONE > 0) ) {
        $check_flag = false;
        $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_CC_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");
        while ($check = tep_db_fetch_array($check_query)) {
          if ($check['zone_id'] < 1) {
            $check_flag = true;
            break;
          } elseif ($check['zone_id'] == $order->billing['zone_id']) {
            $check_flag = true;
            break;
          }
        }

        if ($check_flag == false) {
          $this->enabled = false;
        }
      }      
      if ($shipping['id'] == 'item_item') $this->enabled = false;
    }

The Dirty Little Secrets that no osCommerce template sellers want you to know...revealed...

Support is commercially available. The question is whether you value your business
highly enough to spend money on it.

For commercial support from known developers who support osCommerce
ethos, please post at http://forums.oscommerce.com/forum/79-commercial-support/

#4 uglukha

  • Community Member
  • 9 posts
  • Real Name:Ugluk
  • Gender:Male
  • Location:Warsaw, Poland

Posted 02 December 2009, 09:40

hello,
big thx for help!

@burt,
i tried ur way to do it, but there was no effect at all, I made those 2 changes in file, and was no errors, but still both payments was available... maybe I wrote wrong "id".

is "id" defined in shipping method php file? in my example it was pickup.php - " $this->code = 'pickup'; " ?


@berkedam
thx, this contribution works perfect :)

Thx guys for help!
Cheers!
             _       _    _           
            | |     | |  | |          
 _   _  __ _| |_   _| | _| |__   __ _ 
| | | |/ _` | | | | | |/ / '_ \ / _` |
| |_| | (_| | | |_| |   <| | | | (_| |
 \__,_|\__, |_|\__,_|_|\_\_| |_|\__,_|
        __/ |                         
       |___/  

#5 burt

  • Community Sponsor
  • 6,967 posts
  • Real Name:G Burton
  • Gender:Male
  • Location:UK/DEV/on

Posted 02 December 2009, 09:58

Would probably have been pickup_pickup in that case.
You could have checked by echoing the $shipping['id'] on the checkout_payment page.
The Dirty Little Secrets that no osCommerce template sellers want you to know...revealed...

Support is commercially available. The question is whether you value your business
highly enough to spend money on it.

For commercial support from known developers who support osCommerce
ethos, please post at http://forums.oscommerce.com/forum/79-commercial-support/

#6 berkedam

  • Community Member
  • 885 posts
  • Real Name:john
  • Gender:Male

Posted 02 December 2009, 12:21

Hi Gary,

still think that 1042 where changes can be made in /admin/ is easier
"If you're working on something new, then you are necessarily an amateur."

#7 burt

  • Community Sponsor
  • 6,967 posts
  • Real Name:G Burton
  • Gender:Male
  • Location:UK/DEV/on

Posted 02 December 2009, 13:22

Hi John

Quite possible - but I always advise anyone to not install anyone elses contribution when all that's really needed is one line of code.

Cheers, Gary
The Dirty Little Secrets that no osCommerce template sellers want you to know...revealed...

Support is commercially available. The question is whether you value your business
highly enough to spend money on it.

For commercial support from known developers who support osCommerce
ethos, please post at http://forums.oscommerce.com/forum/79-commercial-support/