Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Payement module


Dreadlord

Recommended Posts

how can I exclude One country for a module payement

 

let say that I want all my customer world wide to be able to pay with Money Order but that I don't want this option to be available in France

 

how shall I do?

 

thanx much in advance for your most welcomed help.. I can't find any direction to exclude a country

 

best regards

 

Greg

Link to comment
Share on other sites

Yes, it can be done with some modifications in checkout_payment.php.

 

I have already done this job for one of my clients, but i am not on my system now, so can't give the exact code. You may PM me so that I will send you the code whenever I will be back.

Link to comment
Share on other sites

Modify /catalog/checkout_payment.php as follows:

 

Find the following line:

 

$selection = $payment_modules->selection();

 

Add just after it the following lines:

 

  $address_query = tep_db_query("select entry_country_id as country_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . $customer_id . "' and address_book_id = '" . $billto . "'");

    $address = tep_db_fetch_array($address_query);

    $country = tep_get_country_name($address['country_id']);

 

Find the following:

 

$radio_buttons = 0;

  for ($i=0, $n=sizeof($selection); $i<$n; $i++) {

?>

              <tr>

                <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

                <td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2">

<?php

    if ( ($selection[$i]['id'] == $payment) || ($n == 1) ) {

      echo '                  <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";

    } else {

      echo '                  <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";

    }

?>

                    <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

                    <td class="main" colspan="3"><b><?php echo $selection[$i]['module']; ?></b></td>

                    <td class="main" align="right">

<?php

    if (sizeof($selection) > 1) {

      echo tep_draw_radio_field('payment', $selection[$i]['id']);

    } else {

      echo tep_draw_hidden_field('payment', $selection[$i]['id']);

    }

?>

                    </td>

                    <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

                  </tr>

<?php

    if (isset($selection[$i]['error'])) {

?>

                  <tr>

                    <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

                    <td class="main" colspan="4"><?php echo $selection[$i]['error']; ?></td>

                    <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

                  </tr>

<?php

    } elseif (isset($selection[$i]['fields']) && is_array($selection[$i]['fields'])) {

?>

                  <tr>

                    <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

                    <td colspan="4"><table border="0" cellspacing="0" cellpadding="2">

<?php

      for ($j=0, $n2=sizeof($selection[$i]['fields']); $j<$n2; $j++) {

?>

                      <tr>

                        <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

                        <td class="main"><?php echo $selection[$i]['fields'][$j]['title']; ?></td>

                        <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

                        <td class="main"><?php echo $selection[$i]['fields'][$j]['field']; ?></td>

                        <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

                      </tr>

<?php

      }

?>

                    </table></td>

                    <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

                  </tr>

<?php

    }

?>

                </table></td>

                <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

              </tr>

<?php

    $radio_buttons++;

  }

?>

 

 

Replace with:

 

$radio_buttons = 0;

  for ($i=0, $n=sizeof($selection); $i<$n; $i++) {

 

          $display ='1';

          $pay_method = $selection[$i]['id'];

          if (eregi($country, 'France') && $pay_method == 'moneyorder'){

          $display = '0';

            }

 

  if ($display == '1') {

?>

              <tr>

                <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

                <td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2">

<?php

    if ( ($selection[$i]['id'] == $payment) || ($n == 1) ) {

      echo '                  <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";

    } else {

      echo '                  <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";

    }

?>

                    <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

                    <td class="main" colspan="3"><b><?php echo $selection[$i]['module']; ?></b></td>

                    <td class="main" align="right">

<?php

    if (sizeof($selection) > 1) {

      echo tep_draw_radio_field('payment', $selection[$i]['id']);

    } else {

      echo tep_draw_hidden_field('payment', $selection[$i]['id']);

    }

?>

                    </td>

                    <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

                  </tr>

<?php

    if (isset($selection[$i]['error'])) {

?>

                  <tr>

                    <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

                    <td class="main" colspan="4"><?php echo $selection[$i]['error']; ?></td>

                    <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

                  </tr>

<?php

    } elseif (isset($selection[$i]['fields']) && is_array($selection[$i]['fields'])) {

?>

                  <tr>

                    <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

                    <td colspan="4"><table border="0" cellspacing="0" cellpadding="2">

<?php

      for ($j=0, $n2=sizeof($selection[$i]['fields']); $j<$n2; $j++) {

?>

                      <tr>

                        <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

                        <td class="main"><?php echo $selection[$i]['fields'][$j]['title']; ?></td>

                        <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

                        <td class="main"><?php echo $selection[$i]['fields'][$j]['field']; ?></td>

                        <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

                      </tr>

<?php

      }

?>

                    </table></td>

                    <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

                  </tr>

<?php

    }

?>

                </table></td>

                <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

              </tr>

<?php

    }

  $radio_buttons++;

  }

?>

 

Make a backup of your file before modifications.

Link to comment
Share on other sites

Kavita

 

I have now swapped the code, how can I now set a country to be exclude from one payement module?

 

for example I don't want COD to be avaialble to Belgium but available to all other countries

 

 

thanx much in advance

 

 

 

Greg

Link to comment
Share on other sites

within above code in checkout_payment.php you may add on your conditions to display the payment options:

 

Like:

 

if (eregi($country, 'France') && $pay_method == 'moneyorder'){

          $display = '0';

            }

 

The above lines disable the display of moneyorder option if the country is France. Similarly you can add the following lines below it so that COD is disabled if the country is Belgium.:

 

if (eregi($country, 'Belgium') && $pay_method == 'cod'){

          $display = '0';

            }

 

Hope it helps!

Link to comment
Share on other sites

let me again explain how to write theses lines:

 

if (eregi($country, 'countryname') && $pay_method == 'payment code'){

          $display = '0';

            }

 

countryname is the name of country to be excluded and payment code is the code of payment module written in corresponding payment module file like for COD module, in /catalog/includes/modules/payment/cod.php the code is defined in

 

$this->code = 'cod';
Link to comment
Share on other sites

First of all thanx very much for you kindly help.. it works like a charm ..

 

you really save me on this one..

 

I have try to do the same for the shipping module.. but it does not work the same or I'm no skilled enough to see where I should put the if country statement.. on the shipping page (no prob for the query but don'(t know where to put the if statement)

 

let say that I wantevery customers to be charged with a flat rate but have free shipping for the french?

 

 

if you have any tips, I would be a taker

 

thanx much in advance

 

 

Greg

Link to comment
Share on other sites

If you want to provide free shipping in the same country as that of store owner set in your shop, then you may easily allow free shipping to national only:

 

Admin -> Modules -> order total -> shipping-> Allow free shipping for national.

 

Hope it solves your requirement.

Link to comment
Share on other sites

I used it but changed the if part (checking total_weight) but my tables break.

 

in my checkout_payment.php this line (the one down below):

 

<?php

}

