Post by kroozing » Mon Jul 12, 2010 5:37 pm

Hi,

Ive upgraded to 1.4.8b from 1.4.7 i have managed to change my template to accommodate the changes however I'm am very stuck on the last thing i need to change.
I have got my cart module in my header and everything works fine, except that i have both the subtotal and total visible.
As i have no tax class this shows the same price in both the subtotal and total fields. i am wanting just to show either subtotal or total but not both and now that the information is being pulled from an array it's not as easy as before just to show what i want it to show.
here is my module/cart.tpl & controller/module/cart.php

Code: Select all

<div id="cart_widget">
    <?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>
    <table cellpadding="0" cellspacing="0" align="right" style="display:inline-block;">
      <?php foreach ($totals as $total) { ?>
      <tr>
        <td align="right"><span class="cart_module_total"><b><?php echo $total['title']; ?></b></span></td>
        <td align="right"><span class="cart_module_total"><?php echo $total['text']; ?></span></td>
      </tr>
    <?php } ?>
    </table>
    <?php } else { ?>
    <div style="text-align: center;"><?php echo $text_empty; ?></div>
    <?php } ?>
</div>
<?php if ($ajax) { ?>
<script type="text/javascript" src="catalog/view/javascript/jquery/ajax_add.js"></script>
<?php } ?>

<script type="text/javascript"><!--

function getUrlParam(name) {
  var name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp(regexS);
  var results = regex.exec(window.location.href);
  if (results == null)
    return "";
  else
    return results[1];
}

$(document).ready(function () {
	$('.cart_remove').live('click', function () {
		if (!confirm('<?php echo $text_confirm; ?>')) {
			return false;
		}
		$(this).removeClass('cart_remove').addClass('cart_remove_loading');
		$.ajax({
			type: 'post',
			url: 'index.php?route=module/cart/callback',
			dataType: 'html',
			data: 'remove=' + this.id,
			success: function (html) {
				$('#module_cart .middle').html(html);
				if (getUrlParam('route').indexOf('checkout') != -1) {
					window.location.reload();
				}
			}
		});
	});
});
//--></script>
controller/module/cart.php

Code: Select all

<?php 
class ControllerModuleCart extends Controller { 
	protected function index() {
		$this->language->load('module/cart');
		
		$this->load->model('tool/seo_url');
		
    	$this->data['heading_title'] = $this->language->get('heading_title');
    	
		$this->data['text_subtotal'] = $this->language->get('text_subtotal');
		$this->data['text_empty'] = $this->language->get('text_empty');
		$this->data['text_remove'] = $this->language->get('text_remove');
		$this->data['text_confirm'] = $this->language->get('text_confirm');
		$this->data['text_view'] = $this->language->get('text_view');
		$this->data['text_checkout'] = $this->language->get('text_checkout');
		
		$this->data['view'] = HTTP_SERVER . 'index.php?route=checkout/cart';
		$this->data['checkout'] = HTTP_SERVER . 'index.php?route=checkout/shipping';
		
		$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;
		
		$this->data['ajax'] = $this->config->get('cart_ajax');
		
		$this->id = 'cart';
		
		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/cart.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/module/cart.tpl';
		} else {
			$this->template = 'default/template/module/cart.tpl';
		}
		
