Post by zaja » Wed Oct 31, 2012 11:59 pm

Does anyone know how to configure sub total in cart/checkout in this way, I need the sum of net price of items and the net cost of shipping?

This is how Opencart now display this info now:

Image

But I need it displayed this way:

Image

User avatar
Newbie

Posts

Joined
Mon Nov 21, 2011 7:54 pm


Post by JAY6390 » Thu Nov 01, 2012 12:11 am

Place your shipping above the subtotal. Go to your EXTENSIONS > TOTALS in the admin and change the sort order of "Shipping" and "Subtotal" so the Shipping has a lower sort order value than the Subtotal

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by zaja » Thu Nov 01, 2012 1:21 am

JAY6390 wrote:Place your shipping above the subtotal. Go to your EXTENSIONS > TOTALS in the admin and change the sort order of "Shipping" and "Subtotal" so the Shipping has a lower sort order value than the Subtotal
Thanks, just tryed but this not work, Shipping ex VAT is still not added to Subtotal ex VAT:

Image

User avatar
Newbie

Posts

Joined
Mon Nov 21, 2011 7:54 pm


Post by JAY6390 » Thu Nov 01, 2012 1:28 am

OK, this is more of a hack than a proper solution, but will make the subtotal correct

Open

Code: Select all

/catalog/model/total/shipping.php
Find this line

Code: Select all

$total += $this->session->data['shipping_method']['cost'];
change it to

Code: Select all

// $total += $this->session->data['shipping_method']['cost'];  
Save that, then open

Code: Select all

/catalog/model/total/subtotal.php
Find this line

Code: Select all

$sub_total = $this->cart->getSubTotal();
After it on a new line put

Code: Select all

$subtotal += $this->session->data['shipping_method']['cost'];
And save. This is totally untested but should work in theory

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by zaja » Thu Nov 01, 2012 3:04 am

Great, it works! :)

Line to add in /catalog/model/total/subtotal.php must be:

Code: Select all

$sub_total += $this->session->data['shipping_method']['cost'];
Thank you! :good:

User avatar
Newbie

Posts

Joined
Mon Nov 21, 2011 7:54 pm


Post by JAY6390 » Thu Nov 01, 2012 3:06 am

Sorry yes that's correct :)

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by zaja » Thu Nov 01, 2012 3:32 am

I just noticed that this modification produces error on the top of the page:

Code: Select all

Notice: Undefined index: shipping_method in C:\xampp\htdocs\open154\catalog\model\subtotal.php on line 7 
Screenshot: http://screencast.com/t/uARZXc2a
This is how subtotal.php look:

Code: Select all

<?php
class ModelTotalSubTotal extends Model {
	public function getTotal(&$total_data, &$total, &$taxes) {
		$this->load->language('total/sub_total');
		
		$sub_total = $this->cart->getSubTotal();
		$sub_total += $this->session->data['shipping_method']['cost'];
		
		if (isset($this->session->data['vouchers']) && $this->session->data['vouchers']) {
			foreach ($this->session->data['vouchers'] as $voucher) {
				$sub_total += $voucher['amount'];
			}
		}
		
		$total_data[] = array( 
			'code'       => 'sub_total',
			'title'      => $this->language->get('text_sub_total'),
			'text'       => $this->currency->format($sub_total),
			'value'      => $sub_total,
			'sort_order' => $this->config->get('sub_total_sort_order')
		);
		
		$total += $sub_total;
	}
}
?>
Do you have any idea why this happening?

User avatar
Newbie

Posts

Joined
Mon Nov 21, 2011 7:54 pm


Post by zaja » Sat Nov 03, 2012 5:24 am

Ok, this work for sub_total.php:

After:

Code: Select all

$sub_total = $this->cart->getSubTotal();
add:

Code: Select all

if ($this->cart->hasShipping() && isset($this->session->data['shipping_method'])) {
			$sub_total += $this->session->data['shipping_method']['cost'];
			}

User avatar
Newbie

Posts

Joined
Mon Nov 21, 2011 7:54 pm

Who is online

Users browsing this forum: Baidu [Spider] and 138 guests