$radio_buttons++;

?>

 

is different than in yours:

 

<?php

$radio_buttons++;

}

?>

 

I use MS 2.2 .

 

Any help will be appreciated.

 

Kind regards,

Raul

Link to comment
Share on other sites

I have a problem. I have two payment modules active (and one hidden by this hack) and I cannot choose the first option of payment. Something is wrong with radio button part.

Any help?

 

Kind regards,

Raul

Link to comment
Share on other sites

let me again explain how to write theses lines:

 

if (eregi($country, 'countryname') && $pay_method == 'payment code'){

? ? ? ? ? $display = '0';

? ? ? ? ? ? }

 

countryname is the name of country to be excluded and payment code is the code of payment module written in corresponding payment module file like for COD module, in /catalog/includes/modules/payment/cod.php the code is defined in

 

$this->code = 'cod';

Is it possible to exclude more than 1 country?

Link to comment
Share on other sites

Yes.

 

Modify the above code as:

 

if ((eregi($country, 'countryname1') ||  eregi($country, 'countryname2') || eregi($country, 'countryname3')) && $pay_method == 'payment code'){

          $display = '0';

            }

Link to comment
Share on other sites

if (eregi($country, 'countryname') && $pay_method == 'payment code'){

          $display = '0';

            }

 

Replace with:

 

if (eregi($country, 'countryname') && $pay_method == 'payment code'){

          $display = '1';

            }

          else {

            $display = '0';

}

Link to comment
Share on other sites

I tried it this morning but it wasn't what I expected. Here is my problem:

I want COD and Paypal to be available for Norwegian customers, and only PayPal for the rest of the world. How can this be done?

 

Thanks for all help.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...