PrestaShop Forum

The best place in the world to ask questions about PrestaShop and get advice from our passionate community!

PrestaShop Forum

Jump to content

[Solved] How to position the cart block in the header???

20 replies to this topic
#1
mokijo

    PrestaShop Apprentice

  • Members
  • PipPip
  • 83 posts
...as the title says, i need to place the cart block in my header / above my logo. I've tried modules > positions > transplant a module. It'll let me display it on either the left or right hand columns, but when I transplant it to the header of pages block, it fails to display it there. I've searched this forum, and the wiki, but found nothing (unless I'm being a muppet and missed it somehow). I know it can be done as I've seen it on several prestashop sites.

There is mention in the wiki that some modules can't be hooked onto certain places, and that alterations may need to be carried out to achieve the desired effect. Does anyone have any tips / advice on what I need to hack?

Coffee and hookers to the winner....

Regards,

Mokijo

#2
mokijo

    PrestaShop Apprentice

  • Members
  • PipPip
  • 83 posts
Forgot to add, my custom theme is a two column layout. The categories column is on the left. I need the cart block (which will be modified to a simple "items: 0; total: £00.00; " setup) to be on the top right of the page.

Just a thought, can I just add the cart to the bottom of the left hand column and use css positioning to place it where I need it??? If so, any tips would be appreciated...

#3
Mattz

    PrestaShop Apprentice

  • Members
  • PipPip
  • 88 posts
I'm looking for this too.

I have the idea that it's just a duplicate of the cart-module where the jquery part for the slide is ripped out.

I ahve to investigate.

#4
mokijo

    PrestaShop Apprentice

  • Members
  • PipPip
  • 83 posts

From 1263337704:



I have the idea that it's just a duplicate of the cart-module where the jquery part for the slide is ripped out.



If you get any joy with your attempts, please can you report back? I reckon a lot of people would appreciate it.

On a side note, I see plently of french sites doing just this. Shame my French abilities are zero. I'm sure someone from their sub-forum would clear this up in a jiffy!

#5
yumyum

    PrestaShop Apprentice

  • Members
  • PipPip
  • 30 posts
check the free xmas theme from prestawork use that blockcart module it can hook on to top
http://www.prestasho...ee_theme_pwxmas

#6
mokijo

    PrestaShop Apprentice

  • Members
  • PipPip
  • 83 posts
Just downloaded the theme. looked at the blockcart.php file in the modules folder that came with it and found this extra line near the bottom of the page:


function hookTOP($params)
{
return $this->hookRightColumn($params);
}


Now I tried adding that to the blockcart.php I had copied into the "my_theme/modules/blockcart" folder. Mega fail.

So off I went to the main modules/blockcart folder and modified the original .php file and it worked! Have to figure out how to format it to my liking but its a start.

Just a little concerned that I had to modify a file outside of my themes folder. I was under the impression this was a no-no (i.e causes problems when you update?)

Hmmm....

:question:

#7
mokijo

    PrestaShop Apprentice

  • Members
  • PipPip
  • 83 posts
and to YumYum for suggesting I go look at that Xmas theme, NICE1 !!!

I reckon that was worth at least three coffees and half a hooker (The good half ;-) )

Cheers xxx

#8
mokijo

    PrestaShop Apprentice

  • Members
  • PipPip
  • 83 posts
Ok, was up till 3am toying with this problem. Still no joy.

Scrapped using the blockcart module. Then tried the user info block module. Problem is I don't want the 'welcome', 'login' etc. Just looking for "item: 0 ; total:£ 0:00 ; ". I've tried playing with the .tpl file but it doesn't seem to have much affect. It also fails to show the format I'm after. I want them to be displayed regardless of whether any one has added anything to the basket.

Please, please, please, with a big fat cherry on top, any suggestions???

Do I even need a module for this?

#9
wildchief

    PrestaShop Apprentice

  • Members
  • PipPip
  • 62 posts
Hello,

I don't suppose you have an image "mock up" of what you want ? I have been working on templates and modules recently and have some knowledge but I am not sure what you want

ta

#10
mokijo

    PrestaShop Apprentice

  • Members
  • PipPip
  • 83 posts
Hello wildchief,

Please find attached a lil' mockup.

However I think I may have found a solution. Please can you give me your opinion on its robustness? Seems to work on my test installation...




Items: {$cart_qties} <-- shows the number of items in cart, or 0 if empty -->
Total: {convertPrice price=$cart->getOrderTotal(true, 4)} <-- shows total cost excluding shipping, or £0.00 if cart is empty -->
Go To Basket <-- link to cart page -->





