Zen Cart Logo
Forums / General Questions / "Successfully added to cart" message stack - change position

"Successfully added to cart" message stack - change position

Locked

Views: 8,795

Results 1 to 18 of 18
This thread is locked. New replies are disabled.
13 Jul 2008, 12:37 PM
#1
miles avatar

miles

Zen Follower

Join Date:
Oct 2006
Location:
At Home
Posts:
357
Plugin Contributions:
0

"Successfully added to cart" message stack - change position

Any idea how to place 'success message stack' from the header to underneath product price in product info page just like the attached image shown below?

16 Jul 2008, 8:10 PM
#2
lissae avatar

lissae

Totally Zenned

Join Date:
Oct 2007
Location:
Australia
Posts:
814
Plugin Contributions:
0

Re: "Successfully added to cart" message stack - change position

I'd like to do this too, anyone know how? I believe the main area is in tpl_header.php

<?php
  // Display all header alerts via messageStack:
  if ($messageStack->size('header') > 0) {
    echo $messageStack->output('header');
  }
  if (isset($_GET['error_message']) && zen_not_null($_GET['error_message'])) {
  echo htmlspecialchars(urldecode($_GET['error_message']));
  }
  if (isset($_GET['info_message']) && zen_not_null($_GET['info_message'])) {
   echo htmlspecialchars($_GET['info_message']);
} else {

}
?>

And then there is this in tpl_product_info_display.php

<?php if ($messageStack->size('product_info') > 0) echo $messageStack->output('product_info'); ?>

So if I put the top code from the header into the info page where I want it, the message will display there, but how do I stop it from also displaying at the top of the page?

Can anyone help? lol thanx ;)

16 Sep 2008, 8:23 PM
#3
mydanilo avatar

mydanilo

Totally Zenned

Join Date:
Dec 2004
Posts:
1,024
Plugin Contributions:
0

Re: "Successfully added to cart" message stack - change position

would be interested too. :lookaroun

20 Dec 2008, 1:42 PM
#4
miles avatar

miles

Zen Follower

Join Date:
Oct 2006
Location:
At Home
Posts:
357
Plugin Contributions:
0

Re: "Successfully added to cart" message stack - change position

Ok, here what I did.

Find: includes/templates/yourtemplate/common/tpl_header.php

Cut out this code:

