Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

$messageStack object


Nullachtfuffzehn

Recommended Posts

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

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

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

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

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

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

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

  • 9 months later...
  • 1 year later...

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

  • 10 months later...

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

  • 2 years later...

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

Archived

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

×
×
  • Create New...