Post by Maansy » Thu Jul 15, 2010 9:53 am

well lets say its 95% perfect
i just dont know if the if the price of the # of items should stay the same even after adding shipping or tax.
i mean shouldnt be the total of all (items+shipping+tax- coupon) displied instead of JUST the total of items
on the 2nd pic you can see the coupon is showing in header, and again the Total is OLNY showing the total of items ignoring there are shipping and coupon dedution.

i have i feeling the total in header is the sub-total not the overall total. we need to show the overall total. right?

you are going in the right track and i am sure you can manage to do it right this time :)

good job so far kroozing :)
header-cart.jpg

shipping value is not added to the totel in the header - header-cart.jpg (11.63 KiB) Viewed 6749 times

header-cart2.jpg

coupon deducted amont shouldnt be showing in header, it should only deduct the value from the total - header-cart2.jpg (10.6 KiB) Viewed 6749 times


ALL Templates :: 1.5.1+ Templates :: 50%-75% PRICE DROP ONLY at OpencartStuff.com


User avatar
Active Member

Posts

Joined
Thu Jun 24, 2010 6:04 am


Post by kroozing » Thu Jul 15, 2010 4:18 pm

if you want to show the overall subtotal of the cart including any deductions and including the shipping.
In header.tpl
Change

Code: Select all

<?php if ($total['title'] != 'Total:') { ?>
To

Code: Select all

<?php if ($total['title'] != 'Sub-Total:') { ?>
this will still show the additional coupons but we'll deal with that if the total is performing correctly.

New member

Posts

Joined
Thu Apr 29, 2010 2:01 am

Post by kroozing » Thu Jul 15, 2010 4:27 pm

On another note you need to dissable ajax in admin for the cart as you have no ajax code in your header.

New member

Posts

Joined
Thu Apr 29, 2010 2:01 am

Post by Maansy » Thu Jul 15, 2010 5:58 pm

kroozing wrote:if you want to show the overall subtotal of the cart including any deductions and including the shipping.
In header.tpl
Change

Code: Select all

<?php if ($total['title'] != 'Total:') { ?>
To

Code: Select all

<?php if ($total['title'] != 'Sub-Total:') { ?>
this will still show the additional coupons but we'll deal with that if the total is performing correctly.
but how to display ONLY the Overall TOTAL after it does all the additions and subtraction (shipping.tax and coupon)?

Ex:
if the cart in block shows this
Sub-Total: $35.00
Tax: $3.00
Flat Shipping Rate: $2.00
Coupon (-10%): -$4.00
Total: $36.00


then in header it should ONLY show this
2 item(s): $36.00

ALL Templates :: 1.5.1+ Templates :: 50%-75% PRICE DROP ONLY at OpencartStuff.com


User avatar
Active Member

Posts

Joined
Thu Jun 24, 2010 6:04 am


Post by kroozing » Thu Jul 15, 2010 9:17 pm

I think the code will do what you want, have you tried it. It worked for me

New member

Posts

Joined
Thu Apr 29, 2010 2:01 am

Post by Maansy » Thu Jul 15, 2010 10:42 pm

yes i have, but coupon and VAT still showing thu
take a look
please demo buy product 1 and product 2 and then take a look at the code in the header.

see image attached also

Attachments

header-cart3.png

header-cart3.png (49.89 KiB) Viewed 6739 times


ALL Templates :: 1.5.1+ Templates :: 50%-75% PRICE DROP ONLY at OpencartStuff.com


User avatar
Active Member

Posts

Joined
Thu Jun 24, 2010 6:04 am


Post by kroozing » Thu Jul 15, 2010 10:56 pm

So am I right in thinking that the total is right now you just need to hide the vat and coupon amounts now? And how many discount codes have you got?

New member

Posts

Joined
Thu Apr 29, 2010 2:01 am

Post by Maansy » Thu Jul 15, 2010 11:19 pm

the total is perfect, you just need to hide the VAT and coupon :)
so far 1 discount code, i will add more later?

ALL Templates :: 1.5.1+ Templates :: 50%-75% PRICE DROP ONLY at OpencartStuff.com


User avatar
Active Member

Posts

Joined
Thu Jun 24, 2010 6:04 am


Post by kroozing » Fri Jul 16, 2010 1:47 am

I will be able to sort the vat and discount how ever the way I will suggest will only work for the discount code you have now and if you were to add more discount codes it will require you to add more code to the header.

I will be home in about an hour so I will post it then.

New member

Posts

Joined
Thu Apr 29, 2010 2:01 am

Post by Maansy » Fri Jul 16, 2010 3:49 am

Instead of trying to use the translation of the variable, why don't you try to use the variable itself so I don't need to go and add a line for coupon when I make a new coupon or for shipping when I use different shipping and same goes for tax.
Let try to hide the variable not the translation if you know what I mean.

ALL Templates :: 1.5.1+ Templates :: 50%-75% PRICE DROP ONLY at OpencartStuff.com


User avatar
Active Member

Posts

Joined
Thu Jun 24, 2010 6:04 am


Post by kroozing » Fri Jul 16, 2010 5:46 am

...

New member

Posts

Joined
Thu Apr 29, 2010 2:01 am

Post by Maansy » Fri Jul 16, 2010 6:21 am

well almost :)
there is a bug in it.
i replaced with this:

Code: Select all

<?php
$cartinfo = $totals[3]['text'];// line 86
echo $cartinfo; ?> 
i got this error (notice i have 3 not 2 cuz 3 is for the total and 2 is VAT and 1 is shipping):


Notice: Undefined offset: 3 in /home/vol13/0fees.net/fees0_5920608/htdocs/store/catalog/view/theme/default2/template/common/header.tpl on line 86
knowing that the cart is empty still. then i added a product and still that error there, then i choose shipping and now the error is gone :)

so the only way for this to work without getting an error is when the cart has all three (shipping,VAT and total)
now you need to make it if the cart is empty then it should show $0.00, and if i choose a product then it show the cart total in header, and if there is VAT applied to product then it will show the total cullcolated vat in it. and if shipping is selected then it should show the total of all three.

i hope you understand it hehehe

i am sure you can get it :)
Last edited by Maansy on Sat Aug 07, 2010 9:33 am, edited 3 times in total.

