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
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!
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
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.
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
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
Thank you very much for your answer.
But unfortunately i still have a problem
My new button looks like this:
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.
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>
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.
For that, you must change the url in admin/controller/sale/order.php on line 1190 or look for the following line:
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:
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.
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');
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');
Developing Quality OpenCart Extensions since 2011.
View my extensions
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?
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?
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):
After that line, add some if else to check for 'code' column and apply the necessary html class. Something like this:
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.
Code: Select all
$total_data = $this->model_sale_order->getOrderTotals($order_id);
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>';
}
}
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
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
Even a Noob like me can understand your explanations! Ofc the invoice is showing new prices. I was totally confused by somethign stupid
Pls type in the path to the file, which the line is in.wakabayashi wrote: My new button looks like this:Code: Select all
<a onclick="window.open('<?php echo $invoice2; ?>');" class="button"><?php echo "test"; ?></a>
Hellohydrowire wrote:For that, you must change the url in admin/controller/sale/order.php on line 1190 or look for the following line: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['invoice'] = $this->url->link('sale/order/invoice', '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.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');
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!
Who is online
Users browsing this forum: No registered users and 79 guests