Hello my oc version in 1.5.6
I am trying to make stock status to appear in email order.
I tried this on catalog/model/checkout.order.php
$order_product_info = $this->db->query("SELECT * FROM " . DB_PREFIX . "product WHERE product_id = '" . (int)$product['product_id'] . "'");
'stock' => $order_product_info->row['stock_status_id'],
and in /template/mail/order.tpl
I have this
<?php echo $product['stock']; ?>
It is almost working but it appears as an id at the email. like (product_name) 5
5 s an example of stosck_status_is
Any idea on how to make it appear as text like "Available"
I am trying to make stock status to appear in email order.
I tried this on catalog/model/checkout.order.php
$order_product_info = $this->db->query("SELECT * FROM " . DB_PREFIX . "product WHERE product_id = '" . (int)$product['product_id'] . "'");
'stock' => $order_product_info->row['stock_status_id'],
and in /template/mail/order.tpl
I have this
<?php echo $product['stock']; ?>
It is almost working but it appears as an id at the email. like (product_name) 5
5 s an example of stosck_status_is
Any idea on how to make it appear as text like "Available"
You have to call the database again to get the name of the status associated with that id.
1. load the model (stock_status)
2. make the query with your language_id
3. add instead the id the new fetched name
1. load the model (stock_status)
2. make the query with your language_id
3. add instead the id the new fetched name
Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.
Thanks for the reply.. i am very new to opencart code .. Can you please tell me how to do it? maybe call database with strlen?
Which OpenCart Version 1.5.6.x exactly?
In 1.5.6.5 order_status is already in the email.
In 1.5.6.5 order_status is already in the email.
Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.
I found the soution..
$order_product_status = $this->db->query("SELECT * FROM " . DB_PREFIX . "stock_status WHERE stock_status_id = '" . (int)$order_product_info->row['stock_status_id'] . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");
'stock_name' => $order_product_status->row['name'],
$order_product_status = $this->db->query("SELECT * FROM " . DB_PREFIX . "stock_status WHERE stock_status_id = '" . (int)$order_product_info->row['stock_status_id'] . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");
'stock_name' => $order_product_status->row['name'],
Sorry - my fault, to late and too tired.
stock_status of course.
While you may have found a solution, the code you posted is not the whole story.
The "problem" is, that the stock status (name and id) and not pulled before from the database.
And in the frontend no model for it exists.
So the queries have to be added without loading a model.
A solution could be: inside the
before the line
add this:
and after
this:
Now you have at each single ordered product the status.
Simply add inside the template on the position you want, the text (translation) and the new variable stock_status
nb: untested, but should work
stock_status of course.
While you may have found a solution, the code you posted is not the whole story.
The "problem" is, that the stock status (name and id) and not pulled before from the database.
And in the frontend no model for it exists.
So the queries have to be added without loading a model.
A solution could be: inside the
Code: Select all
..catalog/model/checkout/order.php
Code: Select all
$template->data['products'][] = array(
Code: Select all
/** get stock status */
$stock_status_id = $this->db->query("SELECT `stock_status_id` FROM `" . DB_PREFIX . "product` WHERE `product_id` = '" . (int)product['order_product_id'] . "'");
$stock_status = $this->db->query("SELECT `name` FROM `" . DB_PREFIX . "stock_status` WHERE `stock_status_id` = '" . (int)$stock_status_id . "' AND `language_id` = '" . (int)$this->config->get('config_language_id') . "'");
Code: Select all
$template->data['products'][] = array(
Code: Select all
'stock_status' => $stock_status,
Simply add inside the template on the position you want, the text (translation) and the new variable stock_status
nb: untested, but should work
Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.
Who is online
Users browsing this forum: No registered users and 392 guests