hasPostVariable Automatically Returns False?

Author Message

Alex Jones

Thursday 14 August 2003 12:38:56 pm

I have added the following code to kernal/shop/basket.php:

if ( $http->hasPostVariable( "my_post_var" ) )
{
$myVar = $http->postVariable( "my_post_var" );
}

And have added this line to the product purchase form on my product pages:

<input type="hidden" name="my_post_var" value="Something" />

Yet, everytime I run it, the code within the if statement is not executed. I have noticed a couple of other posts on the forum about issues much like this with the 'hasPostVariable' code within the eZHTTPTool Class, but have yet to find an explanation as to why it returns false, even when the posted variable does indeed exist. The code is placed below "$http =& eZHTTPTool::instance();" so that shouldn't be causing a problem.

Any ideas on how to fix this, or pointers in the right direction?

Thanks,

Alex

Related Posts:
http://ez.no/developer/ez_publish_3/forum/developer/is_the_posted_values_global_httphaspostvariable_poblem
http://ez.no/developer/ez_publish_3/forum/developer/passing_values_between_pages_ezhttptool_

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Paul Borgermans

Thursday 14 August 2003 1:22:02 pm

Alex,

Is the view cache enabled? If yes, try with a disabled cache. That's the only way my little contributed operator for extra post/get variables works (albeit this is from the template level, not the module level)

Still need a mechanism without sacrifying speed or even changing the kernel code.

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Alex Jones

Thursday 14 August 2003 1:32:34 pm

The view cache has been disabled throughout the process, though I appreciate the tip. :) I really hope that passing variables won't require that caching is disabled as that would be a big hit to performance...

There must be an easy answer to this.

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Paul Forsyth

Friday 15 August 2003 1:33:07 am

There may be redirects occuring during the processing of basket.php which would scupper your code.

Have you tried using ezdebug lines to check whether your variable is being set and reaching the end of basket.php? Try putting some in and test again.

paul

Alex Jones

Friday 15 August 2003 9:41:18 am

I added several eZDebug lines like Paul suggested. The system appears to load and get to the end of basket.php, but oddly enough it doesn't trigger the code that adds products to the cart:
if ( $http->hasPostVariable( "ActionAddToBasket" ) )

Yet the item is added to the cart without any problems. I'm going to look around to see if there is another component that would deal with this functionality, but this doesn't make sense...

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Alex Jones

Tuesday 19 August 2003 2:44:43 pm

Does anyone know why this odd behaviour is occuring and how I can fix it? I could really use some help on this one.

Thanks,

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Alex Jones

Thursday 21 August 2003 9:52:08 am

Okay, I have added an insane amount of debug notices to basket.php and am positive that the code that begins with
if ( $http->hasPostVariable( "ActionAddToBasket" ) ) on line 52 is not triggered when I click on a button adding a product to my cart. Ever. According to PHP there aren't any entries in the global _POST (or $GLOBALS["HTTP_POST_VARS"]) arrays when viewing the result of adding a product to the cart.

Yet the product is added to my cart. How??? All I want to do is pass an additional variable from my product page to the cart, yet I can't for the life of me determine where the posted variables get dropped and how the cart still manages to know what product to add.

Please help - this is the last major hurdle for me to take a large site live and it is pushing me to the edge of sanity. There has got to be an answer.

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.