Jump to content

[Solved] modify block shopping cart


bonbontamura

Recommended Posts

I'd like to hide the checkout button in the block cart if the cart empty (AJAX is activated)
so if the cart is empty, the customer don't see the button so they can't go to order-opc.php for example.
only after the customer add product, the ajax cart updated automatically and the checkout button (what I wish) appears so the customer can go to the checkout process

can someone help me?

Link to comment
Share on other sites

Hi,
If you're using version 1.4.1.0 you must edit the function updateCartEverywhere (line 555) in file modules/blockcart/ajax-cart.js

from line 565 to 567
BEFORE:

$('.ajax_cart_quantity').fadeIn('slow');
$('.ajax_cart_total').fadeIn('slow');


AFTER:

$('.ajax_cart_quantity').fadeIn('slow');
$('.ajax_cart_total').fadeIn('slow');
$('#button_order_cart').fadeIn('slow');



at line 593
BEFORE:

$('.ajax_cart_quantity, .ajax_cart_product_txt_s, .ajax_cart_product_txt, .ajax_cart_total').each( function () {


AFTER:

$('#button_order_cart, .ajax_cart_quantity, .ajax_cart_product_txt_s, .ajax_cart_product_txt, .ajax_cart_total').each( function () {

Link to comment
Share on other sites

hallo,

thanks alot for the solution. you are great. I really appreciate it.
it works (almost) well.

the only problem I have is: if you add a product, the button doesn't appear automatically but you have to refresh the page manually or visit another page first. Then the cart will show the button.

do you know maybe what's wrong?

regards

Link to comment
Share on other sites

In my installation it's perfect.
Are you using PS 1.4.1.0?
Is ajax enabled?
What happens when you remove the last product from the cart?
Can you verify if the updateCartEverywhere is called each time you add a product? (with firebug or with an alert in the code)

Link to comment
Share on other sites

actually I am using the version 1.4.2.0 (the developer gives me this version for testing).
I was having many problem with the version 1.4.1.0 for examples the problem with the order tab in the back office.

Ajax is enabled. strangely enough is if I remove the last product in the cart, the button will disappear directly together with the product (exactly what I want. it also means the ajax works well, doesn't it?) but it doesnt appear automatically if you add product in the cart.

I check the javascript file ajax-cart.js using the web inspector (Firebug but in the safari) and there are no errors

Link to comment
Share on other sites

I noticed that when you load a page and your cart is empty the button is visible for a moment and than disappears.
To avoid this behaviour add

style="display:none"

to the button (file blockcart.tpl)

Link to comment
Share on other sites

hallo apug,

thanks alot for your solution.
I tried already several times in my shop version 1.4.2.0 and I still have same problem.
I can not force the customer to refresh the page or to visit another page first before they are able to check out.
since I will not downgrade my shop to version 1.4.1.0 and the version 1.4.2.0 is coming soon, I think I have to deal with this.

Another Idea (maybe it will be easier):
if the cart is empty, the button should be there BUT the customer can not click it. only if they add a product to the cart, it means the cart isn't empty anymore, they can click the button to check out.

is it possible?
I thank you very much for your help and wish you a good day!

Link to comment
Share on other sites

Hi bonbontamura,
can you compare old and new version of ajax-cart.js?
the code that hide the button when you remove the last product is inside an "else" block;
the code that shows the button (

$('#button_order_cart').fadeIn('slow');

) must be inside the "if" block if(parseInt(jsonData.nbTotalProducts) > 0)


Another Idea (maybe it will be easier):
if the cart is empty, the button should be there BUT the customer can not click it. only if they add a product to the cart, it means the cart isn't empty anymore, they can click the button to check out.
is it possible?


Yes, it's possible, you can swap the link with an image or add a css class "disabled" with a different background-image and unbind onclick event.
But first you have to solve your problem because you have to do it in that block of code :(

Bye^2
Link to comment
Share on other sites

hallo apug,

first I have to say thanks alot, that you do response very quickly. you are very helpful :)
I checked the file "ajax-cart.js" from version 1.4.0.17, 1.4.1.0 and 1.4.2.0. the very good news is all three files are same. it means they didn't change anything in this file.

logically, there must be something wrong with my shop. so I tried this morning your solution on a very fresh installed shop version 1.4.2.0 with the original prestashop theme. and it works perfect without any problem.
so I found out, that my theme (the free matrice theme) causes this problem. if i change the theme from the original to the my free theme, the problem appears again. I see that this free theme doesn't touch the original blockcart module. this themes just modify the css files. in the theme/css' folder I found one css file names "blockcss.css", if I delete this css file, I still have to face with this problem.

so I think I have to find out the solution in the "global.css" file.
maybe you have any idea, what should I change in my global.css file.

I would be very glad, if you visit my shop at http://testnob.x10.bz/test/ maybe you could help me to find the solution.

have a good day apug!
regards

Link to comment
Share on other sites

Hi bonbontamura,
I think you have to repeat your thanks :-P because I found the problem:
in your site there are tree links with id="button_order_cart"
you have to rename two of them
another solution (but I didn't try it ) could be to change line

$('#button_order_cart').fadeIn('slow');


in

$('#cart-buttons #button_order_cart').fadeIn('slow');



bye^2

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