VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: sandomatyas on May 29, 2018, 15:35:52 PM

Title: Get paymentmethod, shipmentmethod name for order
Post by: sandomatyas on May 29, 2018, 15:35:52 PM
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?
Title: Re: Get paymentmethod, shipmentmethod name for order
Post by: K&K media production on May 29, 2018, 20:05:11 PM
$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();
Title: Re: Get paymentmethod, shipmentmethod name for order
Post by: sandomatyas on May 31, 2018, 16:59:14 PM
thanks