To keep in the product listing page, i've modified includes/modules/product_listing.php
Before:
Code: Select all
<?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_NEW, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '" class="simpleBTN comprar tiny" alt="comprar">';?>
After:
Code: Select all
<?php echo '<a href="' . tep_href_link($PHP_SELF, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '" class="simpleBTN comprar tiny" alt="comprar">';?>
To show the message, I've modified incluces/application_top.php and includes/header.php.
1 - In application_top.php, in "buy_now" action switch, I register two session variables: show_message and show_nombre_producto. The first checks if page has to show the message and the second contains the name of the product that has been purchased.
Code: Select all
switch ($HTTP_GET_VARS['action']) {
[...]
case 'buy_now' :
[...]
tep_session_register('show_message');
$show_nombre_producto = $producto['products_name'];
if (!tep_session_is_registered('show_nombre_producto')) tep_session_register('show_nombre_producto');
tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
break;
2 - In header.php I check if session variable 'show_message' is registered. If true, the message is displayed and 'show_message' variable is unregistered to not show the message in other pages
Code: Select all
if (tep_session_is_registered('show_message')) {
echo "<div class='box_conseguido'>El producto $show_nombre_producto se ha añadido a la cesta correctamente.</div>";
tep_session_unregister('show_message');
}
The problem is that message is not displayed. If i disable line tep_session_unregister('show_message'); in header.php, message is displayed, so i think page is loading twice: the first shows message and unregister the session variable and the second is that is displayed.
This is apache's log:
Code: Select all
xxx.xx.xx.xxx - - [03/Oct/2014:14:44:33 +0200] "GET /cartuchos-de-tinta-47/cartuchos-brother-196/ HTTP/1.1" 200 9334 - Product listing url
xxx.xx.xx.xxx - - [03/Oct/2014:14:44:37 +0200] "GET //index.php?cPath=196&sort=2a&action=buy_now&products_id=987 HTTP/1.1" 301 580 - url when press buy button
xxx.xx.xx.xxx - - [03/Oct/2014:14:44:37 +0200] "GET /index.php?cPath=196&sort=2a HTTP/1.1" 301 9525 - url redirect in application_top.php [ tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); ]
xxx.xx.xx.xxx - - [03/Oct/2014:14:44:39 +0200] "GET /cartuchos-de-tinta-47/cartuchos-brother-196/ HTTP/1.1" 200 9361 - url displayed
I think in third step shows the message and unregister the session variable and is redirected to url of fourth step, but i'm not sure of this and i don't know how to solve it. Please note that it works perfectly in a development environment without Inveo SEO plugin. Only fails in production with SEO plugin.
Please, can anyone help me?
Thank you.