ALL Templates :: 1.5.1+ Templates :: 50%-75% PRICE DROP ONLY at OpencartStuff.com


User avatar
Active Member

Posts

Joined
Thu Jun 24, 2010 6:04 am


Post by kroozing » Fri Jul 16, 2010 6:43 am

now i really have got it lol.
this is the only code you need in the header.tpl

Code: Select all

    <?php if ($products) { ?>
    <br />
    <div style="text-align: right;"><a href="index.php?route=checkout/cart" alt="Shopping Bag">Shopping Bag (<?php echo $this->cart->countProducts(); ?>)</a></div>
	<?php
	$count=count($totals);
	$cartinfo = $totals[$count-1]['title'] . ' ' . $totals[$count-1]['text'];
	echo $cartinfo;
	?>   
 	<?php } else { ?>
 	<br />
    	<div style="text-align: right;"><a href="index.php?route=checkout/cart" alt="Shopping Bag">Shopping Bag (<?php echo $this->cart->countProducts(); ?>)</a></div>
	Total: $0.00
	<?php } ?> 
tested it all now and works (i think) :)

New member

Posts

Joined
Thu Apr 29, 2010 2:01 am

Post by Maansy » Fri Jul 16, 2010 7:03 am

you are the man :)
i got an error 1st cuz we had to define $product in catalog\controller\common\header.php
i added this:

Code: Select all

$this->data['products'] = array();
        
        foreach ($this->cart->getProducts() as $result) {
            $option_data = array();

            foreach ($result['option'] as $option) {
                  $option_data[] = array(
                    'name'  => $option['name'],
                    'value' => $option['value']
                  );
            }
            
              $this->data['products'][] = array(
                'key'          => $result['key'],
                'name'       => $result['name'],
                'option'     => $option_data,
                'quantity'   => $result['quantity'],
                'stock'      => $result['stock'],
                'price'      => $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))),
                'href'       => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/product&product_id=' . $result['product_id']),
              );
        }
 

to the rest of the code i added before, so now in header.php i have this:

Code: Select all

   protected function index() {
   
   $this->data['products'] = array();
        
        foreach ($this->cart->getProducts() as $result) {
            $option_data = array();

            foreach ($result['option'] as $option) {
                  $option_data[] = array(
                    'name'  => $option['name'],
                    'value' => $option['value']
                  );
            }
            
              $this->data['products'][] = array(
                'key'          => $result['key'],
                'name'       => $result['name'],
                'option'     => $option_data,
                'quantity'   => $result['quantity'],
                'stock'      => $result['stock'],
                'price'      => $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))),
                'href'       => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/product&product_id=' . $result['product_id']),
              );
        }
        
   $total_data = array();
        $total = 0;
        $taxes = $this->cart->getTaxes();
        
        $this->load->model('checkout/extension');
        
        $sort_order = array(); 
        
        $results = $this->model_checkout_extension->getExtensions('total');
        
        foreach ($results as $key => $value) {
            $sort_order[$key] = $this->config->get($value['key'] . '_sort_order');
        }
        
        array_multisort($sort_order, SORT_ASC, $results);
    
    foreach ($results as $result) {
            $this->load->model('total/' . $result['key']);

            $this->{'model_total_' . $result['key']}->getTotal($total_data, $total, $taxes);
        }
        
        $sort_order = array(); 
      
        foreach ($total_data as $key => $value) {
              $sort_order[$key] = $value['sort_order'];
        }

        array_multisort($sort_order, SORT_ASC, $total_data);
        
        $this->data['totals'] = $total_data;
        
        if (isset($this->session->data['coupon'])) {
            $this->load->model('checkout/coupon');
        
            $coupon = $this->model_checkout_coupon->getCoupon($this->session->data['coupon']);
            
            if ($coupon) {
                $data['coupon_id'] = $coupon['coupon_id'];
            } else {
                $data['coupon_id'] = 0;
            }
        } else {
            $data['coupon_id'] = 0;
        }
        
    $this->data['ajax'] = $this->config->get('cart_ajax');
        
        $this->id = 'cart';
 
