Post by mystifier » Sat Jan 28, 2012 2:55 am

Hi Guys, I haven't visited Opencart for many months, I have never even seen v1.5 (and am very rusty!) but I have been pulled back into the fold.

Can someone help with this:

In Tpl File, I have:

Code: Select all

<textarea name="comment"><?php echo $comment; ?></textarea>
<a onclick="$('#comment').submit();" class="button">
<span><?php echo $button_comment; ?></span></a>
I build $comment and it looks fine in the textarea. If I click the 'Update Comment' button everything works and the text gets saved but I want the text to get saved without having to click the button.

In Controller Php File, I have:

Code: Select all

$data['comment'] = $this->request->post['comment'];
I have tried many things such as:

Code: Select all

if (($this->request->server['REQUEST_METHOD'] == 'POST')
 && isset($this->request->post['comment'])) {
  $this->session->data['comment'] = $this->request->post['comment'];
}
$data['comment'] = (!empty($this->session->data['comment'])) ? $this->session->data['comment'] : 'Rubbish';
But, despite the textarea having valid text, all I ever get is 'Rubbish'.

Can anyone put me right. I had forgotten what a delight php programming was.

Free v1.4.9 Extensions: Default Specials | Improved Search | Customer Activity Report | Customer Groups | Royal Mail With Handling | Improved Product Page | Random Products | Stock Report | All Products


User avatar
Active Member

Posts

Joined
Tue May 18, 2010 5:15 pm

Post by JAY6390 » Sun Jan 29, 2012 2:00 am

Hi Mystifier

If you just get "rubbish" then you aren't sending the value over correctly. Chances are the form is a GET form rather than POST, or something is redirecting it

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by mystifier » Sun Jan 29, 2012 2:29 am

Thanks for the response Jay.

The method for the <form> is definitely post. The 'comment' textarea is showing text okay but:

Code: Select all

if (isset($this->request->post['comment'])) {
  $this->data['comment'] = $this->request->post['comment'];
  $this->session->data['comment'] = $this->request->post['comment'];
}

$data['comment'] = (!empty($this->session->data['comment'])) ? $this->session->data['comment'] : 'Rubbish';
But the data is always set to 'Rubbish'.

I have tried all of the obvious random guesses such as:

Code: Select all

$data['comment'] = $this->request->post['comment'];
I am still at a loss.

Free v1.4.9 Extensions: Default Specials | Improved Search | Customer Activity Report | Customer Groups | Royal Mail With Handling | Improved Product Page | Random Products | Stock Report | All Products


User avatar
Active Member

Posts

Joined
Tue May 18, 2010 5:15 pm

Post by JAY6390 » Sun Jan 29, 2012 3:05 am

Are you doing this in the admin? if so, are you passing the token?

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by mystifier » Sun Jan 29, 2012 3:40 am

Hi Jay,

It is part of the front-end checkout system so there is no token.

Free v1.4.9 Extensions: Default Specials | Improved Search | Customer Activity Report | Customer Groups | Royal Mail With Handling | Improved Product Page | Random Products | Stock Report | All Products


User avatar
Active Member

Posts

Joined
Tue May 18, 2010 5:15 pm

Post by rogery » Sun Jan 29, 2012 5:52 pm

Sorry for getting you into this mystifier :)

If it helps I want it to work like comments on normal checkout where there is no update button. It works fine there. If there is text in the box, it simply shows up on the order comment.

New member

Posts

Joined
Wed May 26, 2010 5:55 pm
Who is online

Users browsing this forum: No registered users and 42 guests