		$this->render();
	}
		
	public function callback() {
		$this->language->load('module/cart');

		$this->load->model('tool/seo_url');
		
		unset($this->session->data['shipping_methods']);
		unset($this->session->data['shipping_method']);
		unset($this->session->data['payment_methods']);
		unset($this->session->data['payment_method']);	
		
		if ($this->request->server['REQUEST_METHOD'] == 'POST') {
			
			if (isset($this->request->post['remove'])) {
	    		$result = explode('_', $this->request->post['remove']);
          		$this->cart->remove(trim($result[1]));
      		} else {
				if (isset($this->request->post['option'])) {
					$option = $this->request->post['option'];
				} else {
					$option = array();	
				}
				
      			$this->cart->add($this->request->post['product_id'], $this->request->post['quantity'], $option);
			}
		}
				
		$output = '<table cellpadding="2" cellspacing="0" style="width: 100%;">';
		
		if ($this->cart->getProducts()) {
		
    		foreach ($this->cart->getProducts() as $product) {
      			$output .= '<tr>';
        		$output .= '<td width="1" valign="top" align="left"><span class="cart_remove" id="remove_ ' . $product['key'] . '" />&nbsp;</span></td><td width="1" valign="top" align="right">' . $product['quantity'] . '&nbsp;x&nbsp;</td>';
        		$output .= '<td align="left" valign="top"><a href="' . $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/product&product_id=' . $product['product_id']) . '">' . $product['name'] . '</a>';
          		$output .= '<div>';
	            
				foreach ($product['option'] as $option) {
            		$output .= ' - <small style="color: #999;">' . $option['name'] . ' ' . $option['value'] . '</small><br />';
	            }
				
				$output .= '</div></td>';
				$output .= '</tr>';
      		}
			
			$output .= '</table>';
    		$output .= '<br />';
    		
    		$total = 0;
			$taxes = $this->cart->getTaxes();
			 
			$this->load->model('checkout/extension');
			
			$sort_order = array(); 
			
			$view = HTTP_SERVER . 'index.php?route=checkout/cart';
			$checkout = HTTP_SERVER . 'index.php?route=checkout/shipping';
			
			$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);
    	    		
    		$output .= '<table cellpadding="0" cellspacing="0" align="right" style="display:inline-block;">';
      		foreach ($total_data as $total) {
      			$output .= '<tr>';
		        $output .= '<td align="right"><span class="cart_module_total"><b>' . $total['title'] . '</b></span></td>';
		        $output .= '<td align="right"><span class="cart_module_total">' . $total['text'] . '</span></td>';
      			$output .= '</tr>';
      		}
      		$output .= '</table>';
      		$output .= '<div style="padding-top:5px;text-align:center;clear:both;"><a href="' . $view . '">' . $this->language->get('text_view') . '</a> | <a href="' . $checkout . '">' . $this->language->get('text_checkout') . '</a></div>';
		} else {
			$output .= '<div style="text-align: center;">' . $this->language->get('text_empty') . '</div>';
		}
		
		$this->response->setOutput($output, $this->config->get('config_compression'));
	} 	
}
?>
Any help is appreciated
Last edited by i2Paq on Tue Aug 24, 2010 11:36 pm, edited 2 times in total.
Reason: Title adjusted + Topic moved

New member

Posts

Joined
Thu Apr 29, 2010 2:01 am

Post by Qphoria » Mon Jul 12, 2010 10:04 pm

in the tpl:

Code: Select all

<?php foreach ($totals as $total) { ?>
      <tr>
        <td align="right"><span class="cart_module_total"><b><?php echo $total['title']; ?></b></span></td>
        <td align="right"><span class="cart_module_total"><?php echo $total['text']; ?></span></td>
      </tr>
<?php } ?>
change to:

Code: Select all

<?php foreach ($totals as $total) { ?>
      <?php if ($total['title'] != 'Sub-Total:') { ?>
      <tr>
        <td align="right"><span class="cart_module_total"><b><?php echo $total['title']; ?></b></span></td>
        <td align="right"><span class="cart_module_total"><?php echo $total['text']; ?></span></td>
      </tr>
      <?php } ?>
<?php } ?>

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by kroozing » Mon Jul 12, 2010 10:27 pm

Thanks a million Qphoria.
I had to add ":" at the end of Sub-Total, but works a treat. Thank you

New member

Posts

Joined
Thu Apr 29, 2010 2:01 am

Post by Maansy » Wed Jul 14, 2010 6:13 am

how do i add total items and total price to the header like this:
0 item(s): $0.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 » Wed Jul 14, 2010 6:26 am

Sorry I havnt got access to the server files till tomorrow morning but I will post all the files needed to have the cart in header that just shows number of products and the sub total.
Cheers

New member

Posts

Joined
Thu Apr 29, 2010 2:01 am

Post by Maansy » Wed Jul 14, 2010 6:30 am

