Jump to content

[SOLVED] ajax-cart.js customization


Recommended Posts

Hi,

I'm trying to modify my block_cart in order to always display the block_summary and title,

(instead of displaying shopping_cart);

 

furthermore I'm trying to apply the ajax collapse and expand fuction only to the block_cart_list,

 

I thought of a workaround wrapping everything in a div and then moving the summary in the outer div,

but I would like to understand how the ajax-cart action in created,

since I'm quite inexpereinced with js this can be a good chance to learn how it works,

 

question 1:

what triggers the expand : function seems to be

if ($('#cart_block_list').hasClass('collapsed'))

or expanded

this depends from the fact if there are or not products in the basket,

where is the class change controlled?

 

question 2:

 

shopping_cart a: hover is what activates the js transition:

why is this positioned in 2 different modules?

it would have more sense to have only one module manage all order information_

If I delete the shopping_cart div (I'll display all order info with blockcart) will this have side-effects?

Edited by maio (see edit history)
Link to comment
Share on other sites

While rereading my post I found a solution that works (at least so far...)

 

changing this (ajax-cart.js)

/* roll over cart */

	var cart_block = new HoverWatcher('#cart_block');
	var shopping_cart = new HoverWatcher('#shopping_cart');

	$("#shopping_cart a:first").hover(
		function() {
			$(this).css('border-radius', '3px 3px 0px 0px');
			if (ajaxCart.nb_total_products > 0)
				$("#cart_block").stop(true, true).slideDown(450);
		},
		function() {
			$('#header #shopping_cart a').css('border-radius', '3px');
			setTimeout(function() {
				if (!shopping_cart.isHoveringOver() && !cart_block.isHoveringOver())
					$("#header #cart_block").stop(true, true).slideUp(450);
			}, 200);
		}
	);

	$("#cart_block").hover(
		function() {
			$('#shopping_cart a').css('border-radius', '3px 3px 0px 0px');
		},
		function() {
			$('#shopping_cart a').css('border-radius', '3px');
			setTimeout(function() {
				if (!shopping_cart.isHoveringOver())
					$("#header #cart_block").stop(true, true).slideUp(450);
			}, 200);
		}
	);
	

to this

/* roll over cart */
	var cart_block_list = new HoverWatcher('#cart_block_list');
	var cart_block = new HoverWatcher('#cart_block');


	$("#cart_block a:first").hover(
		function() {
			$(this).css('border-radius', '3px 3px 0px 0px');
			if (ajaxCart.nb_total_products > 0)
				$("#cart_block_list").stop(true, true).slideDown(450);
		},
		function() {
			$('#header #cart_block a').css('border-radius', '3px');
			setTimeout(function() {
				if (!cart_block.isHoveringOver() && !cart_block_list.isHoveringOver())
					$("#header #cart_block_list").stop(true, true).slideUp(450);
			}, 200);
		}
	);

	$("#cart_block_list").hover(
		function() {
			$('#cart_block a').css('border-radius', '3px 3px 0px 0px');
		},
		function() {
			$('#cart_block a').css('border-radius', '3px');
			setTimeout(function() {
				if (!cart_block.isHoveringOver())
					$("#header #cart_block_list").stop(true, true).slideUp(450);
			}, 200);
		}
	);
	

actually works .....

 

logically adjusting some css is needed....

I'll keep on testing...

Link to comment
Share on other sites

When removing all products from cart ---> the cart_block will disappear instead of showing "empty"

______

 

to avoid this in ajax-cart.js

around line 315

 

you need to change this:

 

$("#header #cart_block").stop(true, true).slideUp(200);

 

to:

 

$("#header #cart_block_list").stop(true, true).slideUp(200);

Link to comment
Share on other sites

  • 2 years later...

Hey,

i need a little help with customization my cart.

 

in the multi shipping total_shipping is too small .

 

total_shipping in my opinion it should look something like:

 

1st product 6 -> packed after 4 -> 2 pack * cost of courier = 1st product ship_cost[0]

2nd product 2 -> packed after 6 -> 1 pack * cost of curier = 2nd product ship_cost[1]

etc.

total_shipping  for(i=0;total_shipping+=ship_cost;i++)

 

meanwhile looks like:

 

1st product 6 * weight + 2nd product 2 * weight + etc = total_weight

total_shipping = courier_cost(total_weight) 

 

how to do this :D

 

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...