<?php
  // Display all header alerts via messageStack:
  if ($messageStack->size('header') > 0) {
    echo $messageStack->output('header');
  }
  if (isset($_GET['error_message']) && zen_not_null($_GET['error_message'])) {
  echo htmlspecialchars(urldecode($_GET['error_message']));
  }
  if (isset($_GET['info_message']) && zen_not_null($_GET['info_message'])) {
   echo htmlspecialchars($_GET['info_message']);
} else {

}
?>
```Then open: includes/templates/*yourtemplates*/templates/**tpl_product_info_display.php**

Paste the above code to anywhere, for example after
<!--eof Reviews button and count -->

Edit CSS to your likely,

.messageStackSuccess {
background-color:red;
color:#000;
}

Then try to add your product to the cart and see how it goes.:wink:
18 Oct 2009, 9:30 AM
#5
gillianfoley avatar

gillianfoley

New Zenner

Join Date:
Aug 2008
Posts:
13
Plugin Contributions:
0

Re: "Successfully added to cart" message stack - change position

Thanks for sharing, Miles! I've been searching for a nifty ajax-like mod or such :wacko: but just couldn't find one. This will work for me! Thanks! :)

18 Oct 2009, 11:17 AM
#6
magicman avatar

magicman

Zen Follower

Join Date:
Oct 2007
Location:
MA, USA
Posts:
385
Plugin Contributions:
0

Re: "Successfully added to cart" message stack - change position

Sweet! Nice post. I now understand better how to move things around.:clap:

19 Oct 2009, 3:12 AM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: "Successfully added to cart" message stack - change position

Keep in mind that MOVING that from the header file into the product-info file specifically will prevent ALL other pages EVERYWHERE on your site from ever seeing any alert messages intended to be shown. And, COPYING instead it will cause duplicates on your product-info page.

19 Oct 2009, 6:31 PM
#8
paul3648 avatar

paul3648

Zen Follower

Join Date:
Mar 2007
Location:
Taiwan
Posts:
239
Plugin Contributions:
0

Re: "Successfully added to cart" message stack - change position

Is it possible to put an if statement into the header -

if this is the product info page then don't display

  • so that we can have a custom placement of the "product added" alert, and other alerts won't be affected?

I'm just thinking out loud - will try experimenting with this in the next couple of days.

19 Oct 2009, 6:37 PM
#9
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: "Successfully added to cart" message stack - change position

To some degree, yes. But what you're all trying to do is mimic ajax-like behavior, and many do that very badly. The biggest problem I see with people doing that is they bypass the shopping-cart page but never provide a clear easy-to-find link to see the actual cart contents and/or begin checkout. Huge mistake IMO.

Nevertheless, if you're trying to deal specifically with positioning the "product added" alert, it would be a whole lot easier to set it to use its own messageStack class in the shopping-cart class and then echo only that particular messageStack class in the middle of your product page.

20 Oct 2009, 1:34 PM
#10
paul3648 avatar

paul3648

Zen Follower

Join Date:
Mar 2007
Location:
Taiwan
Posts:
239
Plugin Contributions:
0

Re: "Successfully added to cart" message stack - change position

DrByte:

To some degree, yes. But what you're all trying to do is mimic ajax-like behavior, and many do that very badly. The biggest problem I see with people doing that is they bypass the shopping-cart page but never provide a clear easy-to-find link to see the actual cart contents and/or begin checkout.

I can't speak for anyone else, but the reason I want this change is that my site is set to stay on the product info page after adding an item to the cart, and the green "added successfully" notice in the header is not really obvious, so it sometimes seems that nothing has happened when you add the item. By placing the notification within the product description, near the "add to cart button" they've just clicked, there's no confusion about what has just happened.

20 Oct 2009, 5:35 PM
#11
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: "Successfully added to cart" message stack - change position

paul3648:

I can't speak for anyone else, but the reason I want this change is that my site is set to stay on the product info page after adding an item to the cart ...
In my experience, most stores who configure their cart that way make a HUGE mistake ... they have only a single little tiny button hidden somewhere for actually starting checkout.
If it's not clear how to proceed to checkout, people won't.
On the Shopping Cart page, it's very clear how to proceed to checkout and actually buy what one has been shopping for.

If you want to skip the use of the shopping-cart page, feel free ... but do your customers a favor and make sure you add a large "Proceed to Checkout" and/or "View My Shopping Cart Contents" button prominently in the upper half of the site.

21 Oct 2009, 3:24 AM
#12
paul3648 avatar

paul3648

Zen Follower

Join Date:
Mar 2007
Location:
Taiwan
Posts:
239
Plugin Contributions:
0

Re: "Successfully added to cart" message stack - change position

DrByte:

If you want to skip the use of the shopping-cart page, feel free ... but do your customers a favor and make sure you add a large "Proceed to Checkout" and/or "View My Shopping Cart Contents" button prominently in the upper half of the site.

Yes, that's a good idea. The person who started this thread got the idea of moving the "added to cart" confirmation from the zencartoptimization site, which has a lot of good ideas about how to streamline your website. As I recall, the idea behind staying on the product info page after selecting an item is to encourage more buying, and also to decrease confusion - "I'm on the shopping cart page, so I guess I have to checkout now."

The zencartoptimization idea seemed like a good idea at the time, but I suppose there are other ways to approach this - putting a big "continue shopping" button on the shopping cart page would be one.

21 Oct 2009, 3:05 PM
#13
magicman avatar

magicman

Zen Follower

Join Date:
Oct 2007
Location:
MA, USA
Posts:
385
Plugin Contributions:
0

Re: "Successfully added to cart" message stack - change position

How do we display this and or turn it off. where is the button in the admin again?

31 Oct 2009, 4:56 AM
#14
paul3648 avatar

paul3648

Zen Follower

Join Date:
Mar 2007
Location:
Taiwan
Posts:
239
Plugin Contributions:
0

Re: "Successfully added to cart" message stack - change position

I added an if statement to the includes/templates/YOUR_TEMPLATE/common/tpl_header.php file as so:

<!--bof Add to Cart Alert--> <?php if ($current_page_base == 'product_info'){ //do nothing } else { // Display all header alerts via messageStack: if ($messageStack->size('header') > 0) { echo $messageStack->output('header'); } if (isset($_GET['error_message']) && zen_not_null($_GET['error_message'])) { echo htmlspecialchars(urldecode($_GET['error_message'])); } if (isset($_GET['info_message']) && zen_not_null($_GET['info_message'])) { echo htmlspecialchars($_GET['info_message']); } else { } } ?> <!--eof Add to Cart Alert-->

This prevents the header alert from showing up on the product_info pages, but allows other alerts to show correctly. This is important if your product listing pages have an "add to cart" button that doesn't redirect them to the product page - the "add to cart" alert will show up properly.

I also moved the alert to the bottom of the header - just before the final </div>. This brings the alert closer to the eye level and more obvious.

4 Dec 2009, 3:45 AM
#15
berserker avatar

berserker

Totally Zenned

Join Date:
May 2006
Posts:
712
Plugin Contributions:
0

Re: "Successfully added to cart" message stack - change position

Did you still move the alert to your product info page and added that if statement or just added that if statement?

4 Dec 2009, 3:59 AM
#16
berserker avatar

berserker

Totally Zenned

Join Date:
May 2006
Posts:
712
Plugin Contributions:
0

Re: "Successfully added to cart" message stack - change position

Ok...I think I got the message in the product info page by adding the following to the tpl_product_info_display

<?php // Display all header alerts via messageStack: if ($messageStack->size('header') > 0) { echo $messageStack->output('header'); } if (isset($_GET['error_message']) && zen_not_null($_GET['error_message'])) { echo htmlspecialchars(urldecode($_GET['error_message'])); } if (isset($_GET['info_message']) && zen_not_null($_GET['info_message'])) { echo htmlspecialchars($_GET['info_message']); } else { } ?>

And then adding paul3648's code to my tpl_header.

Everything seems to work but can someone please tell me what other messages are supposed to appear in the header apart from the "Successfully added product to cart" so I can test it out and see if they disappeared or not.

All the best...

4 Dec 2009, 8:46 PM
#17
paul3648 avatar

paul3648

Zen Follower

Join Date:
Mar 2007
Location:
Taiwan
Posts:
239
Plugin Contributions:
0

Re: "Successfully added to cart" message stack - change position

Berserker:

...what other messages are supposed to appear in the header apart from the "Successfully added product to cart" so I can test it out and see if they disappeared or not.

If you have an "add to cart" button on your product listing page - the one that shows a list of your all products - an "added to cart" alert should appear on that page (if you don't take the customer to the cart immediately).

7 Dec 2009, 3:38 AM
#18
quickinks avatar

quickinks

New Zenner

Join Date:
Jan 2009
Location:
Falkirk-Scotland
Posts:
58
Plugin Contributions:
0

Re: "Successfully added to cart" message stack - change position

Hi guys,

Great thread and just what I was looking for.
I've tried to follow the advice/suggestion here and it has worked but I get the "Successfully added Product to the cart.." alert showing where I want and also at the top of the page as it used to.

I added the suggested code to my tpl_header.php file and to my tpl_product_info_display file.

Take it I've missed something out? Any suggestions?

Berserker, I noticed you have it working ok on your site.