kroozing wrote:Sorry I havnt got access to the server files till tomorrow morning but I will post all the files needed to have the cart in header that just shows number of products and the sub total.
Cheers
thanx kroozing :)

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 » Wed Jul 14, 2010 4:42 pm

As Promised here is all the files needed however please note that you may want to use different div classes.

1. admin/view/template/module/cart.tpl
Add this under the left and right options

Code: Select all

<?php if ($information_position == 'header') { ?>
              <option value="header" selected="selected"><?php echo 'Header'; ?></option>
              <?php } else { ?>
              <option value="header"><?php echo 'Header'; ?></option>
              <?php } ?>
My full file

Code: Select all

<?php echo $header; ?>
<?php if ($error_warning) { ?>
<div class="warning"><?php echo $error_warning; ?></div>
<?php } ?>
<div class="box">
  <div class="left"></div>
  <div class="right"></div>
  <div class="heading">
    <h1 style="background-image: url('view/image/module.png');"><?php echo $heading_title; ?></h1>
    <div class="buttons"><a onclick="$('#form').submit();" class="button"><span><?php echo $button_save; ?></span></a><a onclick="location = '<?php echo $cancel; ?>';" class="button"><span><?php echo $button_cancel; ?></span></a></div>
  </div>
  <div class="content">
    <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
      <table class="form">
        <tr>
          <td><?php echo $entry_ajax; ?></td>
          <td><select name="cart_ajax">
              <?php if ($cart_ajax) { ?>
              <option value="1" selected="selected"><?php echo $text_enabled; ?></option>
              <option value="0"><?php echo $text_disabled; ?></option>
              <?php } else { ?>
              <option value="1"><?php echo $text_enabled; ?></option>
              <option value="0" selected="selected"><?php echo $text_disabled; ?></option>
              <?php } ?>
            </select></td>
        </tr>
        <tr>
          <td><?php echo $entry_position; ?></td>
          <td><select name="cart_position">
              <?php if ($cart_position == 'left') { ?>
              <option value="left" selected="selected"><?php echo $text_left; ?></option>
              <?php } else { ?>
              <option value="left"><?php echo $text_left; ?></option>
              <?php } ?>
              <?php if ($cart_position == 'right') { ?>
              <option value="right" selected="selected"><?php echo $text_right; ?></option>
              <?php } else { ?>
              <option value="right"><?php echo $text_right; ?></option>
              <?php } ?>
	<?php if ($information_position == 'header') { ?>
              	<option value="header" selected="selected"><?php echo 'Header'; ?></option>
              	<?php } else { ?>
              	<option value="header"><?php echo 'Header'; ?></option>
              	<?php } ?>
            </select></td>
        </tr>
        <tr>
          <td><?php echo $entry_status; ?></td>
          <td><select name="cart_status">
              <?php if ($cart_status) { ?>
              <option value="1" selected="selected"><?php echo $text_enabled; ?></option>
              <option value="0"><?php echo $text_disabled; ?></option>
              <?php } else { ?>
              <option value="1"><?php echo $text_enabled; ?></option>
              <option value="0" selected="selected"><?php echo $text_disabled; ?></option>
              <?php } ?>
            </select></td>
        </tr>
        <tr>
          <td><?php echo $entry_sort_order; ?></td>
          <td><input type="text" name="cart_sort_order" value="<?php echo $cart_sort_order; ?>" size="1" /></td>
        </tr>
      </table>
    </form>
  </div>
