The information in this thread might be outdated
If the solution did not help, please, check our Help Portal or contact Ecwid Team.
 
 
Thread Tools Display Modes
  #1  
Old 05-22-2014, 08:26 AM
Luminette Lucimed's Avatar
Luminette Lucimed is offline
 
Join Date: Jul 2012
Posts: 7
Default


I would like to redesign the "add to cart" button so I created a custom button :

Code:
<a class="btn btn-large add-to-cart" data-single-product-id="36382049">Ajouter au panier</a>
with such method :

Code:
$('.add-to-cart').click(function() {
    var id_product = $(this).data('single-product-id');
    Ecwid.Cart.addProduct(id_product);
});
My problem is that I would like to show the shopping cart after product addition. I know that it's possible to define a callback method but can't find the method to call to open the cart.

Can you help ?

Nobody ?

Last edited by Liza; 05-23-2014 at 06:46 AM.
  #2  
Old 05-28-2014, 12:30 PM
Maya's Avatar
Maya Maya is offline
Ecwid Team
 
Join Date: Feb 2010
Location: Ecwid headquarter
Posts: 5,876
Default

Quote:
Originally Posted by Luminette Lucimed View Post
I would like to redesign the "add to cart" button so I created a custom button :

Code:
<a class="btn btn-large add-to-cart" data-single-product-id="36382049">Ajouter au panier</a>
with such method :

Code:
$('.add-to-cart').click(function() {
    var id_product = $(this).data('single-product-id');
    Ecwid.Cart.addProduct(id_product);
});
My problem is that I would like to show the shopping cart after product addition. I know that it's possible to define a callback method but can't find the method to call to open the cart.

Can you help ?

Nobody ?
Hello,

I'm sorry for delay with answer.

In order to execute this script properly, Ecwid main script should be added on your page. Please, make sure you have following script installed:
Code:
<script type="text/javascript" src="http://app.ecwid.com/script.js?STORE_ID" charset="utf-8"></script>
where STORE_ID should be changed to ID of your store.

Once you do this, script will work as expected.

Good luck!
__________________
Maya N., Ecwid Team

------------------
Welcome to our new Help Center!
  #3  
Old 05-29-2014, 01:15 PM
Luminette Lucimed's Avatar
Luminette Lucimed Luminette Lucimed is offline
 
Join Date: Jul 2012
Posts: 7
Default

Hi Maya,

This is not the problem, Ecwid main script is added properly and the script works as expected.

My question is : How to open (show) the minicart after adding a product in it (in the addProduct callback method).

I found a "quick and dirty" solution, but I'm not entirely happy with that

Code:
$('.add-to-cart').click(function() {
	var id_product = $(this).data('single-product-id');
	Ecwid.Cart.addProduct({
		id: id_product,
		callback: function(success, product, cart){
			console.log(success); // true or false
			console.log(product.name);
			$('.gwt-InlineLabel').click();
		}
	});
});
  #4  
Old 05-30-2014, 02:37 PM
Maya's Avatar
Maya Maya is offline
Ecwid Team
 
Join Date: Feb 2010
Location: Ecwid headquarter
Posts: 5,876
Default

Hello,

You'd better to change your store URL hash to redirect customer to cart page, where "Add to cart" button is clicked. Use following code:
Code:
window.location.hash = "#!/~/cart";
Thus, you will get following code:
Code:
$('.add-to-cart').click(function() {
	var id_product = $(this).data('single-product-id');
	Ecwid.Cart.addProduct({
		id: id_product,
		callback: function(success, product, cart){
			console.log(success); // true or false
			console.log(product.name);
                        window.location.hash = "#!/~/cart";
		}
	});
});
Good luck!
__________________
Maya N., Ecwid Team

------------------
Welcome to our new Help Center!
The Following User Says Thank You to Maya For This Useful Post:
Luminette Lucimed (05-30-2014)
 
The information in this thread might be outdated
If the solution did not help, please, check our Help Portal or contact Ecwid Team.

Tags
api, cart, javascript, open, show

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:25 AM.
Powered by vBulletin® Version 3.8.11. Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.