There's plenty of hooks to add css to, so it should provide endless options for people to style it as they wish (fancy background images for example!!!). Plus it ain't no smelly module so you can place it anywhere.

I haven't a clue what i'm doing in .php, so I just hit those spans with chuncks taken from the cart modules. Eventually i found some code that seems to work :cheese:

If it proves to be usuable, would anyone object to me naming this lil chunk of code "mokijo's super simple cart summary" ???

:red:

Attached Files



#11
mokijo

    PrestaShop Apprentice

  • Members
  • PipPip
  • 83 posts
Now off to treat myself to some coffee and hookers .............

;-)

#12
M3g4S4nt1k4

    PrestaShop Newbie

  • Members
  • Pip
  • 18 posts
Thank youu,...
I manage >> www.tshitstore.com
--------------------------------------
I will use your source code to change the world

#13
mokijo

    PrestaShop Apprentice

  • Members
  • PipPip
  • 83 posts
I've since tweaked the code for my super simple cart summary. Here's my latest version:

HTML-










CSS-


#carthnm {
float: right;
width: 400px;
}

.carthnm ul {
margin: 0;
padding: 0 5px 0 0;
list-style: none;
}

.carthnm li {
float: right;
height: 30px;
line-height: 30px;
}

.carthnm_basket a {
text-indent: -1000em;
width: 27px;
height: 27px;
display: block;
overflow: hidden;
background: transparent url(../img/basket.gif) no-repeat left top;
padding-right: 15px
}

.carthnm_total {
padding: 0 13px 0 0;
}

.carthnm_item {
padding: 0 13px 0 0;
}

.carthnm_number {
padding: 0;
color: #5ab8cb;
}

.carthnm_button a{
font-size: 12px;
color: #000;
text-decoration: none;
background-color: #b6d584;
padding: 5px 10px;
vertical-align: top;
}

.carthnm_button a:hover {
color: #fff;
text-decoration: none;
}



The cart summary is floated to the right, hence the reverse order of my
  • items. The basket image is also clickable with this method. Hope this helps.

    Regards

    Mokijo

    ps. If you float the cart to the left, reverse the order of
  • 's otherwise it won't display properly!


    UPDATE: please see this post for more clarification on implementing this hack

    Attached Files



  • #14
    mooshi

      PrestaShop Apprentice

    • Members
    • PipPip
    • 168 posts
    Thanks! for this mokijo...great!

    #15
    mokijo

      PrestaShop Apprentice

    • Members
    • PipPip
    • 83 posts
    My pleasure

    #16
    annunakiwww

      PrestaShop Newbie

    • Members
    • Pip
    • 23 posts
    Thanks mokijo!

    #17
    mokijo

      PrestaShop Apprentice

    • Members
    • PipPip
    • 83 posts
    Just had a PM regarding this thread. I thought it might be useful to others to copy my reply here, just in case anyone else needed a little further clarification. I'm just about to launch my business so might not be able to respond to any more PM's for a while:

    Quote



    Hello Soro,

    Not sure what else I can add to my thread...

    The CSS goes into your global.css file: yoursite.com/themes/yourtheme/css/global.css

    The HTML goes into your header.tpl: yoursite.com/themes/yourtheme/header.tpl (probably above, or within, the
    that contains your logo)

    Re- The basket icon: Visit http://www.smashingmagazine.com and search for 'ecommerce icons' to find one that suits your site. You'll need to place your icon in the yoursite.com/themes/yourtheme/img folder. You'll also need to tweek the CSS a little.

    This kind of Mod is meant for those who know their way around a CSS / HTML file, so you may want to learn the basics first. The link above is your friend!!!

    Good luck



    #18
    viar

      PrestaShop Apprentice

    • Members
    • PipPip
    • 56 posts
    thank you for the code.
    now i just need to work on css a little bit.
    :)

    #19
    markthedoc

      PrestaShop Newbie

    • Members
    • Pip
    • 24 posts
    Cheers for this, been battling with it for the past day or so.

    #20
    Kold

      PrestaShop Newbie

    • Members
    • Pip
    • 1 posts
    This is super cool. Just what Im looking for. There is one small issue with the solution though. The content of this slim basket dont update on the fly like the regular basket when an item are added (bought). updates only apear after page reload (or when you change to a new page).

    Is there a clever way to make it update on the fly. And can it use the ajax fly to basket?

    Thanks.