Post by wakabayashi » Sun Dec 18, 2011 3:32 am

Hello

I try to modify my opencart a bit. For my shop i need 2 differents themes for the bills. I thought this should be quite easy. I just copied the Button "print bill" (I use german language pack, so i am not sure if its exactly this words in english version). My hope was now that i could just change somewhere the path to the tpl-file and that I will have 2 themes. Somehow this doesnt work ;D
My level of understanding PHP is very low, but I tried to find $invoice in the files. But this variable is nowhere... I can only find $invoice_no and this totally confuses me.

So my question is, if my way of trying to get two different themes for the bills is just stupid or what do I have to do? Or is there even a much simpler way of solving this problem?

Thanks for your help!
Last edited by wakabayashi on Thu Dec 22, 2011 6:32 am, edited 1 time in total.

New member

Posts

Joined
Thu Aug 04, 2011 2:55 am

Post by hydrowire » Mon Dec 19, 2011 6:08 pm

Hi wakabayashi,

Besides 2 .tpl files, you also need 2 functions in the controller to control each of them. In admin/controller/sale/order.php, you can see the function 'invoice()', that is for admin/view/template/sale/order_invoice.tpl. So if you create another .tpl, you will need another function, say invoice2() to control our new .tpl now. Just copy everything from invoice() and change what's necessary in your new invoice2() function.

Now you Print button will link to the new function instead, and the link will be something like admin/index.php?route=sale/order/invoice2&token=ef35a4aq5e4bz891c8d1fc53ar8a1t1c&order_id=8

Developing Quality OpenCart Extensions since 2011.
View my extensions


User avatar
Active Member

Posts

Joined
Wed Jan 26, 2011 5:41 pm


Post by wakabayashi » Tue Dec 20, 2011 11:43 pm

Thank you very much for your answer.
But unfortunately i still have a problem :)

My new button looks like this:

Code: Select all

<a onclick="window.open('<?php echo $invoice2; ?>');" class="button"><?php echo "test"; ?></a>
But of course i get the message: Undefined variable: invoice2
Where do I have to make the correction?
I copied the full function and called it invoice2 and changed the tpl file. The function works, because when i click on the "print invoice" button and change manually the url from invoice&token to invoice2&token, everything is fine.

New member

Posts

Joined
Thu Aug 04, 2011 2:55 am

Post by hydrowire » Wed Dec 21, 2011 1:44 am

For that, you must change the url in admin/controller/sale/order.php on line 1190 or look for the following line:

Code: Select all

$this->data['invoice'] = $this->url->link('sale/order/invoice', 'token=' . $this->session->data['token'] . '&order_id=' . (int)$this->request->get['order_id'], 'SSL');
All you need to do is add another line below it with your new variable and link destination, which you can guess it's like this:

Code: Select all

$this->data['invoice2'] = $this->url->link('sale/order/invoice2', 'token=' . $this->session->data['token'] . '&order_id=' . (int)$this->request->get['order_id'], 'SSL');
The above code is inside the info() function in. Just look at the url of the page you are at to know which function is the variable in. In you case, it's in route=sale/order/info, which means in sale folder, order.php file, and info() function.

Developing Quality OpenCart Extensions since 2011.
View my extensions


User avatar
Active Member

Posts

Joined
Wed Jan 26, 2011 5:41 pm


Post by wakabayashi » Wed Dec 21, 2011 2:57 am

Thank you very much!! now everything works fine.

Do you know 2 other things? :)

-In the tpl file there is for example the $total['title'] and this inserts total, subtotal and so on. I wan to edit this with css. But my intention is only to edit total and not both. I want for example make the total font-color: red; but the subtotal should still be black.
I think i have to split up this array, but no idea how this works...

- If I have products with special offers, I see in the invoice only the normal price. Is there a possibilty to insert the new price?

New member

Posts

Joined
Thu Aug 04, 2011 2:55 am

Post by hydrowire » Wed Dec 21, 2011 2:08 pm

1. Take a look at your database using phpMyAdmin or any tool and look for 'order_total' table. Here's where all the totals are. Now open and edit admin/controller/sale/order.php, look for the following line in your invoice() (or invoice2() in your case):

Code: Select all

$total_data = $this->model_sale_order->getOrderTotals($order_id);
After that line, add some if else to check for 'code' column and apply the necessary html class. Something like this:

Code: Select all

foreach($total_data as $key => $total)
{
	if($total['code'] == 'sub_total') {
		$total_data[$key]['text'] = '<span class="red">' . $total['text'] . '</span>';
	}
	if($total['code'] == 'total') {
		$total_data[$key]['text'] = '<span class="bold black">' . $total['text'] . '</span>';
	}
}
To get the 'code', look into your 'order_total' table in your database I mentioned just now. After that just add your own css in admin/view/stylesheet/invoice.css

2. The invoice is indeed showing Special/discount price of product with Special/discount price correctly.

Developing Quality OpenCart Extensions since 2011.
View my extensions


User avatar
Active Member

Posts

Joined
Wed Jan 26, 2011 5:41 pm


Post by wakabayashi » Thu Dec 22, 2011 6:32 am

Thank you very much!

Even a Noob like me can understand your explanations! Ofc the invoice is showing new prices. I was totally confused by somethign stupid :crazy:

New member

Posts

Joined
Thu Aug 04, 2011 2:55 am

Post by harry729 » Wed Apr 04, 2012 7:18 pm

wakabayashi wrote: My new button looks like this:

Code: Select all

<a onclick="window.open('<?php echo $invoice2; ?>');" class="button"><?php echo "test"; ?></a>
Pls type in the path to the file, which the line is in.

Newbie

Posts

Joined
Sun Dec 25, 2011 3:21 am

Post by harry729 » Wed Apr 04, 2012 7:24 pm

harry729 wrote: Pls type in the path to the file, which the line is in.
OK. I've already found it. It's admin/view/template/sale/order_info.tpl .

Newbie

Posts

Joined
Sun Dec 25, 2011 3:21 am

Post by wakabayashi » Thu May 24, 2012 12:14 am

hydrowire wrote:For that, you must change the url in admin/controller/sale/order.php on line 1190 or look for the following line:

Code: Select all

$this->data['invoice'] = $this->url->link('sale/order/invoice', 'token=' . $this->session->data['token'] . '&order_id=' . (int)$this->request->get['order_id'], 'SSL');
All you need to do is add another line below it with your new variable and link destination, which you can guess it's like this:

Code: Select all

$this->data['invoice2'] = $this->url->link('sale/order/invoice2', 'token=' . $this->session->data['token'] . '&order_id=' . (int)$this->request->get['order_id'], 'SSL');
The above code is inside the info() function in. Just look at the url of the page you are at to know which function is the variable in. In you case, it's in route=sale/order/info, which means in sale folder, order.php file, and info() function.
Hello

I have almost the same problem again. This time I try two make 2 themes for the product page. I want to make \catalog\view\theme\default\template\product\product.tpl and product2.tpl. I want to have a second url...

Where is the url for products created? I tried to find it in the files \admin\controller\catalog\product.php and \admin\controller\common\header.php... But I dont know what exactly I have to chance!?

Thanks for your help!

New member

Posts

Joined
Thu Aug 04, 2011 2:55 am
Who is online

Users browsing this forum: jp1077 and 72 guests