and in header.tpl i have this:

Code: Select all

<b>
<?php if ($products) { ?>
    
    <a href="index.php?route=checkout/cart" alt="Shopping Bag">Shopping Bag (<?php echo $this->cart->countProducts(); ?>)</a>
   <?php
   $count=count($totals);
   $cartinfo = $totals[$count-1]['title'] . ' ' . $totals[$count-1]['text'];
   echo $cartinfo;
   ?>   
   <?php } else { ?>
   
       <a href="index.php?route=checkout/cart" alt="Shopping Bag">Shopping Bag (<?php echo $this->cart->countProducts(); ?>)</a>
   Total: $0.00
   <?php } ?> 
            </b>
now you need to do this proper for malti-lang :) you need to add this to language file:
Shopping Bag
Total:


to do that open catalog\language\english\common\header.php
and at the end just before ?> add this:

Code: Select all

$_['text_shoppingbag']   = 'Shopping Bag';
$_['text_shoppingbagtotal']   = Total:;
 
then open catalog\controller\common\header.php
after:

Code: Select all

$this->data['text_advanced'] = $this->language->get('text_advanced');
 
add this:

Code: Select all

$this->data['text_shoppingbag'] = $this->language->get('text_shoppingbag');
$this->data['text_shoppingbagtotal'] = $this->language->get('text_shoppingbagtotal');
 
and now open catalog\view\theme\default\template\common\header.tpl
and change Shopping Bag with:

Code: Select all

<?php echo $text_shoppingbag; ?>
and Change Total: with:

Code: Select all

<?php echo $text_shoppingbagtotal; ?>


good job kroozing, congratulation on you 1st add-on :D
Last edited by Maansy on Sat Aug 07, 2010 9:36 am, edited 2 times in total.

ALL Templates :: 1.5.1+ Templates :: 50%-75% PRICE DROP ONLY at OpencartStuff.com


User avatar
Active Member

Posts

Joined
Thu Jun 24, 2010 6:04 am


Post by Maansy » Fri Jul 16, 2010 7:30 am

you need also to take care of the $0.00, you should put the code for empty instead
instead of this:

Code: Select all

Total: $0.00
   <?php } ?> 
here is what i did:

Code: Select all

   : 
   <?php
    foreach ($totals as $total) { 
    if ($total['title'] != 'Sub-Total:') {
            echo $total['text']; 
        }
       }     
    } ?> 
            
thanks :)

ALL Templates :: 1.5.1+ Templates :: 50%-75% PRICE DROP ONLY at OpencartStuff.com


User avatar
Active Member

Posts

Joined
Thu Jun 24, 2010 6:04 am


Post by kroozing » Sat Jul 17, 2010 3:47 am

Glad we got there in the end, it all makes sense in the end.
Cheers

New member

Posts

Joined
Thu Apr 29, 2010 2:01 am

Post by neosdesign » Tue Aug 24, 2010 4:44 pm

Is there a way to change the controller/module/cart.php $total_data array to just output the total, not the both the total and subtotal?

I currently have:

Code: Select all

foreach ($total_data as $total) {
		        $output .= '<div class="product_total">' . $total['text'] . '</div>';
      		}
When I add a product to the cart....it spits out the price twice. I've implemented your method to my cart.tpl file, but am trying to continue to use the ajax refresh. It works great other than displaying both subtotal and total as the ajax script looks at the cart.php file for its formatting, not the cart.tpl file.

New member

Posts

Joined
Tue Aug 17, 2010 5:44 pm

Post by Maansy » Tue Aug 24, 2010 6:33 pm

its outputting the total only
take a look

ALL Templates :: 1.5.1+ Templates :: 50%-75% PRICE DROP ONLY at OpencartStuff.com


User avatar
Active Member

Posts

Joined
Thu Jun 24, 2010 6:04 am


Post by adkoda » Wed May 18, 2011 2:17 pm

Hello,

I'm trying to do what has been generally discussed here except I'd like to know how to hide unit price and subtotal in the cart module as opposed to the header. (I'm assuming its the cart module as I've only just started using opencart). I'm using opencart v 1.4.9.4

Any help would be appreciated :)

Newbie

Posts

Joined
Wed May 18, 2011 2:11 pm
Who is online

Users browsing this forum: No registered users and 30 guests