Post by deinosys » Mon Jan 25, 2016 9:43 pm

Hi,

I'm using OC 2.0.3.1

I would like to modify the confirmation email for the order to add informations about the quantity currently available for some products.

On my shop, customers can order out of stock products.
If they do so, they receive the warning message in the cart that tells them that the product is not in stock and there will be a delay in the delivery.
So this is a pre-order system and it is OK.

When the customer places the order, I would like the confirmation email to display the current availability of the ordered products.
So the idea is that the mail displays that some products are in pre-order.

If i'm correct, to do that I need to edit /catalog/view/theme/default/template/mail/order.tpl

Code: Select all

<tbody>
      <?php foreach ($products as $product) { ?>
      <tr>
        <td style="font-size: 12px;	border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD; text-align: left; padding: 7px;"><?php echo $product['name']; ?>
          <?php foreach ($product['option'] as $option) { ?>
          <br />
          &nbsp;<small> - <?php echo $option['name']; ?>: <?php echo $option['value']; ?></small>
          <?php } ?></td>
        <td style="font-size: 12px;	border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD; text-align: left; padding: 7px;"><?php echo $product['model']; ?></td>
        <td style="font-size: 12px;	border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD; text-align: right; padding: 7px;"><?php echo $product['quantity']; ?></td>
        <td style="font-size: 12px;	border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD; text-align: right; padding: 7px;"><?php echo $product['price']; ?></td>
        <td style="font-size: 12px;	border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD; text-align: right; padding: 7px;"><?php echo $product['total']; ?></td>
      </tr>
In that place I would need to access to the current quantity of each product, so I would need to have a $product['stock'] variable...
How can I do to create this variable?

I hope my explanation is clear enough.

Thanks by advance!

Newbie

Posts

Joined
Mon Jan 25, 2016 9:24 pm

Post by dbmtrde » Tue Jan 16, 2018 2:02 am

Hey I have too this Problem.

Have you any solution ?

Newbie

Posts

Joined
Sun Jan 14, 2018 4:29 am
Location - Germany

Post by straightlight » Tue Jan 16, 2018 6:19 am

dbmtrde wrote:
Tue Jan 16, 2018 2:02 am
Hey I have too this Problem.

Have you any solution ?
Which OC version are you using by indicating that you also have the same problem?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by dbmtrde » Fri Jan 19, 2018 9:16 am

Hi,

My version is 2.1.0.2 and I want show option price on cart and confirmation mail too. But i have not find a solution for that..

Newbie

Posts

Joined
Sun Jan 14, 2018 4:29 am
Location - Germany

Post by straightlight » Sat Jan 20, 2018 7:40 am

One way to accomplish this request would be by modifying the following line in your catalog/model/checkout/order.php file. Tested on v2.3.0.2 release.

In this file,

find:

Code: Select all

// Check for any downloadable products
add above:

Code: Select all

$stock_statuses = array();

$this->load->model('catalog/product');
Then, find:

Code: Select all

// Check if there are any linked downloads
add above:

Code: Select all

$product_info = $this->model_catalog_product->getProduct($order_product['product_id']);

if (!empty($product_info['stock_status'])) {
	$stock_statuses[] = html_entity_decode($product_info['stock_status'], ENT_QUOTES, 'UTF-8');
}
If you want the total product quantities, use this:

Code: Select all

$product_info = $this->model_catalog_product->getProduct($order_product['product_id']);

if (isset($product_info['quantity'])) {
	$stock_statuses[] = html_entity_decode($product_info['quantity'], ENT_QUOTES, 'UTF-8');
}

Then, this (quantity):

Code: Select all

$data['stock_status'] = sprintf($language->get('text_stock_status'), array_sum($stock_statuses));
If not quantities -

Then, find:

Code: Select all

$data['title'] = sprintf($language->get('text_new_subject'), $order_info['store_name'], $order_id);
add above:

Code: Select all

$data['stock_status'] = sprintf($language->get('text_stock_status'), sizeof($stock_statuses));
Quantities or not -

In your catalog/language/<your_language_code>/mail/order.php file, at the bottom of the file,

add:

Code: Select all

$_['text_stock_status'] = 'Stock status: %s';
In your catalog/view/theme/<your_theme>/template/mail/order.tpl file,

add / customize it the way you see fit:

Code: Select all

<?php if ($stock_status) { ?>
	<?php echo $stock_status; ?>
<?php } ?>
This should resolved the issue.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by CaptainN » Sat Feb 17, 2018 7:28 am

How can I adapt this to be used during checkout? I've made the changes to order.php. I've added another column to the checkout order table via confirm.tpl. I am unsure of how much of the code and proper position to insert into confirm.php to get it to show the stock status of the items in the table at the end of checkout.

Newbie

Posts

Joined
Tue Nov 04, 2014 6:43 am
Who is online

Users browsing this forum: No registered users and 169 guests