VirtueMart Forum

VirtueMart 2 + 3 + 4 => 3rd party extension => Topic started by: Linelab on March 28, 2016, 14:24:04 PM

Title: Payment methods depending on shipping - plugin (Free)
Post by: Linelab on March 28, 2016, 14:24:04 PM
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.
Title: Re: Payment methods depending on shipping - plugin (Free)
Post by: igrkiv on February 12, 2017, 20:17:53 PM
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.