Post by gtphotography » Fri Oct 09, 2020 7:19 pm

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"

User avatar
Newbie

Posts

Joined
Fri Oct 09, 2020 7:11 pm


Post by OSWorX » Sat Oct 10, 2020 1:38 am

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

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by gtphotography » Sat Oct 10, 2020 1:45 am

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?

User avatar
Newbie

Posts

Joined
Fri Oct 09, 2020 7:11 pm


Post by OSWorX » Sat Oct 10, 2020 2:32 am

Which OpenCart Version 1.5.6.x exactly?
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.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by gtphotography » Sat Oct 10, 2020 2:45 am

my version is 1.5.6.4

User avatar
Newbie

Posts

Joined
Fri Oct 09, 2020 7:11 pm


Post by kestas » Sat Oct 10, 2020 2:47 am

OSWorX wrote:
Sat Oct 10, 2020 2:32 am
Which OpenCart Version 1.5.6.x exactly?
In 1.5.6.5 order_status is already in the email.

If I correctly understand OP asking about stock_status

Custom OpenCart modules and solutions. You can write PM with additional questions... Extensions you can find here


Active Member

Posts

Joined
Tue Oct 12, 2010 2:23 am

Post by gtphotography » Sat Oct 10, 2020 2:54 am

OSWorX wrote:
Sat Oct 10, 2020 2:32 am
Which OpenCart Version 1.5.6.x exactly?
In 1.5.6.5 order_status is already in the email.
I just did download 1.5.6.5 but there is no stock_status on email order

User avatar
Newbie

Posts

Joined
Fri Oct 09, 2020 7:11 pm


Post by gtphotography » Sat Oct 10, 2020 3:19 am

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'],

User avatar
Newbie

Posts

Joined
Fri Oct 09, 2020 7:11 pm


Post by OSWorX » Sat Oct 10, 2020 3:37 am

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

Code: Select all

..catalog/model/checkout/order.php
before the line

Code: Select all

$template->data['products'][] = array(
add this:

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') . "'");
and after

Code: Select all

$template->data['products'][] = array(
this:

Code: Select all

'stock_status' => $stock_status,
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

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by gtphotography » Sat Oct 10, 2020 5:23 am

Thanks a lot.. it is working prefect .. you are the best!

User avatar
Newbie

Posts

Joined
Fri Oct 09, 2020 7:11 pm

Who is online

Users browsing this forum: No registered users and 392 guests