Disable a shipping option or payment option during checkout

Fred <[email protected]>
Newsgroups gmane.comp.web.oscommerce.suggestions
Message-ID <f8f31ee97234f936d8700883a5e9588a@osCommerce-Forums>
This message was sent from: Suggestions and Proposals
http://forums.oscommerce.com/viewtopic.php?p=184746#184746
----------------------------------------------------------------

I have written a couple of shipping and payment modules to fit my needs and I have a proposal for the core team - a way to disable a shipping option or payment option during the checkout process with a message why the option is not enabled. 

I would like to "disable" some shipping and/or payment options depending on order value and order weight, etc. I found that it's easy to disable a shipping option in a shipping module by setting the 'error' field of the qoutes array in the function quote:

$this->quotes['error'] = MODULE_SHIPPING_PACKET_TOO_VALUABLE 

The file "checkout_shipping.php" is then displaying the message and the option is not able to select (i.e the radio box is not even printed). 

I had the same idea when implementing my payment module. This time I am setting the 'error' field of returning array in function selection:

'error' => MODULE_PAYMENT_COD_2_TEXT_MAX_VALUE

The message is displayed fine but the things is that it is still possible to select the payment option (due to that the radio box is printed). So I changed the logic in "checkout_payment.php" according to this (please note the if statement tagged with Fred):

[code]  $selection = $payment_modules->selection();

...

  $radio_buttons = 0;
  for ($i=0, $n=sizeof($selection); $i<$n; $i++) {
?>
...
<?php
    if (!isset($selection[$i]['error'])) { //Fred - added to be able to disable a payment module
      if (sizeof($selection) > 1) {
        echo tep_draw_radio_field('payment', $selection[$i]['id']);
      } else {
        echo tep_draw_hidden_field('payment', $selection[$i]['id']);
      }
    } //Fred - added to be able to disable a payment module
?>
...
?>[/code]

I know I can set $this->enabled = false in the update_status function, the only issue with this is that the payment option is not displayed and the user may not know why the option isn't there. 

What I am asking for is the some logic in both shipping and payment stage. 

/Fred
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.