Jump to content

(solved) block cart on top


Recommended Posts

im trying to modify the default theme, and need some help :)

well im put bolckcart on top its worked fine so far and what i need is to made that blockcart floating so when expanded the menu below is not slidedown too. im already trying to put some z-index but didnt worked ;(

see the attachment for more detail

21966_yib35SrAT7JXuyaN5Xj1_t

Link to comment
Share on other sites

thank you... the css problem is solved... :kiss:

now about js... ive made that cart is on colapsed/closed state when loading the page and i want to made that cart block expanded automaticly when people add product to cart or when mouse hovering the header.
and then will colapsed/closed automaticly after sometimes....

Link to comment
Share on other sites

For mouse hovering try something like this.In blockcart folder, file ajax-cart.js at bottom
change code to this

$(document).ready(function(){

   // expand/collapse management
   $('#cart_block h4').mouseout(function(){
           ajaxCart.collapse();
   });
   $('#cart_block h4').mouseover(function(){
           ajaxCart.expand();
   });
   ajaxCart.overrideButtonsInThePage();
   ajaxCart.refresh();
});

Link to comment
Share on other sites

Try this :
In ajax-cart.js around line 139 add

    ajaxCart.expand();


so it looks like

    // add a product in the cart via ajax
   add : function(idProduct, idCombination, addedFromProductPage, callerElement, quantity, whishlist){
   ajaxCart.expand();



Then add around line 505

setTimeout("ajaxCart.collapse()",3000); 



so it looks like

            setTimeout("ajaxCart.collapse()",3000); 
       //reset the onlick events in relation to the cart block (it allow to bind the onclick event to the new 'delete' buttons added)
       ajaxCart.overrideButtonsInThePage();



And try different values in setTimeout function . 3000 is just for test.

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

How do you place the cart_block in the header?

I've tried several things, through the 'Back Office >> Modules >> Positions', this didn't work; through CSS positioning in the header in the global.css file, this didn't work either; through the modules >> positions placing it in the 'top', this DOES work, but it places it way outside the header...

Please advise me, thanks,
ibo

Link to comment
Share on other sites

You need to add this code to modules/blockcart/blockcart.php

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



And then you can transplant module to top and
then set position and css.


And for hover effect this is better solution then i posted earlier

//when document is loaded...
$(document).ready(function(){


   // expand/collapse management
   $('#cart_block').hover(function(){
           ajaxCart.expand();
   },
  function(){
           ajaxCart.collapse();
   });
   ajaxCart.overrideButtonsInThePage();
   ajaxCart.refresh();
}); 

Link to comment
Share on other sites

Hello razaro,

Your script works fabulous! Though there's one thing, sometimes the page is a little bit slow, or one moves the cursor too fast, upon that, it might happen that the cart won't collapse again but remain open though the mouse is not hovering it.

What could be a solution for that?

Kind regards,
ibo

Link to comment
Share on other sites

Another thing,

There is a field in the cart that displays the quantity of the ordered items and that field disappears when you hover the cart. I wanted to replace that field with a 'steady' one, that doesn't disappear, but when the 'disappearing field' is being removed, the cart won't fold out. How to fix that? I.e. how to make that 'quantity-field' un-disappearing?

Thanks in advance,
ibo

Link to comment
Share on other sites

With out messing to much with code you can do this way.
It is not elegant solution but this first came to my mind.
In blockcart.tpl copy this code

        
{if $cart_qties > 0}{$cart_qties}{/if}
{l s='products' mod='blockcart'}
{l s='product' mod='blockcart'}
{if $cart_qties > 0}{if $priceDisplay == 1}{convertPrice price=$cart->getOrderTotal(false)}{else}{convertPrice price=$cart->getOrderTotal(true)}{/if}{/if}
{if $cart_qties == 0}{l s='(empty)' mod='blockcart'}{/if}


and paste it after

    <!-- block list of products -->
Link to comment
Share on other sites

 {if $cart_qties > 0}{$cart_qties}{/if}



This is not correct tag is just
And maybe i misunderstood your post.
Code in attachment shows quantity in collapsed and in expanded cart.
But code for quantity is duplicated so that way i said it is not elegant.

blockcart.txt

Link to comment
Share on other sites

I noticed that when adding a product to the cart it simply adds to the number displayed, but when removing an item from the cart the 'total products' number doesn't decrease. One needs to refresh the page to get the correct number again.

Link to comment
Share on other sites

  • 1 month later...

Hi Josh,

Thank you very much. Actually the design is mine, but the specials like the unfolding cart are really from the help of the guys on the forum. Like razaro and others.

@all, on my site I have implemented the unfolding cart. There's also a numbering of the articles added to the cart (in magento). But it updates only on refreshing the site instead of 'live'. Anyone an idea?

Thanks in advance,
ibo

Link to comment
Share on other sites

  • 1 month later...
You need to add this code to modules/blockcart/blockcart.php

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



And then you can transplant module to top and
then set position and css.




could you give instructions for position and css? I added the lines to blockcart.php and if I transplant the module to top of pages it puts it on the left and above the logo. I want it to the right and on the same row as the logo which is on the left. other examples in this thread have it in that position, I just can't figure out how to get it over there on the right and after the logo.

if I transplant it to the header then it doesn't show.

any help appreciated.
Link to comment
Share on other sites

  • 1 month later...

Hi great thread

I have been trying and trying to reach this function.

1 Cart stay collapsed on page load (or auto collapse after time)
2 Cart thereafter expands / collapse with CLICK
3 cart do not expand for added products


This code performs
1 Cart expands and collapse after "3000"
2 Cart expands with CLICK
-Cart is then not able to collapse again, not with click not auto
3 cart expands for addded products,

What am I doing wrong?

//when document is loaded...
$(document).ready(function(){


   // expand/collapse management
   $('#cart_block').click(function(){
           ajaxCart.expand();
   },
  function(){
           ajaxCart.collapse();
   });
   setTimeout("ajaxCart.collapse()",3000); 
   ajaxCart.overrideButtonsInThePage();
   ajaxCart.refresh();
});

Link to comment
Share on other sites

@mel first sorry for really late replay if you still needs help PM me link to your site.

@ impeccabledeals
Try this in ajax-cart.js
First comment out line 488

//ajaxCart.expand();


and change code at bottom to

//when document is loaded...
$(document).ready(function(){

   // expand/collapse management
   $('#block_cart_collapse').click(function(){
           ajaxCart.collapse();
   });
   $('#block_cart_expand').click(function(){
           ajaxCart.expand();
   });
   setTimeout("ajaxCart.collapse()",3000);
   ajaxCart.overrideButtonsInThePage();
   ajaxCart.refresh();
});


Note that click events are connected with arrows(span elements wit ids #block_cart_collapse and #block_cart_expand ) and not whole cart block and you can't use click same way as hover function.

Link to comment
Share on other sites

ok the code produces exactly what I wanted though the step:

First comment out line 488
//ajaxCart.expand();

which prevents the cart from expanding on every pageload seems to bring some cookie-related bug when entering e.g. checkout page and going back since some code seems to need the cart to be expanded then. I think I read somewhere that there is a code that checks so the cookie contains expanded for some reason.

do you know anything about the matter, since the visual of that the cart stays collapsed and only expands with click is very much appreciated.

ps.

the click code correction worked like a charm, and seem so dig together with the code also.

Link to comment
Share on other sites

Hi, thanks for the reply.

I tried those solutions but unfortunately didnt work.

The uncomment of

ajaxCart.expand();


around line 488 solves the function of keeping the cart collapsed but if bugs the in order.php where the cart seems to have to must expand otherwise the the cart content does not show and if you go back to the store again all the visual functions is buggy.

I was thinking about a solution to put in an if sentence that uncoment the ajaxCart.expand(); line but not when on order.php page. Is it possible to do that in js?

I tried with the $page_name var but got errors.

any ideas on that?

Link to comment
Share on other sites

ok, interesting.

The code did no effect on my machine. I am not totally sure, but we might have missunderstood the wanted effect.

An example of a cart functioning exactly as I want is apple store
http://store.apple.com/us

-collapsed from start
-stays collapsed when browsing to new page
-stays collapsed when adding new product
-expand on click or hover

as I wrote your uncomment-solution of code below worked but triggers some buggy functioning of (i think) the ajax update.

ajaxCart.expand();

Link to comment
Share on other sites

  • 4 weeks later...
  • 8 months later...

hi
i fallow all the steps but there is another issue
when i add product to the cart there is no animation how to solve that this is my website www.flavorynature.co.uk. any ideas why this is happening?
i would be so so so grateful for help

Link to comment
Share on other sites

  • 7 months later...

Hi guys, I hope someone gets to read this since i've done everything this thread said and I broke my cart when I transplanted it to the top hook. before that, all the hovering effect worked like a charm. Im enclosing a screen of the site i've designed and that im building right now. I just need someone to point me in the right direction, tell me what to paste here if you need it.

 

Thanks in advance.

 

Screenshot: http://i.imgur.com/XpYAr.jpg

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...