Nullachtfuffzehn Posted February 27, 2007 Share Posted February 27, 2007 I've added a function to the osc which prevents customers from buying more than one item at a time, as well as no more than one items of a kind can be bought. To inform the customer, if he tries to add a second item to the cart, I wanted to display an errormessage like it's done on other places in osc. So I tried to add the message in application_top.php where the update_cart parameter is processed. But when I'm getting redirected to the shopping_cart.php the $messageStack Object is empty. Even $messageStack->add_session doesn't work, which should read the content of the object from the POSTVARS after declaring the new object in application_top. But nothing I tried did work. Any hints? Thanks in advance. Link to comment Share on other sites More sharing options...
jonquil Posted February 28, 2007 Share Posted February 28, 2007 If you get this working well, I'm interested in the how's and where's. One of my clients sells one of a kinds and this would be a Godsend. Have you addressed the possibility of a customer logging out but hoarding product, thus depriving someone of the sale? Like empty cart on logout if customer didn't complete checkout? jon It's all just ones and zeros.... Link to comment Share on other sites More sharing options...
Guest Posted February 28, 2007 Share Posted February 28, 2007 I've added a function to the osc which prevents customers from buying more than one item at a time, as well as no more than one items of a kind can be bought. To inform the customer, if he tries to add a second item to the cart, I wanted to display an errormessage like it's done on other places in osc. So I tried to add the message in application_top.php where the update_cart parameter is processed. But when I'm getting redirected to the shopping_cart.php the $messageStack Object is empty. Even $messageStack->add_session doesn't work, which should read the content of the object from the POSTVARS after declaring the new object in application_top. But nothing I tried did work. Any hints? Thanks in advance. The messagestack class is instantiated after the action switch. So you need to move the class defnition and the instance before the action switch. Along with the box class which is the root of the messagestack. This is in your application_top.php Link to comment Share on other sites More sharing options...
Nullachtfuffzehn Posted March 1, 2007 Author Share Posted March 1, 2007 The messagestack class is instantiated after the action switch. So you need to move the class defnition and the instance before the action switch. Along with the box class which is the root of the messagestack. This is in your application_top.php That's what I did. But with no success so far. I think I gotta look into it a bit deeper. Link to comment Share on other sites More sharing options...
Nullachtfuffzehn Posted March 1, 2007 Author Share Posted March 1, 2007 That's what I did. But with no success so far. I think I gotta look into it a bit deeper. Dunno if I'm thinking wrong, but when I set an error message by ->add_session(), the array should be stored in the session variables. When application_top is called the next time and the messagestack object is created again, it should retrieve the array from the session variables and put it back to the messagestack object. But why doesn't it work? Am I blind somehow? Link to comment Share on other sites More sharing options...
Guest Posted March 1, 2007 Share Posted March 1, 2007 Dunno if I'm thinking wrong, but when I set an error message by ->add_session(), the array should be stored in the session variables. When application_top is called the next time and the messagestack object is created again, it should retrieve the array from the session variables and put it back to the messagestack object. But why doesn't it work? Am I blind somehow? Because there are bugs in the messageStack class for both the catalog and the admin ends. I noticed it will show some times and other times it wont. At least you have the messageStack object now properly set. Link to comment Share on other sites More sharing options...
Guest Posted March 1, 2007 Share Posted March 1, 2007 I also found this http://www.oscommerce.com/forums/index.php?showtopic=219213 I remember messing with it but I cannot recall what exactly I did. And that was with the older osc versions. Link to comment Share on other sites More sharing options...
Nullachtfuffzehn Posted March 1, 2007 Author Share Posted March 1, 2007 Because there are bugs in the messageStack class for both the catalog and the admin ends. I noticed it will show some times and other times it wont. At least you have the messageStack object now properly set. Thanks for the hint. I've built a workaround for it now. Seems to work properly. Link to comment Share on other sites More sharing options...
mixit Posted December 8, 2007 Share Posted December 8, 2007 This topic is also about the $messageStack problem: http://www.oscommerce.com/forums/index.php?showtopic=281293 Link to comment Share on other sites More sharing options...
Guest Posted February 2, 2009 Share Posted February 2, 2009 Hi all, I know this is a fairly old topic now, but Nullachtfuffzehn, it would help me, and maybe others a great deal if you could provide details on how you got the error message stack working correctly..... Cheers, Paul Link to comment Share on other sites More sharing options...
David Houillon Posted December 28, 2009 Share Posted December 28, 2009 Hi everybody (Im french so excuse my awful french style expression!!) Ive found the "messageStack empty" solution. When you try to delete the primary address in your address book, an error message can be shown or not, depends on GOD! :x To resolve it, ive put a sleep(1); just after $messageStack->add_session('addressbook', WARNING_PRIMARY_ADDRESS_DELETION, 'warning'); like that : $messageStack->add_session('addressbook', WARNING_PRIMARY_ADDRESS_DELETION, 'warning'); sleep(1); tep_redirect(tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL')); It seems that it works. (With a sleep(0.5) for example it doesn't !!!!) If this issue can make oscommerce developpers find the primary problem, i'll be very pleased. Kind regards. David Link to comment Share on other sites More sharing options...
dailce Posted June 11, 2012 Share Posted June 11, 2012 Thought I'd share this fix, from my modified store. function output($class) { $output = ''; for ($i=0, $n=sizeof($this->messages); $i<$n; $i++) { if ($this->messages[$i]['class'] == $class) { if( $this->messages[$i][0] != '' ){ //coming from session $output .= $this->messages[$i][0]; }else{ //not a session $output .= $this->messages[$i]['text']; } } } return $output; } So I guess original output from messagestack class MIGHT be: function output($class) { $this->table_data_parameters = 'class="messageBox"'; $output = array(); for ($i=0, $n=sizeof($this->messages); $i<$n; $i++) { if( $this->messages[$i][0] != '' ){ //coming from session $output[] = $this->messages[$i][0]; }else{ //not a session $output[] = $this->messages[$i]['text']; } } return $this->tableBox($output); } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.