[Zen Cart] redirects to home after buy-now from listing

Magic SEO URLs for Zen Cart.
experimedia
Posts: 10
Joined: Sun Jan 13, 2013 9:31 pm

Re: [Zen Cart] redirects to home after buy-now from listing

Postby experimedia » Mon Jan 14, 2013 2:32 pm

Ok setup some before and after tests here.

Setup two fresh default zen cart installs.

http://test.experimedia.net = without MSU
http://test2.experimedia.net = with MSU

These 3 basic function settings in ZC have been changed to following in order to illustrate the issue...
My Store > Display Cart After Adding Product = false
Product Listing > Display Multiple Products Qty Box Status and Set Button Location = 0
New Listing > Display Multiple Products Qty Box Status and Set Button Location = 0

First...
goto // http://test.experimedia.net/index.php?m ... oducts_new
Click any product's buy now button.
You will see that when you will stay on that page with the "Successfully added Product to the cart ..."

Second...
goto // http://test2.experimedia.net/new-products/
Click any product's buy now button.
You will see that you instead of staying on the page with the added to cart notification you are instead redirected to the index page.


Now also try the same thing with category product listings...
http://test.experimedia.net/index.php?m ... cPath=3_10
vs
http://test2.experimedia.net/dvd-movies-3/action-10/

This issue only occurs when you are adding to cart via product listings... featured, new, specials, or categories. When adding to cart from the product info pages everything works as it should.

From what I understand the file /includes/init_includes/init_cart_handler.php is what controls all these 'buy now' redirect functions. So perhaps there is something clashing between the MSU htaccess rewrites and the functions in that file.

Here is another potential clue which I find odd...
Lets jump over to featured product listing which I have set to...
Display Multiple Products Qty Box Status and Set Button Location = 3
Which gives the other approach to shopping via listings with the quantity boxes and "add selected products" buttons at the top and bottom.

In this scenario everything works correctly and the same....
http://test.experimedia.net/index.php?m ... sp_order=1
vs
http://test2.experimedia.net/featured-products/

So the issue only occurs when a listing section is set to...
Display Multiple Products Qty Box Status and Set Button Location = 0

Let me know if this gives you any clues as to what might be going on.

inveo
Inveo Support
Posts: 1285
Joined: Sat Feb 02, 2008 12:07 pm
Contact:

Re: [Zen Cart] redirects to home after buy-now from listing

Postby inveo » Mon Jan 14, 2013 3:01 pm

Please post content of includes/configure.php files of both sites.

experimedia
Posts: 10
Joined: Sun Jan 13, 2013 9:31 pm

Re: [Zen Cart] redirects to home after buy-now from listing

Postby experimedia » Mon Jan 14, 2013 8:10 pm

test.experimedia.net // without MSU

Code: Select all

<?php
/**
 * @package Configuration Settings circa 1.5.1
 * @copyright Copyright 2003-2012 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * File Built by zc_install on 2013-01-14 12:17:19
 */


/*************** NOTE: This file is similar, but DIFFERENT from the "admin" version of configure.php. ***********/
/***************       The 2 files should be kept separate and not used to overwrite each other.      ***********/

// Define the webserver and path parameters
  // HTTP_SERVER is your Main webserver: eg-http://www.your_domain.com
  // HTTPS_SERVER is your Secure webserver: eg-https://www.your_domain.com
  define('HTTP_SERVER', 'http://test.experimedia.net');
  define('HTTPS_SERVER', 'https://test.experimedia.net');

  // Use secure webserver for checkout procedure?
  define('ENABLE_SSL', 'false');

// NOTE: be sure to leave the trailing '/' at the end of these lines if you make changes!
// * DIR_WS_* = Webserver directories (virtual/URL)
  // these paths are relative to top of your webspace ... (ie: under the public_html or httpdocs folder)
  define('DIR_WS_CATALOG', '/');
  define('DIR_WS_HTTPS_CATALOG', '/');

  define('DIR_WS_IMAGES', 'images/');
  define('DIR_WS_INCLUDES', 'includes/');
  define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/');
  define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/');
  define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/');
  define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/');
  define('DIR_WS_DOWNLOAD_PUBLIC', DIR_WS_CATALOG . 'pub/');
  define('DIR_WS_TEMPLATES', DIR_WS_INCLUDES . 'templates/');

  define('DIR_WS_PHPBB', '/');

// * DIR_FS_* = Filesystem directories (local/physical)
  //the following path is a COMPLETE path to your Zen Cart files. eg: /var/www/vhost/accountname/public_html/store/
  define('DIR_FS_CATALOG', '/home/xxxxxx/test.experimedia.net/');

  //the following path is a COMPLETE path to the /logs/ folder  eg: /var/www/vhost/accountname/public_html/store/logs ... and no trailing slash
  define('DIR_FS_LOGS', '/home/xxxxxx/test.experimedia.net/logs');

  define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');
  define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/');
  define('DIR_WS_UPLOADS', DIR_WS_IMAGES . 'uploads/');
  define('DIR_FS_UPLOADS', DIR_FS_CATALOG . DIR_WS_UPLOADS);
  define('DIR_FS_EMAIL_TEMPLATES', DIR_FS_CATALOG . 'email/');

// define our database connection
  define('DB_TYPE', 'mysql');
  define('DB_PREFIX', 'zen_');
  define('DB_CHARSET', 'utf8');
  define('DB_SERVER', 'xxxxxx');
  define('DB_SERVER_USERNAME', 'xxxxxx');
  define('DB_SERVER_PASSWORD', 'xxxxxx');
  define('DB_DATABASE', 'xxxxxx');

  // The next 2 "defines" are for SQL cache support.
  // For SQL_CACHE_METHOD, you can select from:  none, database, or file
  // If you choose "file", then you need to set the DIR_FS_SQL_CACHE to a directory where your apache
  // or webserver user has write privileges (chmod 666 or 777). We recommend using the "cache" folder inside the Zen Cart folder
  // ie: /path/to/your/webspace/public_html/zen/cache   -- leave no trailing slash 
  define('SQL_CACHE_METHOD', 'database');
  define('DIR_FS_SQL_CACHE', '/home/xxxxxx/test.experimedia.net/cache');

