Post by trbfred » Thu Jul 04, 2013 2:06 am

Hello,
I would like to place a link on any product page where a potential customer can send an individual e-mail with questions about the product etc.

Linking the existent contact form is not the problem. But is it possible, to transmit the product-no as subject (or a specific string which i can pass through) like "index.php?route=information/contact&subject='Hello world'" ?

Thanks for your help!

Newbie

Posts

Joined
Thu Jul 04, 2013 2:02 am

Post by pedro1993 » Thu Jul 04, 2013 2:49 am

This is possible with a bit of coding :)

Step 1, edit the product page:
Open catalog/view/theme/your_template/template/view/product.tpl

Search for this code:

Code: Select all

      <div class="image-additional">
        <?php foreach ($images as $image) { ?>
        <a href="<?php echo $image['popup']; ?>" title="<?php echo $heading_title; ?>" class="colorbox" rel="colorbox"><img src="<?php echo $image['thumb']; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" /></a>
        <?php } ?>
      </div>
underneath add:

Code: Select all

<a href="index.php?route=information/contact&subject=<?php echo $heading_title; ?>" class="button">Ask Question about this item</a>
That should display a button in your product page. That code can be moved about so it is in the place you want it to be. You can change the text to whatever you link within the link.

Step 2, altering the contact controller:

Here you want to tell the contact page there is some more data that is to be email. You are also telling the controller thta if there is no product subject, then the subject is to be changed to the original subject used in OC.

Open catalog/controller/information/contact.php
Search for this code:

Code: Select all

$this->data['entry_captcha'] = $this->language->get('entry_captcha');
and underneath add:

Code: Select all

if (isset($this->request->get['subject'])) {
$this->data['subject'] = $this->request->get['subject'];
}else{
$this->data['subject'] = '';
}
then replace this:

Code: Select all

$mail->setSubject(html_entity_decode(sprintf($this->language->get('email_subject'), $this->request->post['name']), ENT_QUOTES, 'UTF-8'));
with:

Code: Select all

if(isset($this->request->post['subject'])){
$mail->setSubject(html_entity_decode(sprintf($this->request->post['subject'], $this->request->post['name']), ENT_QUOTES, 'UTF-8'));
}else{
$mail->setSubject(html_entity_decode(sprintf($this->language->get('email_subject'), $this->request->post['name']), ENT_QUOTES, 'UTF-8'));
}
Step 3, editing the actual contact form:
Open catalog/view/theme/your_template/information/contact.tpl

Search for this code:

Code: Select all

    <?php if ($error_email) { ?>
    <span class="error"><?php echo $error_email; ?></span>
    <?php } ?>
    <br />
and underneath it add

Code: Select all

    <b>Subject: </b><br />
    <b>Question about item: <?php echo $subject; ?></b>
    <input type="hidden" name="subject" value="Question about item: <?php echo $subject; ?>" />
    <br /><br />
The wording can be changed within the <input /> and <b> tags. The wording with in the <b> tag is what the user sees on the contact oage, the value within the input field is what is actually in the email.

I hope this helps,

Let me know how you get on :)

Peter

For OpenCart & PHP/MySQL support feel free to PM me :)
Click here for my extentions
Did I help you? Donate here to show support


Active Member

Posts

Joined
Tue Oct 18, 2011 4:31 am
Location - Glasgow, Scotland

Post by trbfred » Fri Jul 05, 2013 1:46 am

Thank you very much - works perfectly!

Newbie

Posts

Joined
Thu Jul 04, 2013 2:02 am

Post by pedro1993 » Fri Jul 05, 2013 5:04 am

Glad I could help :)

For OpenCart & PHP/MySQL support feel free to PM me :)
Click here for my extentions
Did I help you? Donate here to show support


Active Member

Posts

Joined
Tue Oct 18, 2011 4:31 am
Location - Glasgow, Scotland

Post by naghsheno » Sat Jul 27, 2013 3:04 pm

i use opencart_v1.4.9.4 and it doesn't work for me , after submit it give me this error message Error: E-Mail message required!

pls help me
thank you

Newbie

Posts

Joined
Sat Jul 27, 2013 2:55 pm

Post by pedro1993 » Wed Jul 31, 2013 1:45 am

This solution is for 1.5.x only. I am not familiar with 1.4.x, I'm sure it wil be something small.

Did you edit all the files accordingly?

Peter

For OpenCart & PHP/MySQL support feel free to PM me :)
Click here for my extentions
Did I help you? Donate here to show support


Active Member

Posts

Joined
Tue Oct 18, 2011 4:31 am
Location - Glasgow, Scotland

Post by naghsheno » Wed Jul 31, 2013 3:37 pm

thank you peter i solved the problem :) i had been removed some part of codes uncorrectly

Newbie

Posts

Joined
Sat Jul 27, 2013 2:55 pm

Post by pedro1993 » Thu Aug 01, 2013 7:12 am

That's great! I'm glad you got it working :)

For OpenCart & PHP/MySQL support feel free to PM me :)
Click here for my extentions
Did I help you? Donate here to show support


Active Member

Posts

Joined
Tue Oct 18, 2011 4:31 am
Location - Glasgow, Scotland

Post by visnetmedia » Thu Aug 08, 2013 2:02 pm

Hi thanks for the code works really well, just a question is there a way to add price in subject I tried to add <?php echo $price; ?> but it wouldn't show the button at all then.

Cheers

Active Member

Posts

Joined
Fri Feb 12, 2010 7:17 am

Post by comprido » Mon May 28, 2018 11:48 am

Thanks Peter, I've using your hack for years, now I had to rebuild my shop and I didn't find your code so once I got it I built the vqmod for more comfort on modifying files. Great work.
https://www.opencart.com/index.php?rout ... n_id=34175

Pedro Martin - websitesbuilder.com.au
Checkout my free extensions: https://www.opencart.com/index.php?rout ... r=comprido


User avatar
New member

Posts

Joined
Mon Sep 10, 2012 11:46 pm

Post by xxvirusxx » Fri Aug 17, 2018 5:26 pm

comprido wrote:
Mon May 28, 2018 11:48 am
I built the vqmod for more comfort on modifying files.
https://www.opencart.com/index.php?rout ... n_id=34175
I made for 2.3.0.2 and 3.0.2.0

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by comprido » Sat Aug 18, 2018 5:24 am

Feel free to add as your own work in the marketplace ;)

Pedro Martin - websitesbuilder.com.au
Checkout my free extensions: https://www.opencart.com/index.php?rout ... r=comprido


User avatar
New member

Posts

Joined
Mon Sep 10, 2012 11:46 pm

Post by faizsandbox » Mon Feb 25, 2019 12:14 pm

i need help in combining 2 extensions
***1- https://www.opencart.com/index.php?rout ... load_id=47
***2- xxvirusxx vqmod
Basically “Ask Question” link should be active only when extension ***1- is on with Text “Free” and show up below “Free”
OC 2..3.0.2 - Default Theme.
Thank you

Newbie

Posts

Joined
Mon Feb 25, 2019 11:56 am
Who is online

Users browsing this forum: Semrush [Bot] and 26 guests