</div>
<?php echo $footer; ?>
2. catalog/controller/common/header.php
Add this code before protected function index() {

Code: Select all

      $module_data = array();
      
      $this->load->model('checkout/extension');
      
      $results = $this->model_checkout_extension->getExtensions('module');

      foreach ($results as $result) {
         if ($this->config->get($result['key'] . '_status') && ($this->config->get($result['key'] . '_position') == 'header')) {
            $module_data[] = array(
               'code'       => $result['key'],
               'sort_order' => $this->config->get($result['key'] . '_sort_order')
            );
            
            $this->children[] = 'module/' . $result['key'];      
         }
      }

      $sort_order = array();
    
      foreach ($module_data as $key => $value) {
            $sort_order[$key] = $value['sort_order'];
       }

       array_multisort($sort_order, SORT_ASC, $module_data);         
      
      $this->data['modules'] = $module_data;
My full code

Code: Select all

<?php   
class ControllerCommonHeader extends Controller {
	protected function index() {
$module_data = array();
      
      $this->load->model('checkout/extension');
      
      $results = $this->model_checkout_extension->getExtensions('module');

      foreach ($results as $result) {
         if ($this->config->get($result['key'] . '_status') && ($this->config->get($result['key'] . '_position') == 'header')) {
            $module_data[] = array(
               'code'       => $result['key'],
               'sort_order' => $this->config->get($result['key'] . '_sort_order')
            );
            
            $this->children[] = 'module/' . $result['key'];      
         }
      }

      $sort_order = array();
    
      foreach ($module_data as $key => $value) {
            $sort_order[$key] = $value['sort_order'];
       }

       array_multisort($sort_order, SORT_ASC, $module_data);         
      
      $this->data['modules'] = $module_data;
    	if (($this->request->server['REQUEST_METHOD'] == 'POST') && isset($this->request->post['language_code'])) {
			$this->session->data['language'] = $this->request->post['language_code'];
		
			if (isset($this->request->post['redirect'])) {
				$this->redirect($this->request->post['redirect']);
			} else {
				$this->redirect(HTTP_SERVER . 'index.php?route=common/home');
			}
    	}		
		
		if (($this->request->server['REQUEST_METHOD'] == 'POST') && isset($this->request->post['currency_code'])) {
      		$this->currency->set($this->request->post['currency_code']);
			
			unset($this->session->data['shipping_methods']);
			unset($this->session->data['shipping_method']);
				
			if (isset($this->request->post['redirect'])) {
				$this->redirect($this->request->post['redirect']);
			} else {
				$this->redirect(HTTP_SERVER . 'index.php?route=common/home');
			}
   		}
		
		$this->language->load('common/header');
		
		if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
			$server = HTTPS_IMAGE;
		} else {
			$server = HTTP_IMAGE;
		}
			
		$this->data['title'] = $this->document->title;
		$this->data['keywords'] = $this->document->keywords;
		$this->data['description'] = $this->document->description;
		$this->data['template'] = $this->config->get('config_template');
		
		
		if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
			$this->data['base'] = HTTPS_SERVER;
		} else {
			$this->data['base'] = HTTP_SERVER;
		}
		
		if ($this->config->get('config_icon') && file_exists(DIR_IMAGE . $this->config->get('config_icon'))) {
			$this->data['icon'] = $server . $this->config->get('config_icon');
		} else {
			$this->data['icon'] = '';
		}
		
		$this->data['charset'] = $this->language->get('charset');
		$this->data['lang'] = $this->language->get('code');
		$this->data['direction'] = $this->language->get('direction');
		$this->data['links'] = $this->document->links;	
		$this->data['styles'] = $this->document->styles;
		$this->data['scripts'] = $this->document->scripts;		
		$this->data['breadcrumbs'] = $this->document->breadcrumbs;
		
		$this->data['store'] = $this->config->get('config_name');
		
		if ($this->config->get('config_logo') && file_exists(DIR_IMAGE . $this->config->get('config_logo'))) {
			$this->data['logo'] = $server . $this->config->get('config_logo');
		} else {
			$this->data['logo'] = '';
		}
		
		$this->data['text_home'] = $this->language->get('text_home');
		$this->data['text_special'] = $this->language->get('text_special');
		$this->data['text_contact'] = $this->language->get('text_contact');
		$this->data['text_sitemap'] = $this->language->get('text_sitemap');
		$this->data['text_bookmark'] = $this->language->get('text_bookmark');
    	$this->data['text_account'] = $this->language->get('text_account');
    	$this->data['text_login'] = $this->language->get('text_login');
    	$this->data['text_logout'] = $this->language->get('text_logout');
    	$this->data['text_cart'] = $this->language->get('text_cart'); 
    	$this->data['text_checkout'] = $this->language->get('text_checkout');
		$this->data['text_keyword'] = $this->language->get('text_keyword');
		$this->data['text_category'] = $this->language->get('text_category');
		$this->data['text_advanced'] = $this->language->get('text_advanced');

		$this->data['entry_search'] = $this->language->get('entry_search');
		
		$this->data['button_go'] = $this->language->get('button_go');

		$this->data['home'] = HTTP_SERVER . 'index.php?route=common/home';
		$this->data['special'] = HTTP_SERVER . 'index.php?route=product/special';
		$this->data['contact'] = HTTP_SERVER . 'index.php?route=information/contact';
    	$this->data['sitemap'] = HTTP_SERVER . 'index.php?route=information/sitemap';
    	$this->data['account'] = HTTPS_SERVER . 'index.php?route=account/account';
		$this->data['logged'] = $this->customer->isLogged();
		$this->data['login'] = HTTPS_SERVER . 'index.php?route=account/login';
		$this->data['logout'] = HTTP_SERVER . 'index.php?route=account/logout';
    	$this->data['cart'] = HTTP_SERVER . 'index.php?route=checkout/cart';
		$this->data['checkout'] = HTTPS_SERVER . 'index.php?route=checkout/shipping';
		
		if (isset($this->request->get['keyword'])) {
			$this->data['keyword'] = $this->request->get['keyword'];
		} else {
			$this->data['keyword'] = '';
		}
		
		if (isset($this->request->get['category_id'])) {
			$this->data['category_id'] = $this->request->get['category_id'];
		} elseif (isset($this->request->get['path'])) {
			$path = explode('_', $this->request->get['path']);
		
			$this->data['category_id'] = end($path);
		} else {
			$this->data['category_id'] = '';
		}
		
		$this->data['advanced'] = HTTP_SERVER . 'index.php?route=product/search';
		
		$this->load->model('catalog/category');
		
		$this->data['categories'] = $this->getCategories(0);
		
		$this->data['action'] = HTTP_SERVER . 'index.php?route=common/home';

		if (!isset($this->request->get['route'])) {
			$this->data['redirect'] = HTTP_SERVER . 'index.php?route=common/home';
		} else {
			$this->load->model('tool/seo_url');
			
			$data = $this->request->get;
			
			unset($data['_route_']);
			
			$route = $data['route'];
			
			unset($data['route']);
			
			$url = '';
			
			if ($data) {
				$url = '&' . urldecode(http_build_query($data));
			}			
			
			$this->data['redirect'] = $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=' . $route . $url);
		}
		
		$this->data['language_code'] = $this->session->data['language'];
		
		$this->load->model('localisation/language');
		
		$this->data['languages'] = array();
		
		$results = $this->model_localisation_language->getLanguages();
		
		foreach ($results as $result) {
			if ($result['status']) {
				$this->data['languages'][] = array(
					'name'  => $result['name'],
					'code'  => $result['code'],
					'image' => $result['image']
				);	
			}
		}
		
		$this->data['currency_code'] = $this->currency->getCode(); 
		
		$this->load->model('localisation/currency');
		 
		 $this->data['currencies'] = array();
		 
		$results = $this->model_localisation_currency->getCurrencies();	
		
		foreach ($results as $result) {
			if ($result['status']) {
   				$this->data['currencies'][] = array(
					'title' => $result['title'],
					'code'  => $result['code']
				);
			}
		}
		
		$this->id = 'header';
		
		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/common/header.tpl';
		} else {
			$this->template = 'default/template/common/header.tpl';
		}
		
    	$this->render();
	}	
	
	private function getCategories($parent_id, $level = 0) {
		$level++;
		
		$data = array();
		
		$results = $this->model_catalog_category->getCategories($parent_id);
		
		foreach ($results as $result) {
			$data[] = array(
				'category_id' => $result['category_id'],
				'name'        => str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $level) . $result['name']
			);
			
			$children = $this->getCategories($result['category_id'], $level);
			
			if ($children) {
			  $data = array_merge($data, $children);
			}
		}
		
		return $data;
	}
}
?>
3. catalog/view/theme/default/template/common/header.tpl
Add this where you want to display the cart

