Author Topic: Get paymentmethod, shipmentmethod name for order  (Read 268 times)

sandomatyas

  • Jr. Member
  • **
  • Posts: 216
Get paymentmethod, shipmentmethod name for order
« on: May 29, 2018, 15:35:52 pm »
I write a custom script which loads orders.
I started like this
Code: [Select]
$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

  • VirtueMart Developer Team
  • Global Moderator
  • Full Member
  • *
  • Posts: 839
  • VirtueMart Version: VM3 on J3
Re: Get paymentmethod, shipmentmethod name for order
« Reply #1 on: May 29, 2018, 20:05:11 pm »
Code: [Select]
$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

Code: [Select]
$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();

sandomatyas

  • Jr. Member
  • **
  • Posts: 216
Re: Get paymentmethod, shipmentmethod name for order
« Reply #2 on: May 31, 2018, 16:59:14 pm »
thanks