Post by lovenatural » Fri May 22, 2020 5:27 am

Hello. Anyone knows which column in order_total is responsible for shipping price? Or where is it at all in db?

New member

Posts

Joined
Sat Aug 08, 2015 12:04 am

Post by Johnathan » Fri May 22, 2020 9:29 pm

All line items on the order are stored in the "order_total" table. You can find the relevant lines using the "order_id" column, then loop through the rows you find, and pick the one with code "shipping". The cost of the shipping will be stored in the "value" column.

Image
Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by arcovirtual » Tue Jun 16, 2020 6:58 pm

Johnathan wrote:
Fri May 22, 2020 9:29 pm
All line items on the order are stored in the "order_total" table. You can find the relevant lines using the "order_id" column, then loop through the rows you find, and pick the one with code "shipping". The cost of the shipping will be stored in the "value" column.
I have no knowledge in php or programming with sql, but I have been 24 hours without sleep reading everything, and I need something similar,
I need to get the total value of a shipment using the CODE column finding the word "shipping" and assigning the "value" to be able to call this value or shipping cost and use it in a calculation formula in a market nucleus, there is something like a php line that can do this? I have looked at many lines that apparently can locate the CODE column by ORDER_ID but I don't know how they work. :(

New member

Posts

Joined
Thu Jul 07, 2016 9:49 am

Post by arcovirtual » Tue Jun 16, 2020 7:03 pm

I have this function that uses parameters other than opencart, but I found that maybe there is the key to get the shipping value of an order, looking at codes ...

Code: Select all

private function _getOrderTotals($order_id,$initial_order_total) {
		// totals @todo
		$order_info = $this->model_account_order->getOrder($order_id, 'seller');
		$suborder_sub_total = $this->MsLoader->MsOrderData->getOrderTotal($order_id, array('seller_id' => $this->customer->getId()));
		$suborder_shipping_total = $this->MsLoader->MsOrderData->getOrderShippingTotal($order_id, array('seller_id' => $this->customer->getId()));
		$suborder_total = $suborder_sub_total + $suborder_shipping_total;

		// Get oc order totals. Needed to keep sort_order in totals
		$order_totals = $this->model_account_order->getOrderTotals($this->request->get['order_id']);
		foreach ($order_totals as $key => &$total) {
			if($total['code'] == 'mm_shipping_total') $total['value'] = $suborder_shipping_total;
			if($total['code'] == 'total') $total['value'] = $suborder_total;

			if($total['code'] == 'sub_total') {
				if((float)$total['value'] !== (float)$initial_order_total)
					$total['title'] .= '<!-- <span data-toggle="tooltip" title="Comision de tienda deducida"> <i class="fa fa-exclamation-circle" aria-hidden="true"></i></span>-->';

				$total['value'] = $suborder_sub_total;
			}

			// if total is for taxes - unset it, because taxes are counted in product's price
			// if total is for oc shipping - unset it, because this information is not related to seller
			if($total['code'] == 'tax' || $total['code'] == 'shipping' || $total['code'] == 'coupon') {
				unset($order_totals[$key]);
				continue;
			}
			$total['text'] = $this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']);
		}

		return $order_totals;
	}

New member

Posts

Joined
Thu Jul 07, 2016 9:49 am

Post by arcovirtual » Tue Jun 16, 2020 7:07 pm

In this line I want to put the shipping cost of opencart, but I can't get it from the database, I don't know how to put together the code to get it. :(

Code: Select all

		$suborder_total = $suborder_sub_total + $suborder_shipping_total;
but I found something interesting:
In this part I see that apparently it gets data from the database, I'm not sure, even if I try to modify it, it doesn't work.

Code: Select all

	// Get oc order totals. Needed to keep sort_order in totals
		$order_totals = $this->model_account_order->getOrderTotals($this->request->get['order_id']);
		foreach ($order_totals as $key => &$total) {
			if($total['code'] == 'mm_shipping_total') $total['value'] = $suborder_shipping_total;
			if($total['code'] == 'total') $total['value'] = $suborder_total;

New member

Posts

Joined
Thu Jul 07, 2016 9:49 am
Who is online

Users browsing this forum: No registered users and 36 guests