News:

Support the VirtueMart project and become a member

Main Menu

Get paymentmethod, shipmentmethod name for order

Started by sandomatyas, May 29, 2018, 15:35:52 PM

Previous topic - Next topic

sandomatyas

I write a custom script which loads orders.
I started like this

$this->_db = JFactory::getDBO();
$query = $this->_db->getQuery(true);
$query->select('virtuemart_order_id')
  ->from('#__virtuemart_orders')
  ->where('created_on > NOW() - INTERVAL 60 DAY');
$this->_db->setQuery($query);
$items = $this->_db->loadObjectList();

foreach($items as $item) {
$order = $ordersModel->getOrder( $item->virtuemart_order_id );
}


there is an $order['details']['BT']->virtuemart_paymentmethod_id and the same for shipping but could you please help me how should I get the name of the payment/shipment method as text?

K&K media production

$shipmentModel= VmModel::getModel('shipmentmethod');
$shipmentmethod = $shipmentModel->getShipment($order['details']['BT']->virtuemart_shipmentmethod_id);
$shipmentName = $shipmentmethod->shipment_name;

$paymentModel= VmModel::getModel('paymentmethod');
$paymentmethod = $paymentModel->getPayment($order['details']['BT']->virtuemart_paymentmethod_id);
$paymentName = $paymentmethod->payment_name;


or


$db = JFactory::getDBO();
$db->setQuery("SELECT payment_name FROM #__virtuemart_paymentmethods_de_de WHERE virtuemart_paymentmethod_id=".$order['details']['BT']->virtuemart_paymentmethod_id); 
$db->query();
$paymentName = $db->loadResult();

$db = JFactory::getDBO();
$db->setQuery("SELECT shipment_name FROM #__virtuemart_shipmentmethods_de_de WHERE virtuemart_shipmentmethod_id=".$order['details']['BT']->virtuemart_shipmentmethod_id); 
$db->query();
$shipmentName = $db->loadResult();