Post by imnotaprogrammer » Fri Apr 21, 2017 3:16 pm

Hello!
My OC version is 2.2.0.0

I am trying to modify the invoice sent to our customers by editing mail/order.tpl file.
I have these lines of text in the invoice:

Code: Select all

Invoice Nr.: 71595
Date: 21.04.2017
Payment Method: Cash
Shipping Method: Pickup
I want to edit the last line which says "Shipping Method: Pickup". The "Shipping Method:" part is OK, but the "Pickup" must be changed.
This "Pickup" line comes from /catalog/language/en-gb/shipping/pickup2.php file (or from any other shipping method language file).

Code: Select all

<?php
// Text
$_['text_title']       = 'Pickup';
$_['text_description'] = 'Pickup From Storehouse';
?>
What I want is to replace it with "Pickup From Storehouse", or more correctly - $_['text_description'].
I can easily change the order.tpl file to show this $_['text_description'] as static text, but because our store offers a few shipping methods, this line of text must be a variable that will change according to the chosen shipping method.
So, in the end the invoice should read:

Code: Select all

Invoice Nr.: 71595
Date: 21.04.2017
Payment Method: Cash
Shipping Method: Pickup From Storehouse
I had hoped this would be as simple as changing 'text_title' to 'text_description' in some file, but this seems not to be the case, as I have looked through a lot of files the whole day. I just can't find a solution here!
Can someone please guide me how to make this work?

Thank you!


Posts

Joined
Wed Jun 15, 2016 3:30 pm

Post by uksitebuilder » Fri Apr 21, 2017 3:34 pm

Actually, the shipping method is getting it’s value from the oc_order table in the database.

It's value is set at the time of the order being placed, and yes that value comes from one of the shipping module's language files.

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by imnotaprogrammer » Fri Apr 21, 2017 4:39 pm

Thank you for the tip!
I managed to do exactly what I wanted but my joy very soon faded, as I found that another line of text in the invoice had changed.
The table for totals at the bottom of the invoice now shows:

Code: Select all

Price (without tax): 152.55€
Tax: 32.04€
Pickup From Storehouse: 0.00€
Total: 184.59€
The problem here is the line "Pickup From Storehouse" - it should be left as before saying "Pickup". As far as I understand, Totals tab is under foreach loop, but I do not want to change it, as I am not familiar with this type of code. I am afraid it might change a lot more than I need.

The more simple approach (I hope) might be to once again try and change this top part of the invoice:

Code: Select all

Invoice Nr.: 71595
Date: 21.04.2017
Payment Method: Cash
Shipping Method: Pickup
The template file pickup2.tpl has this code:

Code: Select all

<b><?php echo $text_shipping_method; ?></b> <?php echo $shipping_method; ?>
The part I need to change is <?php echo $shipping_method; ?>
How can I edit it so it shows the $_['text_description'] = 'Pickup From Storehouse'; from the language file I mentioned in the original post? Not static, but as variable depending in the selected shipping method.

Thank you!


Posts

Joined
Wed Jun 15, 2016 3:30 pm

Post by paulfeakins » Fri Apr 21, 2017 4:41 pm

Haha love your username "imnotaprogrammer". In that case though, the best thing you can do is hire someone who is a programmer to fix stuff like this for you.

For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Active Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom

Post by imnotaprogrammer » Fri Apr 21, 2017 8:08 pm

Thanks, it took me a long time to come up with that name! :D ;)

So I am digging deeper here and seems I have found all the files I need, just not sure how to link them together.
I found out that during checkout, the title and the description of the shipping method is shown:
Image
That means I could try and use it in my invoice, too. The code is in /template/checkout/shipping_method.tpl:

Code: Select all

<p><strong><?php echo $shipping_method['title']; ?></strong></p>
and /controller/checkout/shipping_method.php:

Code: Select all

foreach ($results as $result) {
	if ($this->config->get($result['code'] . '_status')) {
	$this->load->model('shipping/' . $result['code']);

	$quote = $this->{'model_shipping_' . $result['code']}->getQuote($this->session->data['shipping_address']);

		if ($quote) {
			$method_data[$result['code']] = array(
			'title'      => $quote['title'],
			'quote'      => $quote['quote'],
			'sort_order' => $quote['sort_order'],
			'error'      => $quote['error']
		);
		}
	}
}
And now I have to edit this code in invoice template file:

Code: Select all

<b><?php echo $text_shipping_method; ?></b> <?php echo $shipping_method; ?>
As well as add some code somewhere after this line in /catalog/model/checkout/order.php:

Code: Select all

'shipping_method'         => $order_query->row['shipping_method'],
I tried a few variants, but none worked. It always showed the obvious "Notice: Undefined variable".
Am I even thinking correctly here? How should I resolve this problem?
Any help is appreciated! Thank you!


Posts

Joined
Wed Jun 15, 2016 3:30 pm

Post by imnotaprogrammer » Fri Apr 28, 2017 1:59 pm

Taking on this task again. Maybe anyone could help me with this problem?


Posts

Joined
Wed Jun 15, 2016 3:30 pm
Who is online

Users browsing this forum: iplocker and 49 guests