fast and secure web hosting. from a simple website to a highly visited e-shop  

Virtuemart 1.1.x - payment method by country

Something that it is missing from Joomla - Virtuemart 1.1.x is the restriction of payment method (for example Cahs On Delivery) to specific countries or to make it simple, how to set a payment method to be available only for a specified country or countries. Above, by editing only three (3) files (via the file manager of your panel that you web hosting company provides or via ftp) of virtuemart we will explain how to add this functionality. Run the following command on your mySQL database (via phpMyAdmin or via any other way you want to):
ALTER TABLE  `jos_vm_payment_method` ADD  `payment_method_country` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT  'restrict payment method by country';
---------------------- EDIT:
administrator/components/com_virtuemart/html/
store.payment_method_form.php
FIND:
    <tr class="row0">
      <td class="labelcell"><?php echo $VM_LANG->_('PHPSHOP_PAYMENT_METHOD_FORM_SHOPPER_GROUP') ?>:</td>
ADD ABOVE:
    <tr class="row1">
      <td class="labelcell"><?php echo $VM_LANG->_('PHPSHOP_PAYMENT_METHOD_FORM_SHOPPER_COUNTRY') ?>:</td>
      <td width="69%" >
      <input type="text" class="inputbox" name="payment_method_country" value="<?php $db->sp("payment_method_country") ?>" size="32" />
          <?php echo mm_ToolTip( $VM_LANG->_('VM_PAYMENT_METHOD_COUNTRY_TIP') ); ?>
      </td>
    </tr>
---------------------- EDIT:
administrator/components/com_virtuemart/classes/
ps_payment_method.php
ON BOTH LINES 211 AND 276 FIND:
'payment_extrainfo' => vmGet( $_POST, 'payment_extrainfo', null, VMREQUEST_ALLOWRAW )
ADD ABOVE:
'payment_method_country' => vmGet($d, 'payment_method_country'),
Near line 397 FIND:
$q .= "(enable_processor='$selector') AND ";
ADD ABOVE:
$q .= "(payment_method_country LIKE '%|". $_SESSION['auth']['country'] ."|%' OR payment_method_country='') AND ";
---------------------------------- EDIT:
administrator/components/com_virtuemart/languages/store/
english.php
FIND:
'PHPSHOP_PAYMENT_METHOD_FORM_CODE' => 'Code',
ADD ABOVE:
'PHPSHOP_PAYMENT_METHOD_FORM_SHOPPER_COUNTRY' => 'Show only for countries',
'VM_PAYMENT_METHOD_COUNTRY_TIP' => 'Enter Country Code (3) of the desired countries and split it like this: |GRC|RUS|. For just one country: |GRC|',
Repeat this last step for all the languages installed on your shop. USAGE: Edit or Add a payment method via your virtuemart administration panel. Use the "Show only for countries:" field. Enter Country Code (3) of the desired countries and split it like this: |GRC|RUS|. For just one country: |GRC| ... or just read the tip next to the input field