Post by thinkingforward » Wed May 05, 2010 9:10 am

Hi,

Im trying to put the cart in the header but can't seem to find instructions that apply to v 1.34.

Anyone out there done it for this version?

Thanks,

Chris
Last edited by i2Paq on Sat May 08, 2010 9:14 pm, edited 1 time in total.
Reason: Title adjusted

Active Member

Posts

Joined
Wed Nov 25, 2009 2:55 am


Post by thinkingforward » Sat May 08, 2010 2:31 am

Anyone? I want it top right

Active Member

Posts

Joined
Wed Nov 25, 2009 2:55 am


Post by thinkingforward » Sat May 08, 2010 8:00 am

Ive done this so far

Opened file /admin/view/template/module/cart.tpl and added the following code directly after the left/right position code, before the </select> tag.

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 } ?>
Added code to the controller that processes the header data so it will find the module. File, /catalog/controller/common/header.php

Directly below

Code: Select all

protected function index() {
I have added

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;
and then in /catalog/view/theme/default/template/common/header.tpl inside <DIV3>

Code: Select all

<?php foreach ($modules as $module) { ?>
  <?php echo ${$module['code']}; ?>
  <?php } ?>
But I'm getting the path: "http://www.thinking-forward.co.uk/index ... ckout/cart" displayed instead of the basket contents. Any ideas? Site is http://www.thinking-forward.co.uk

Active Member

Posts

Joined
Wed Nov 25, 2009 2:55 am


Post by thinkingforward » Sat May 08, 2010 8:12 pm

I've turned this off for now as my site is live, but here is a screen shot of how the top right of my store looks with it switched on.

Image

Active Member

Posts

Joined
Wed Nov 25, 2009 2:55 am


Post by thinkingforward » Wed May 12, 2010 12:37 am

bump

Active Member

Posts

Joined
Wed Nov 25, 2009 2:55 am


Post by chapter5 » Tue Jul 13, 2010 6:10 pm

I'm using OpenCart 1.4.8b and I've got the same problem. Is there anybody out there that can help us move the Cart or at least - My Cart(10) - type of thing into the header?

cheers!

Newbie

Posts

Joined
Fri Jul 09, 2010 3:42 pm

Post by Maansy » Tue Jul 13, 2010 7:52 pm

i am trying to do almost the same thing.
i want to display:
2 item(s) : $29.99
in the header
but seems like no one want to help :(

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 » Wed Jul 14, 2010 8:27 am

no 1 tried to do this before? maybe its impossible to do.. :o

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 slawrence10 » Sun Sep 19, 2010 10:57 pm

Hey Guys,

Thought I might as well post the simpest solution as I had to just do this one for a client.

In catalog/controller/common/header.php add

Code: Select all

$this->data['text_cart_count'] = $this->cart->countProducts();
$this->data['text_cart_total'] = $this->cart->getTotal();
after:

Code: Select all

$this->language->load('common/header');
Then, wherever in your header template you want the amount of products in cart to be displayed simple use:

Code: Select all

<?php echo $text_cart_count; ?>
and where you want the cart total:

Code: Select all

<?php echo $text_cart_total; ?>
Note that this method will only refresh totals after a page load, so if you have a cart in your sidebar you will want to turn off AJAX. This is the simplest implementation of a cart in your header.


Scott

Scott Lawrence - Creative agency - Bespoke web and graphic design


User avatar
Active Member

Posts

Joined
Sun Jul 19, 2009 8:10 pm
Location - London, UK

Post by harryo40 » Fri Oct 29, 2010 5:02 am

Hi,
Hope this helps people out in this thread ;)
I have created a Mod which can be downloaded for FREE from here.....
http://www.opencart.com/index.php?route ... ion_id=716
It shows the cart in the header & to the right of the search box & also shows the Item count & Sub-Total that updates when the main add to cart buttons are clicked.
I have also started a Thread which can be seen here.....
http://forum.opencart.com/viewtopic.php?f=112&t=22043
Please post question, issues or any problems with the 'Cart In Header' Mod & I will reply to them from within the thread ;)
cheers
harryo

Add To Cart Confirm Ajax Popup for OC 1.5.1.3 --> 1.5.5.1 - Add to Cart Confirmation Popup
Image Map Banner Module - Image Map Banner Module
----------------------------------------------------------------------
Womens Famous Name Fashion Clothing at bargain prices - Next2nowt.com


Active Member

Posts

Joined
Wed Oct 21, 2009 3:37 am
Location - Blackburn, Lancashire
Who is online

Users browsing this forum: No registered users and 12 guests