omnipartners / m1-ajax-add-to-cart

Unobtrusive Ajax Add to Cart extension for Magento
3 stars 3 forks source link

Not obvious that item has been added on long pages #2

Closed LiamMcArthur closed 6 years ago

LiamMcArthur commented 7 years ago

I've found that on long product listing pages or when using a mobile device, it isn't obvious that an item has been added to the cart. I've created a pull request #1 that automatically scrolls the user to the top of the page once an item has been successfully added to the cart.

vuleticd commented 7 years ago

Hmm, the "obvious" depends greatly on website design.

For example, the scrollTop would not be desired if website has minicart in sticky header and infinite scrolling or load more pagination of products on category pages. It would bounce user back to top and lose focus on the item being ordered.

Even on standard headers, it's questionable if that bounce back to top would be a good thing. I mean if user is forced to lose focus and "see the cart", then default redirecting to cart page might be better.

I think that this kind of functionality should at least be configurable with ON/OFF switch in system config, and probably best to leave to the implementation team to extend if needed. When extending, it's always better to add functionality instead removing.

For example, updateMinicart method should be possible to extend in custom JS file, with something like this

$j(document).ready(function () {
    OmniAddToCart.prototype.updateMinicart = OmniAddToCart.prototype.updateMinicart.wrap(function(parentMethod){
        parentMethod();
        $j("html, body").animate({scrollTop: 0 }, "slow");
    }
});
LiamMcArthur commented 7 years ago

That's very true and I agree that having configurable options in the config would enable the user to choose if this was a feature they would like to enable for their store or not. I based the idea on the standard RWD theme I'm using which doesn't have a sticky header, but does have a long product list page.