Code: Select all

            <div>
  			<?php foreach ($modules as $module) { ?>
  			<?php echo ${$module['code']}; ?>
  			<?php } ?>
            </div>
Any problems let me know.

New member

Posts

Joined
Thu Apr 29, 2010 2:01 am

Post by Maansy » Wed Jul 14, 2010 6:46 pm

i followed these steps, but it didnt work.
it shows nothing where i want it disply

soi put everything back to what it was before.

Edit

i tried to figure it out myself.

here is what i did:
1- catalog/controller/common/header.php
Find:

Code: Select all

protected function index() {
insert this after it:

Code: Select all

$total_data = array();
		$total = 0;
		
		$this->load->model('checkout/extension');
		
		$sort_order = array(); 
		
		$results = $this->model_checkout_extension->getExtensions('total');
		
		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;
2- in catalog/view/theme/default/template/common/header.tpl

add this anywhere in the header where you want to display:

Code: Select all

<?php foreach ($totals as $total) { ?>
           <?php echo $total['text']; ?>
           <?php } ?>

now you have cart details in the header.

i notice now the site is loading slow. ???

now, if i only want to display ONLY Total Items & Total Price
what should i edit?



thanx

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 » Wed Jul 14, 2010 10:36 pm

Sorry I forgot to mention that you need to go into admin and change the position of the cart to header not left or right

New member

Posts

Joined
Thu Apr 29, 2010 2:01 am

Post by Maansy » Wed Jul 14, 2010 10:51 pm

kroozing wrote:Sorry I forgot to mention that you need to go into admin and change the position of the cart to header not left or right
yes i kinda figured this out :) but the thing is i dont want to change the location of the cart. i just want to display ONLY Total Items & Total Price in header while cart still un touched

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 12:38 am

