Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 2 of 7
AJAX based Shopping Cart
 
ultrasonic
Jr. Member
 
Total Posts:  1
Joined:  2009-03-05
 

yeah they have mentioned,
“As all the other Magento modules, this one is upgrade-proof, which means we never use hacks on core coding of Magneto Commerce solution”

i think it’s worth to buy unless you can make one.

 
Magento Community Magento Community
Magento Community
Magento Community
 
twistedindustries
Member
 
Total Posts:  64
Joined:  2008-06-09
 

Ultrasonic, you make a good point.  I had to do a core hack on one part and I don’t even think it was necessary but I had nobody to help me and this extension wasn’t available at the time.

My question would be how good is the support for the extension?
Can you do custom add ons?

I think this is where utilizing open source and a great community over powers this and if you know how its made you can customize it the way you want and fix it when it breaks.  This is obviously not going to be for everyone as everyone does not wish to be a web master for their store they just want it to work.  If you are that person BUY THE EXTENSION. 

If you are the person that likes to tweak your shop and make it unique well stay tuned as I will be sharing how I made my AJAX cart and hopefully someone that is smarter than me can come by and help us improve but this is all we have right now.

 
Magento Community Magento Community
Magento Community
Magento Community
 
splotch
Jr. Member
 
Total Posts:  3
Joined:  2009-01-08
 

I am currently developing for a client who would like an AJAX powered cart. I would love to see what you’ve done and add improvements where possible. Time is a factor, though and if I can’t get access to your code in the next couple of days, I will have to resort to the commercial plug-in. I’d love to help out if I can get my hands on the code.

 
Magento Community Magento Community
Magento Community
Magento Community
 
xondeo
Member
 
Total Posts:  40
Joined:  2009-04-08
 

twistedindustries, I will be happy to install your code if finally you decide to share it. Don’t be upset if community has not helped you, think not all of us have that level skill with AJAX confused

 
Magento Community Magento Community
Magento Community
Magento Community
 
twistedindustries
Member
 
Total Posts:  64
Joined:  2008-06-09
 

Here is my JS:

function ajaxCartAddProduct (productAddToCartFormId) {

if (productAddToCartFormId) {
var form = jQuery(’#’ + productAddToCartFormId);
} else {
var form = jQuery(’#product_addtocart_form’);
}
var inputs = jQuery(’:input’).serialize();
var infoMessage = jQuery(’.ajax_cart_info’);
var addButton = jQuery(’.form-button-cart’, form);
var content = jQuery(’#ajaxcart’);
var container = jQuery(’#ajaxcart’);
var targetOffset = form.offset().top;
var highslide = jQuery(’.highslide-container’);
var error = jQuery(’#ajaxcarterror’, form);
var success = jQuery(’#ajax-cart-added’);
var carterror = jQuery(’#ajax-cart-error’);
var removed = jQuery(’#ajax-cart-remove’);

content.html(’<br/><div align="center"><img src="http://www.ilovejeans.com/skin/frontend/default/default/images/ajax_cart_loading.gif"/><br/>Updating cart...</div>’);
success.hide()
carterror.hide()
error.hide()
content.hide()
removed.hide()
content.fadeIn(1000, function() {

});
jQuery(’html,body’).animate({scrollTop: 0}, 100);

jQuery.post(form.get(0).action+"?isAjax=1", inputs, function (data, textStatus) {
if (data != ‘bad’){
content.html(data);
success.html(’<span align="left">Product Added.</span>’);
success.fadeIn(1000, function() {
});

}

if (data == ‘bad’){error.html(’<span style="color: #AD001A;">Please specify product options.</span>’);
carterror.html(’<span align="right" style="color: #AD001A; padding-left: 100px;">Please specify product options.</span>’);
error.fadeIn(1000, function() {
});
success.hide()
carterror.fadeIn(1000, function() {
});
jQuery(’html,body’).animate({scrollTop: targetOffset-500}, 100);
content.hide()
content.load("/price/index.php/cart.html");
content.fadeIn(1000, function() {
});

}
content.hide()
content.fadeIn(1000, function() {
});

}, “html");

return false;
}

function ajaxCartAddProductListing (productAddToCartFormId) {

if (productAddToCartFormId) {
var form = jQuery(’#’ + productAddToCartFormId);
var requiredinputs = jQuery(".required-entry", form);
} else {
var form = jQuery(’#product_addtocart_form’);
}

var inputs = jQuery(’:input’).serialize();
var infoMessage = jQuery(’.ajax_cart_info’);
var addButton = jQuery(’.form-button-cart’, form);
var content = jQuery(’#ajaxcart’);
var container = jQuery(’#ajaxcart’);
var targetOffset = form.offset().top;
var highslide = jQuery(’.highslide-container’);
var error = jQuery(’#ajaxcarterror’, form);
var success = jQuery(’#ajax-cart-added’);
var carterror = jQuery(’#ajax-cart-error’);
var removed = jQuery(’#ajax-cart-remove’);

requiredinputs.removeClass("validation-failed");
content.html(’<br/><div align="center"><img src="/skin/frontend/default/default/images/ajax_cart_loading.gif"/><br/>Updating cart...</div>’);
success.hide()
carterror.hide()
error.hide()
content.hide()
removed.hide()
content.fadeIn(1000, function() {

});
jQuery(’html,body’).animate({scrollTop: 0}, 100);

jQuery.post(form.get(0).action+"?isAjax=1", inputs, function (data, textStatus) {
if (data != ‘bad’){
content.html(data);
success.html(’<span align="left">Product Added.</span>’);
success.fadeIn(1000, function() {
});

}

if (data == ‘bad’){error.html(’<span style="color: #AD001A;">Please specify product options.</span>’);
carterror.html(’<span align="right" style="color: #AD001A; padding-left: 100px;">Please specify product options.</span>’);
error.fadeIn(1000, function() {
});
success.hide()
carterror.fadeIn(1000, function() {
});
jQuery(’html,body’).animate({scrollTop: targetOffset-500}, 100);
content.hide()
content.load("/price/index.php/cart.html");
content.fadeIn(1000, function() {
});

}
content.hide()
content.fadeIn(1000, function() {
});

}, “html");

return false;
}

function ajaxCartRemoveProduct(a, removeUrl) {
var content = jQuery(’#ajaxcart’);
var success = jQuery(’#ajax-cart-added’);
var carterror = jQuery(’#ajax-cart-error’);
var removed = jQuery(’#ajax-cart-remove’);

success.hide()
carterror.hide()
removed.hide()

content.html(’<br/><div align="center"><img src="/skin/frontend/default/default/images/ajax_cart_loading.gif"/><br/>Updating cart...</div>’);
content.hide()
content.fadeIn(1000, function() {
});

jQuery.get(removeUrl+’?isAjax=1’, function (data, textStatus) {
content.hide()
content.load("/price/index.php/cart.html");
content.fadeIn(1000, function() {
});
removed.hide()
removed.html(’Product Removed.’);
removed.fadeIn(1000, function() {
});
}, “html");
return false;

}

 
Magento Community Magento Community
Magento Community
Magento Community
 
twistedindustries
Member
 
Total Posts:  64
Joined:  2008-06-09
 

Here is the cor hack app/code/core/Checkout/controllers/CartController.php

<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to so we can send you a copy immediately.
*
* DISCLAIMER
*
*
* @category Mage
* @package Mage_Checkout
* @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

/**
* Shopping cart controller
*/
class Mage_Checkout_CartController extends Mage_Core_Controller_Front_Action
{
/**
* Retrieve shopping cart model object
*
* @return Mage_Checkout_Model_Cart
*/
protected function _getCart()
{
return Mage::getSingleton(’checkout/cart’);
}

/**
* Get checkout session model instance
*
* @return Mage_Checkout_Model_Session
*/
protected function _getSession()
{
return Mage::getSingleton(’checkout/session’);
}

/**
* Get current active quote instance
*
* @return Mage_Sales_Model_Quote
*/
protected function _getQuote()
{
return $this->_getCart()->getQuote();
}

/**
* Set back redirect url to response
*
* @return Mage_Checkout_CartController
*/
protected function _goBack()
{
if (!Mage::getStoreConfig(’checkout/cart/redirect_to_cart’)
&& !$this->getRequest()->getParam(’in_cart’)
&& $backUrl = $this->_getRefererUrl()) {

$this->getResponse()->setRedirect($backUrl);
} else {
if (($this->getRequest()->getActionName() == ‘add’) && !$this->getRequest()->getParam(’in_cart’)) {
$this->_getSession()->setContinueShoppingUrl($this->_getRefererUrl());
}
$this->_redirect(’cart.html’);
}
return $this;
}

/**
* Initialize product instance from request data
*
* @return Mage_Catalog_Model_Product || false
*/
protected function _initProduct()
{
$productId = (int) $this->getRequest()->getParam(’product’);
if ($productId) {
$product = Mage::getModel(’catalog/product’)
->setStoreId(Mage::app()->getStore()->getId())
->load($productId);
if ($product->getId()) {
return $product;
}
}
return false;
}

/**
* Shopping cart display action
*/
public function indexAction()
{
$cart = $this->_getCart();
if ($cart->getQuote()->getItemsCount()) {
$cart->init();
$cart->save();

if (!$this->_getQuote()->validateMinimumAmount()) {
$warning = Mage::getStoreConfig(’sales/minimum_order/description’);
$cart->getCheckoutSession()->addNotice($warning);
}
}

foreach ($cart->getQuote()->getMessages() as $message) {
if ($message) {
$cart->getCheckoutSession()->addMessage($message);
}
}

/**
* if customer enteres shopping cart we should mark quote
* as modified bc he can has checkout page in another window.
*/
$this->_getSession()->setCartWasUpdated(true);

Varien_Profiler::start(__METHOD__ . ‘cart_display’);
$this->loadLayout();
$this->_initLayoutMessages(’checkout/session’);
$this->_initLayoutMessages(’catalog/session’);
$this->getLayout()->getBlock(’head’)->setTitle($this->__(’Shopping Cart’));
$this->renderLayout();
Varien_Profiler::stop(__METHOD__ . ‘cart_display’);
}

/**
* Add product to shopping cart action
*/
public function addAction()
{
$cart = $this->_getCart();
$params = $this->getRequest()->getParams();

$product= $this->_initProduct();
$related= $this->getRequest()->getParam(’related_product’);

/**
* Check product availability
*/
if (!$product) {
$this->_goBack();
return;
}

try {
$cart->addProduct($product, $params);
if (!empty($related)) {
$cart->addProductsByIds(explode(’,’, $related));
}

$cart->save();

$this->_getSession()->setCartWasUpdated(true);

/**
* @todo remove wishlist observer processAddToCart
*/
Mage::dispatchEvent(’checkout_cart_add_product_complete’, array(’product’=>$product, ‘request’=>$this->getRequest()));
$message = $this->__(’%s was successfully added to your shopping cart.’, $product->getName());
if (!$this->_getSession()->getNoCartRedirect(true)) {

$this->_goBack();
}
}
catch (Mage_Core_Exception $e) {
if ($this->_getSession()->getUseNotice(true)) {
} else {
$messages = array_unique(explode("\n", $e->getMessage()));
foreach ($messages as $message) {

}
}

$url = “bad”;
if ($url) {
echo “bad”;
} else {
$this->_redirectReferer(Mage::helper(’checkout/cart’)->getCartUrl());
}
}
catch (Exception $e) {

}

 
Magento Community Magento Community
Magento Community
Magento Community
 
Pankaj Gupta
Jr. Member
 
Total Posts:  10
Joined:  2008-11-29
 

hi!
twistedindustries

Thanks for the code ,but i need to make this in a custom module ,how can i do this.

Any help would be highly appreciated.

Please reply
Many Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
Pankaj Gupta
Jr. Member
 
Total Posts:  10
Joined:  2008-11-29
 

I have done the ajax updation for the side bar cart , but this have done using code in the already placed files.

Now i have to make a custom module for it.  I made a module in local and the function in the local/..  files but when called this function ,it is not called.

Any idea ?

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
twistedindustries
Member
 
Total Posts:  64
Joined:  2008-06-09
 
aheadWorks - 04 May 2009 03:41 AM

srinigenie - 12 March 2009 10:10 PM
Check this one out. Looks interesting

http://www.magentocommerce.com/extension/969/ajaxcart-premium

@ twistedindustries - Would have loved to help you on this one. But felt you might have got a better hand to help. Sorry to hear that you did not.

There is a cheaper alternative by the way:
http://www.magentocommerce.com/extension/1185/ajax-cart-pro

Your right I saw that and I like it a lot.  I am actually going to buy it for another project I have going, I am anxious to get it.

 
Magento Community Magento Community
Magento Community
Magento Community
 
devopensource
Member
 
Avatar
Total Posts:  42
Joined:  2008-04-23
spain
 

hi twistedindustries

your code is working in a magento version 1.3.+ ?

thx for your help tongue rolleye

 
Magento Community Magento Community
Magento Community
Magento Community
 
chrissou
Jr. Member
 
Total Posts:  15
Joined:  2009-07-12
 

I’m currently developping an add ons providing this kind of features.

Actual features:
- AJAX add to cart (no reload, sidecart updated)
- AJAX remove (from sidecart) + “Cancel last delete feature” wich backup product (with the quantity) with no required options
- Javascript “pop-up” (I mean a div) shows when loading + confirmation (with “continue shopping” & “go to cart links”, it disapear after X seconds)
- Custom products options shows in the “pop-up” (still working on it) [can be disabled]
- script.aculo.us effects for pop apparition/disparition and for sidecart update [can be disabled]
- Image zoom when the mouse goes hover a product in sidecart [can be disabled]

What features would you like? I’d love to develop it smile

No demo for now (but sooner!)
The extension will be commercial (still don’t know the price)

 
Magento Community Magento Community
Magento Community
Magento Community
 
chrissou
Jr. Member
 
Total Posts:  15
Joined:  2009-07-12
 

For those interested there is a demo there : Demo

If you have the time, please feedback smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
chrissou
Jr. Member
 
Total Posts:  15
Joined:  2009-07-12
 

I guess you’re talking about your extension.

What’s new :
- support of all product types (simple(custom options included), configurable, ...) I mean the options are displayed using ajax
- Ajax delete/recover from sidecart feature
- image zoom in sidecart
- discount price

 
Magento Community Magento Community
Magento Community
Magento Community
 
chrissou
Jr. Member
 
Total Posts:  15
Joined:  2009-07-12
 

I don’t really see other solutions you are talking about. Are they present in magento connect?

Maybe I’m wrong but I never seen full ajax cart extension supporting all product types.

My extension is not finished yet and I’m planning some new features and I think there are a lot of things not implemented in ajax carts

Can you send me some links of the other solutions?

 
Magento Community Magento Community
Magento Community
Magento Community
 
sino
Member
 
Avatar
Total Posts:  34
Joined:  2008-04-22
 

I am in need to have the custom options, be collapsible & grouped eg: I have products that have a bunch of custom options, I sort of want to bundle them and make them collapsible into groups, would this ajax ext. be able to do that?

Also if possible, looking to have an ajax popup, saying uploading, when a user uploads files throu the custom options

thank you

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 2 of 7