I have tried looking in the module API, but it's pretty much Greek to me.
Is there a system such that a message set by a module will be displayed at the top of the next page that is loaded?
I.e. Customer clicks "Add to Cart" on a product detail page, and gets taken back to the main products page and sees a highlighted message that says "Foo was added to your cart".
Yes, there is a my-cart box on the page, but the client gets the impression that if there isn't a message displayed, the adding has failed. They don't want the add-to cart page to go to the full cart view, as they want the customer to select more products without having to "contunue shopping".
Also, where is the best place to set such a message?
Maintainability suggests somewhere in-database-and-not-overwritten-by upgrades (i.e. a template), but logic suggests it needs to be based on the success of the add to cart action?
Notifying successful add-to-cart (Calguys Commerce)
Re: Notifying successful add-to-cart (Calguys Commerce)
You can use the My Cart call and have it show: 0 items in your cart and if item added it will show how many, this can be a small thing in top of site or wherever you want it, I use this method a lot the time...
Re: Notifying successful add-to-cart (Calguys Commerce)
I've once made the cart submission 'ajaxified'. Then you can show whatever you like before/after/during submission to the cart.
Unfortunatelly the Cart part is not public (only registered dealers) can use it.
In this case I used a kind of (ugly) animation of the product moving into the cart at the top of the page. The Cart also updates after submission and the page will NOT reload, so easy for the visitor to continue shopping.
Unfortunatelly the Cart part is not public (only registered dealers) can use it.
In this case I used a kind of (ugly) animation of the product moving into the cart at the top of the page. The Cart also updates after submission and the page will NOT reload, so easy for the visitor to continue shopping.
Re: Notifying successful add-to-cart (Calguys Commerce)
Velden, it would be awesome if you could set up a stripped down demo of that implementation somewhere public so others can learn from it. As you might remember I was wondering about the same thing before.
Re: Notifying successful add-to-cart (Calguys Commerce)
Hi, I do have a demo version (temporary though) which I'll be happy to provide a temporary customer account for. Please send a PM if interested.
Below I'll post some relevant code from the template. There might be an obsolete function in it but don't have time to look at that now (don't fix what's not broken did remove some
).
Below I'll post some relevant code from the template. There might be an obsolete function in it but don't have time to look at that now (don't fix what's not broken did remove some

Code: Select all
{* update contents of div where cart is shown *}
function updateCart() {
$("#mycart").load(
"{module_action_link module='Cart2' action='mycart' urlonly=1 jsfriendly=1}",
{ 'showtemplate' : 'false' },
function() { }
)
};
{* Ajaxify pagination links *}
function ajaxifyPaginationLinks() {
$(".pagination a").click(
function(event) {
event.preventDefault();
var url = $(this).attr("href");
showItems(url);
}
)
};
{* buttons of cart should be ajaxified. For logged in customers only *}
{cc_protect group='Customers' nocache}
function ajaxifyCartButtons() {
$('.frm_cart form').on( "submit", function( event ) {
event.preventDefault();
var posturl = $(this).attr("action") + "?showtemplate=false";
var postdata = $(this).serialize();
/* ajax */
$.post(posturl,postdata,function() {
//we don't display returned data
// but update cart
updateCart();
});
});
}
{/cc_protect}
{* display Products items *}
{* filter items based on checkboxes *}
function showItems(url) {
//disabled filter checkboxes
$("#filter input").attr("disabled",true)
$('#filter').addClass('disabled');
//show loading gif
$('span#loader').addClass('loading');
//array of to be excluded categories/brands
var excats = [];
//put UNchecked brands to array
$('.cb-filter:not(:checked)').each(function() {
excats.push($(this).val());
});
var data = { 'showtemplate' : 'false' };
var url2 = '{module_action_link module='Products' action='default' urlonly=1 jsfriendly=1}';
if (typeof(url) !== 'undefined') { url2 = url }
{* get productActionId from url, needed for extra parameter excludecats *}
var productActionId = url2.match(/Products,([^,]+),/)[1];
data[productActionId + 'excludecat'] = excats.toString();
$("#shopen-products").load(url2, data, function(){
{cc_protect group='Customers' nocache}ajaxifyCartButtons();{/cc_protect}
ajaxifyPaginationLinks();
$("#shopen-products").foundation();
$("#filter input").removeAttr("disabled")
$('span#loader').removeClass('loading');
$('#filter').removeClass('disabled');
} );
} ;