I'm sorry but I don't know how to add the header cart as well as the side cart. I would imagine you have to call the mysql query in the header controller. Maybe someone could suggest how to do it.

New member

Posts

Joined
Thu Apr 29, 2010 2:01 am

Post by Maansy » Thu Jul 15, 2010 1:06 am

following my steps will aloow you to have the cart info duplicated in header (1 in cart block + 1 in header)

but this is not what i was after, i wanted ONLY to add the Total items & Total Price in header.

maybe someone will help.
fingers are crossed :)

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 2:08 am

i think this is the code you require (i may be wrong but you could try it)

Code: Select all

<?php echo $this->cart->countProducts(); ?>

New member

Posts

Joined
Thu Apr 29, 2010 2:01 am

Post by Maansy » Thu Jul 15, 2010 2:19 am

yes that did the trick :) thanks kroozing. take a look
now how can get Only the Total price to show without the sub-total,shipping and tax?

after you figure this out you should release it as your add-on because its your effort :)

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 3:12 am

in your header.tpl put

Code: Select all

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

Code: Select all

<?php foreach ($totals as $total) { ?>
           <?php echo $total['text']; ?>
           <?php } ?>
I'm not going to release this as a module due to not knowing enough php to offer support, but if you wish to i haven't got a problem with it :)

New member

Posts

Joined
Thu Apr 29, 2010 2:01 am

Post by Maansy » Thu Jul 15, 2010 3:47 am

yes with this it disply only the total.
but as soon as shipping is collcolated then it show shipping and total
good work so far
you need to hide shipping now :)

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:32 am

in controller/common/header.php try deleting $taxes from the query as the tax and shipping is loaded from this i think.

Scrap that idea it doesn't work

New member

Posts

Joined
Thu Apr 29, 2010 2:01 am

Post by kroozing » Thu Jul 15, 2010 4:55 am

ok so i think ive got it. In header.tpl copy the code below and replace your current code, where it says flat shipping rate replace the "Flat Shipping Rate:" with what it saying for your shipping exactly.

Code: Select all

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

New member

Posts

Joined
Thu Apr 29, 2010 2:01 am

Post by Maansy » Thu Jul 15, 2010 5:43 am

Wouldn't this wipe out shipping from cart in block also?

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:00 am

It shouldn't do as it's only controlling what gets displayed in the header

New member

Posts

Joined
Thu Apr 29, 2010 2:01 am
Who is online

Users browsing this forum: No registered users and 9 guests