Post by DannyMacD » Wed Jan 02, 2013 4:34 am

Hello,

im trying to change the layout of the cart page and need some help with the code.

i need this
image1.png

image1.png (37.4 KiB) Viewed 3123 times

to look like this
image2.png

image2.png (30.29 KiB) Viewed 3123 times

unit price ex VAT
total price ex VAT = unit price ex VAT x Quantity
total price inc VAT = total price ex VAT + VAT (Tax)

any ideas?

many thanks

Active Member

Posts

Joined
Fri Jun 26, 2009 6:39 am

Post by pedro1993 » Wed Jan 02, 2013 8:25 am

Okay, this is easier said than done.

I see you have the template/layout side sorted but I will talk you through it.

There are the 3 steps:
[b]1. Add the code that will get the no-tax prices and no-tax totals[/b]
[b]]2. Adding the no-tax prices/totals to the data array. In simple terms, sending the prices to the template file.[/b]
[b]3. Displaying the prices in the table[/b]

[b]1. Add the code that will get the no-tax prices and no-tax totals[/b]
Open the catalog/controller/checkout/cart.php file and search for this code (around line 218):
[code]
// Display prices
if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
$price = $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')));
} else {
$price = false;
}

// Display prices
if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
$total = $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')) * $product['quantity']);
} else {
$total = false;
}
[/code]

Beneath that add this bunch of code:
[code]
// Display prices (no tax)
if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
$priceNoTax = $this->currency->format($product['price'], $product['tax_class_id'], $this->config->get('config_tax'));
} else {
$priceNoTax = false;
}

// Display total (no tax)
if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
$totalNoTax = $this->currency->format($product['price'], $product['tax_class_id'], $this->config->get('config_tax') * $product['quantity']);
} else {
$totalNoTax = false;
}
[/code]

[b]2. Adding the no-tax prices/totals to the data array. In simple terms, sending the prices to the template file.[/b]
Further down a little you will see 2 lines of code exactly like this:
[code]
'price' => $price,
'total' => $total,
[/code]

Directly underneath that add these two lines:
[code]
'totalNoTax' => $totalNoTax,
'priceNoTax' => $priceNoTax,
[/code]

[b]3. Displaying the prices in the table
a) Add the thead columns[/b]
Replace this bunch of code:
[code]
<td class="price"><?php echo $column_price; ?></td>
<td class="total"><?php echo $column_total; ?></td>
[/code]
with:
[code]
<td class="price"><?php echo $column_price; ?> (Exluding VAT)</td>
<td class="total"><?php echo $column_total; ?> (Excluding VAT)</td>
<td class="total"><?php echo $column_total; ?></td>
[/code]
[b][color=#BF0000]Note: You can change anything within the TD tags. The phrase "exlcuding VAT" won't be translated if you are using other languages.[/color]
b) Edit the tbody columns[/b]
Replace this code:
[code]
<td class="price"><?php echo $product['price']; ?></td>
<td class="total"><?php echo $product['total']; ?></td>
[/code]
with:
[code]
<td class="price"><?php echo $product['priceNoTax']; ?></td>
<td class="total"><?php echo $product['totalNoTax']; ?></td>
<td class="total"><?php echo $product['total']; ?></td>
[/code]

The is a working screenshot attached.

Please let me know how you get on.

Peter

Attachments

Capture.PNG

Capture.PNG (28.59 KiB) Viewed 3110 times


For OpenCart & PHP/MySQL support feel free to PM me :)
Click here for my extentions
Did I help you? Donate here to show support


Active Member

Posts

Joined
Tue Oct 18, 2011 4:31 am
Location - Glasgow, Scotland

Post by pedro1993 » Wed Jan 02, 2013 8:29 am

Sorry, I can't figure out why the bbcode isn't working. Hopefully a mod will be able to edit?

Peter

For OpenCart & PHP/MySQL support feel free to PM me :)
Click here for my extentions
Did I help you? Donate here to show support


Active Member

Posts

Joined
Tue Oct 18, 2011 4:31 am
Location - Glasgow, Scotland

Post by DannyMacD » Wed Jan 02, 2013 10:12 pm

it has worked a treat!!!

im also using the amazing Qs Uber checkout. im trying to follow the same process with the checkout_two page. should it just work and be the same?

cant really post code as its a commercial module..

Active Member

Posts

Joined
Fri Jun 26, 2009 6:39 am

Post by DannyMacD » Fri Jan 04, 2013 5:36 pm

so using the code above i have managed to tweak the uber checkout to show what i want it to show.. :0)

Active Member

Posts

Joined
Fri Jun 26, 2009 6:39 am

Post by Qphoria » Sun Jan 06, 2013 1:59 am

So you want to add the column "Total +Vat" ?

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by DannyMacD » Sun Jan 06, 2013 2:09 am

yup, i got it to work now. just having an issue with the plus and minus and update stock buttons:

http://forum.opencart.com/viewtopic.php?f=20&t=92202

Active Member

Posts

Joined
Fri Jun 26, 2009 6:39 am

Post by twdre » Mon Oct 10, 2016 5:16 pm

Is this also possible in opencart 2.03.1

I tried to follow the instuctions the collumnnames are showing and also the totla but not the totals exl tax

Im using Journal2 template
Thank you

New member

Posts

Joined
Sat Mar 28, 2015 4:52 am
Who is online

Users browsing this forum: No registered users and 53 guests