Zen Follower
- Join Date:
- Oct 2006
- Location:
- At Home
- Posts:
- 357
- Plugin Contributions:
- 0
Views: 8,795
Zen Follower
Totally Zenned
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 ;)
Totally Zenned
would be interested too. :lookaroun
Zen Follower
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:
New Zenner
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! :)
Zen Follower
Sweet! Nice post. I now understand better how to move things around.:clap:
Sensei
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.
Zen Follower
Is it possible to put an if statement into the header -
if this is the product info page then don't display
I'm just thinking out loud - will try experimenting with this in the next couple of days.
Sensei
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.
Zen Follower
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.
Sensei
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.
Zen Follower
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.
Zen Follower
How do we display this and or turn it off. where is the button in the admin again?
Zen Follower
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.
Totally Zenned
Did you still move the alert to your product info page and added that if statement or just added that if statement?
Totally Zenned
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...
Zen Follower
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).
New Zenner
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.
Tell staff why this post should be reviewed.