Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Geek ? on application_top.php


dwatson

Recommended Posts

I'm working my way through applicaiton_top.php and its included files, writing it as pseudocode. I'm up to a section on page 6, about line 311, of applicaton_top.php that starts with a comment //Shopping cart actions.

 

It seems that this whole section being executed is predicated upon a conditional:

if (isset($HTTP_GET_VARS('action').

 

So forms have to be sending requests with the GET var 'action' set for any of this to execute. When I put in print and var_dump statements, and then run my app under different conditions, I cannot make this section execute.

 

So my question is -- under what conditions will this section get run? When does this GET var on action get set?

 

Are there parameters that can be set in the configuration table to make this happen, or does this come from some non-standard change in the html forms? Or maybe, probably, I'm just missing something obvious.

Thanks,

 

David Watson

Link to comment
Share on other sites

I think you are missing the obvious...

 

The GET action must be one of the ones listed in the switch statement just below the code you posted above (isset). I've stripped it down...reference the code below for the possible values of action.

    switch ($HTTP_GET_VARS['action']) {
     // customer wants to update the product quantity in their shopping cart
     case 'update_product' : for ($i=0, $n=sizeof($HTTP_POST_VARS['products_id']); $i<$n; $i++) {
                             break;
     // customer adds a product from the products page
     case 'add_product' :    if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {
                             break;
     // performed by the 'buy now' button in product listings and review page
     case 'buy_now' :        if (isset($HTTP_GET_VARS['products_id'])) {
                             break;
     case 'notify' :         if (tep_session_is_registered('customer_id')) {
                             break;
     case 'notify_remove' :  if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['products_id'])) {
                             break;
     case 'cust_order' :     if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['pid'])) {
                             break;
   }

Link to comment
Share on other sites

Thanks for the tip. The GET action must be one of the ones in the switch (I saw that), but the GET 'action' itself is not passed by the request from the browser (in my setup). In other words, if I put, echo "GET action set"; into the application_top.php code (on my local, dev setup) just above that switch statement, I never see it on the screen because it never passes the conditional that checks to see if the GET 'action' variable was set at all. So then the switch never executes.

 

So, that leads me to see how the forms are being specified (what method) in the html.

 

I see in the function tep_draw_form in html_output.php that the default method is "post". I guess if I

changed this to "get" that would probably make this section of code execute.

 

Well, hold on, let me try it.

 

I did change tep_draw_form method default to 'get', and when I clicked on the update from the shopping cart, it did get past that conditional above and print out my "GET action set" on the screen (causing another problem, but that's okay). So I did make it execute that code.

 

So I guess that is my answer. When the default in tep_draw_form is set to 'get' it does execute this section of the code (or when you pass in 'get' as a parameter to that function). I guess this is a little obvious, but I did have to do a little more digging.

Thanks,

 

David Watson

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...