// EOF


test2.experimedia.net // with MSU

Code: Select all

<?php
/**
 * @package Configuration Settings circa 1.5.1
 * @copyright Copyright 2003-2012 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * File Built by zc_install on 2013-01-14 12:25:55
 */


/*************** NOTE: This file is similar, but DIFFERENT from the "admin" version of configure.php. ***********/
/***************       The 2 files should be kept separate and not used to overwrite each other.      ***********/

// Define the webserver and path parameters
  // HTTP_SERVER is your Main webserver: eg-http://www.your_domain.com
  // HTTPS_SERVER is your Secure webserver: eg-https://www.your_domain.com
  define('HTTP_SERVER', 'http://test2.experimedia.net');
  define('HTTPS_SERVER', 'https://test2.experimedia.net');

  // Use secure webserver for checkout procedure?
  define('ENABLE_SSL', 'false');

// NOTE: be sure to leave the trailing '/' at the end of these lines if you make changes!
// * DIR_WS_* = Webserver directories (virtual/URL)
  // these paths are relative to top of your webspace ... (ie: under the public_html or httpdocs folder)
  define('DIR_WS_CATALOG', '/');
  define('DIR_WS_HTTPS_CATALOG', '/');

  define('DIR_WS_IMAGES', 'images/');
  define('DIR_WS_INCLUDES', 'includes/');
  define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/');
  define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/');
  define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/');
  define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/');
  define('DIR_WS_DOWNLOAD_PUBLIC', DIR_WS_CATALOG . 'pub/');
  define('DIR_WS_TEMPLATES', DIR_WS_INCLUDES . 'templates/');

  define('DIR_WS_PHPBB', '/');

// * DIR_FS_* = Filesystem directories (local/physical)
  //the following path is a COMPLETE path to your Zen Cart files. eg: /var/www/vhost/accountname/public_html/store/
  define('DIR_FS_CATALOG', '/home/xxxxxx/test2.experimedia.net/');

  //the following path is a COMPLETE path to the /logs/ folder  eg: /var/www/vhost/accountname/public_html/store/logs ... and no trailing slash
  define('DIR_FS_LOGS', '/home/xxxxxx/test2.experimedia.net/logs');

  define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');
  define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/');
  define('DIR_WS_UPLOADS', DIR_WS_IMAGES . 'uploads/');
  define('DIR_FS_UPLOADS', DIR_FS_CATALOG . DIR_WS_UPLOADS);
  define('DIR_FS_EMAIL_TEMPLATES', DIR_FS_CATALOG . 'email/');

// define our database connection
  define('DB_TYPE', 'mysql');
  define('DB_PREFIX', 'zen_');
  define('DB_CHARSET', 'utf8');
  define('DB_SERVER', 'xxxxxx');
  define('DB_SERVER_USERNAME', 'xxxxxx');
  define('DB_SERVER_PASSWORD', 'xxxxxx');
  define('DB_DATABASE', 'xxxxxx');

  // The next 2 "defines" are for SQL cache support.
  // For SQL_CACHE_METHOD, you can select from:  none, database, or file
  // If you choose "file", then you need to set the DIR_FS_SQL_CACHE to a directory where your apache
  // or webserver user has write privileges (chmod 666 or 777). We recommend using the "cache" folder inside the Zen Cart folder
  // ie: /path/to/your/webspace/public_html/zen/cache   -- leave no trailing slash 
  define('SQL_CACHE_METHOD', 'database');
  define('DIR_FS_SQL_CACHE', '/home/xxxxxx/test2.experimedia.net/cache');

// EOF

inveo
Inveo Support
Posts: 1285
Joined: Sat Feb 02, 2008 12:07 pm
Contact:

Re: [Zen Cart] redirects to home after buy-now from listing

Postby inveo » Tue Jan 15, 2013 1:59 pm

We've investigated this problem to the detail. Your report is valid and with settings you've described it leads to such behavior. We were thinking how to improve it but we do not see the way - ZC is by design using many different URLs to link the only one product and then it can works this way. However MSU always use the one unique product URL to avoid duplicate content and increase PR.
Maybe it would be possible to path some parameter to product URLs (like buy=now which is never shown to Search Engines) which will do the trick but it would require quite complex change (and affects stability).

That code which is affected by unique URLs is located in includes/init_includes/init_cart_handler.php ($goto var). Maybe you will see the solution but to our knowledge it is not easily solvable (we know about partial solution but it does not work for HTTPS).

experimedia
Posts: 10
Joined: Sun Jan 13, 2013 9:31 pm

Re: [Zen Cart] redirects to home after buy-now from listing

Postby experimedia » Wed Jan 16, 2013 5:24 am

Thanks for looking into this. Sad to hear its not easily rectified.

Could you tell me about this partial solution you mentioned? It might give me some clues in the right direction and a basis for testing.

inveo
Inveo Support
Posts: 1285
Joined: Sat Feb 02, 2008 12:07 pm
Contact:

Re: [Zen Cart] redirects to home after buy-now from listing

Postby inveo » Wed Jan 16, 2013 9:25 am

That partial solution is based on using $_SERVER['HTTP_REFERRER'] var and then passing main_page parameter to $goto var (parse_str() function will help you). However, HTTP referrer is not sent by modern browser if HTTPS connection is used so it will not work when HTTPS is in use.