I need assistance with displaying the price of product options on the Admin Order Product page in OpenCart. Currently, when viewing the order details in the Admin panel, the product options are listed, but the price of each option is not shown next to the option name. I would like to show the price of each selected option as part of the product title or in a separate column, if possible.
Until now I have done the following:
admin/model/sale/order.php
Code: Select all
public function getOrderOptions($order_id, $order_product_id) {
$query = $this->db->query("SELECT oo.name, oo.value, oo.type, pov.price, pov.price_prefix
FROM " . DB_PREFIX . "order_option oo
LEFT JOIN " . DB_PREFIX . "product_option_value pov ON (oo.product_option_value_id = pov.product_option_value_id)
WHERE oo.order_id = '" . (int)$order_id . "' AND oo.order_product_id = '" . (int)$order_product_id . "'");
return $query->rows;
}
Code: Select all
// Products
$data['order_products'] = array();
$products = $this->model_sale_order->getOrderProducts($this->request->get['order_id']);
foreach ($products as $product) {
// Get options and include price
$product_options = $this->model_sale_order->getOrderOptions($this->request->get['order_id'], $product['order_product_id']);
$options_with_price = array();
foreach ($product_options as $option) {
$options_with_price[] = array(
'name' => $option['name'],
'value' => $option['value'],
'type' => $option['type'],
'price' => isset($option['price']) ? $this->currency->format($option['price'], $this->config->get('config_currency')) : null
);
}
$data['order_products'][] = array(
'product_id' => $product['product_id'],
'name' => $product['name'],
'model' => $product['model'],
'option' => $options_with_price, // Use options with price here
'quantity' => $product['quantity'],
'price' => $product['price'],
'total' => $product['total'],
'reward' => $product['reward']
);
}
Code: Select all
<td class="text-left">
<a href="{{ product.href }}">{{ product.name }}</a>
{% for option in product.option %}
<br />
{% if option.type != 'file' %}
<small> - {{ option.name }}: {{ option.value }}{% if option.price %} (Price: {{ option.price }}){% endif %}</small>
{% else %}
<small> - {{ option.name }}: <a href="{{ option.href }}">{{ option.value }}</a></small>
{% endif %}
{% endfor %}
</td>
Does anyone know how I can modify the admin panel to display the price of the options for products in an order? I'm using OpenCart 3.0.3.3 and any guidance on the necessary code changes or settings would be greatly appreciated.
Thank you!