News:

Support the VirtueMart project and become a member

Main Menu

Payment methods depending on shipping - plugin (Free)

Started by Linelab, March 28, 2016, 14:24:04 PM

Previous topic - Next topic

Linelab

This plugin that limits the number of payment methods depending on the chosen shipping method. E.g. When customer chooses self pick up he should not be able to select PayPal etc...

1. Add new column to a table:
ALTER TABLE `#__virtuemart_paymentmethods` ADD `shipping` VARCHAR( 100 ) NOT NULL

2. Open: administrator/components/com_virtuemart/tables/paymentmethods.php
Find line: 62
Add:
var $shipping = '';

3. Open: administrator/components/com_virtuemart/models/paymentmethod.php

Find line: 218
Before:
$table->bindChecknStore($data);
Add:    
$data['shipping']=implode('|',$data['shipping']);

4. Open: administrator/components/com_virtuemart/views/paymentmethod/tmpl/edit_edit.php
Before:
</table>
      
Add:
<?php 
$db JFactory::getDbo(); 
$query "SELECT virtuemart_shipmentmethod_id,shipment_name FROM #__virtuemart_shipmentmethods_en_gb";
$db->setQuery($query);
$shipping_tmp $db->loadObjectList();
$shipping = array();
foreach ($shipping_tmp as $s) {
$shipping[$s->virtuemart_shipmentmethod_id] = $s->shipment_name.' ['.$s->virtuemart_shipmentmethod_id.']';
}
echo VmHTML::row('selectList','VM_SHIPPING','shipping',explode('|',$this->payment->shipping),$shipping,2,"multiple=\"multiple\""); 
$doc =& JFactory::getDocument();
$doc->addScriptDeclaration"
jQuery( document ).ready(function( $ ) {
$('#shipping').attr('name', 'shipping[]');
});
"
);
?>



5. Install VM shipping plugin (see attached...)
The plugin must be published the last in the list!
6. Create new language override for "VM_SHIPPING"

This plugin is compatible with the Joomla 2.5+ version.

igrkiv

#1
Thank you for nice plugin, but there is small problem
If you change the shipment method, the payment method is not changed until it is selected.