Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / Customizing the Look of Your Shop / Templates, Stylesheets, Page Layout / Moving the "Successfully added to cart" message on the product info page

Moving the "Successfully added to cart" message on the product info page

16 May 2014, 5:12 AM
#1
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Post #1 by divavocals

Following this post: **"Successfully added to cart" message stack - change position**, I too wanted to display the message stack in a different place on the product info page. Like the OP in that thread I too am looking at implementing changes suggested by Eric Leuenberger. (Simple Google Analytics author)

The old thread may not be clear for everyone stumbling upon it.. Plus the changes suggested are based on Zen Cart v1.3.x code.. So wanted to share what I did to update this to use with Zen Cart v1.5.1..

First go to Configuration > My Store > Display Cart After Adding Product, change the value to "False".

Then find the following in includes/templates/yourtemplate/common/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']), ENT_COMPAT, CHARSET, TRUE);
  }
  if (isset($_GET['info_message']) && zen_not_null($_GET['info_message'])) {
   echo htmlspecialchars($_GET['info_message'], ENT_COMPAT, CHARSET, TRUE);
} else {

}
?>

Replace with:

<?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']), ENT_COMPAT, CHARSET, TRUE);
  }
  if (isset($_GET['info_message']) && zen_not_null($_GET['info_message'])) {
   echo htmlspecialchars($_GET['info_message'], ENT_COMPAT, CHARSET, TRUE);
} else {

}
}
?>

Then in includes/templates/yourtemplates/templates/tpl_product_info_display.php delete this:

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

Then in the same file (includes/templates/yourtemplates/templates/tpl_product_info_display.php), I added this code where I wanted the message alert to appear on the product info page

<?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']), ENT_COMPAT, CHARSET, TRUE);
  }
  if (isset($_GET['info_message']) && zen_not_null($_GET['info_message'])) {
   echo htmlspecialchars($_GET['info_message'], ENT_COMPAT, CHARSET, TRUE);
} else {

}
?>

It appears to work just fine.. Hoping to get input from others if they see anything that isn't kosher here..

My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

16 May 2014, 3:52 PM
#2
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Post #2 by divavocals

Now wondering how to do this on the product listing pages as well.. What I want to do is move the message stack from the very top position to say just above the text that says "Displaying 1 to.."

Will play around with this, but thinking this may be a tad over my head.. Particularly the change that has to happen in the in includes/templates/yourtemplate/common/tpl_header.php file.. Hoping someone from the community can chime in..

My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

2 Aug 2021, 7:11 AM
#3
rlexyd avatar

rlexyd

Zen Follower

Join Date:
Nov 2006
Location:
Sydney, Australia
Posts:
507
Plugin Contributions:
0

Post #3 by rlexyd

DivaVocals:

Now wondering how to do this on the product listing pages as well.. What I want to do is move the message stack from the very top position to say just above the text that says "Displaying 1 to.."

Will play around with this, but thinking this may be a tad over my head.. Particularly the change that has to happen in the in includes/templates/yourtemplate/common/tpl_header.php file.. Hoping someone from the community can chime in..

Thank you for that, I just followed your easy instructions (but had to update the code to match the 1.5.7c tpl_header.php file and it worked fine on product info page :)
Did you ever figure this out the other pages like **Show All Products **or when you click on Category pages as well??

*Zen Cart eCommerce Solution - Putting the Dream of Owning an Online Business within reach of anyone!

8 Aug 2021, 9:49 PM
#4
rlexyd avatar

rlexyd

Zen Follower

Join Date:
Nov 2006
Location:
Sydney, Australia
Posts:
507
Plugin Contributions:
0

Post #4 by rlexyd

Any luck??

*Zen Cart eCommerce Solution - Putting the Dream of Owning an Online Business within reach of anyone!