Author Topic: Add fields in Ask A Question  (Read 9297 times)

franz

  • Beginner
  • *
  • Posts: 7
Add fields in Ask A Question
« on: January 13, 2012, 11:37:44 am »
Hi, I'd like to add some extra fields in ask a question form. I've read other topics about this but they're all for VM 1.x. Infact on VM 2 I can't find the file ps_communication. Anyway, can you tell me what's the procedure to add fields?
Thank you :)

ferdesign

  • Beginner
  • *
  • Posts: 1
Re: Add fields in Ask A Question
« Reply #1 on: January 25, 2012, 17:43:52 pm »
I have the same question.

In the old Virtuemart is easy to add new fields.

The Steps

This is how I got it to work.

Edit: administrator/components/com_virtuemart/languages/shop/english.php

At line 70

Add: 'PHONE_PROMPT' => 'Enter your Phone Number',


Edit: components/com_virtuemart/themes/default/templates/pages/shop.ask.tpl.php

At line 32

Or where you want your phone field to appear.

Add:

<label for="phone"><?php echo $VM_LANG->_('PHONE_PROMPT') ?></label>
<br /><input type="text" id="phone" name="phone" size="50" class="inputbox" value="">
<br /><br />

Edit: administrator/components/com_virtuemart/html/shop.ask.php

At line 80

Add

'phone' => $phone,


Edit: administrator/components/com_virtuemart/classes/ps_communication.php

At line 156

Add: $phone = $d['phone'];

At line 157

Change to: $subject_msg = vmRequest::getVar( 'text', '', 'post', 'phone' );

At line 205

Add: 'phone' => $phone,


Edit: components/com_virtuemart/themes/default/templates/order_emails/enquiry_email.tpl.php

Add: <?php echo $phone ?>


New Virtuemart 2.0

Edit: language/en-GB/en-GB.com_virtuemart.ini

Add: COM_VIRTUEMART_ASK_PHONE="Enter your Phone Number"

EDIT: components/com_virtuemart/views/askquestion/tmpl/form.php

where you want your phone field to appear.


         <label><?php echo JText::_('COM_VIRTUEMART_USER_FORM_NAME')  ?> : <input type="text" class="validate[required,minSize[4],maxSize[64]]" value="<?php echo $this->user->name ?>" name="name" id="name" size="30"  validation="required name"/></label>
         <br />
         <label><?php echo JText::_('COM_VIRTUEMART_USER_FORM_EMAIL')  ?> : <input type="text" class="validate[required,custom[email]]" value="<?php echo $this->user->email ?>" name="email" id="email" size="30"  validation="required email"/></label>
         <br/>
                        <label><?php echo JText::_('COM_VIRTUEMART_USER_FORM_PHONE')  ?> : <input type="text" class="validate[required]" value="<?php echo $this->user->phone ?>" name="phone" id="phone" size="30"  validation="required phone"/></label>
         <br/>
         <label>


Also need to edit the file com_virtuemart/views/askquestion/tmpl/mail_html_question.php

   <table class="html-email" cellspacing="0" cellpadding="0" border="0" width="100%">  <tr >

            <th width="100%">

                <?php echo JText::_('COM_VIRTUEMART_QUESTION_ABOUT').' '.$this->product->product_name ?>

            </th>

             </tr>

             <tr>

            <td valign="top" width="100%">

                <?php

                echo JText::sprintf('COM_VIRTUEMART_QUESTION_MAIL_FROM', $this->user['name'], $this->user['email']) . "<br />";
                                   
                                   // Add  "phone" When sending the message //

                echo $this->comment. "<br />";

                ?>

            </td>

             </tr>

         </table>




Please help me to add new field in "Ask A Question"

What other files need to edit?


ekc_maga

  • Beginner
  • *
  • Posts: 3
Re: Add fields in Ask A Question
« Reply #2 on: April 24, 2012, 08:33:48 am »
Hi, I also want such customization, any updates on this ?

Thanks!

rodrigo-fuchs

  • Beginner
  • *
  • Posts: 3
Re: Add fields in Ask A Question
« Reply #3 on: May 31, 2012, 11:46:32 am »
I am also facing the same problem in virtuemart 2.0, one could evaluate a solution for this?
This field is very important to shop around, but I could not build something and did not find any solution in the search.
Does anyone have an idea to finish the code?

rodrigo-fuchs

  • Beginner
  • *
  • Posts: 3
Re: Add fields in Ask A Question
« Reply #4 on: May 31, 2012, 21:05:12 pm »
New Virtuemart 2.0!!!!!

Edit: language/en-GB/en-GB.com_virtuemart.ini

Add: COM_VIRTUEMART_ASK_PHONE="Enter your Phone Number"

EDIT: components/com_virtuemart/views/askquestion/tmpl/form.php

where you want your phone field to appear.


         <label><?php echo JText::_('COM_VIRTUEMART_USER_FORM_NAME')  ?> : <input type="text" class="validate[required,minSize[4],maxSize[64]]" value="<?php echo $this->user->name ?>" name="name" id="name" size="30"  validation="required name"/></label>
         <br />
         <label><?php echo JText::_('COM_VIRTUEMART_USER_FORM_EMAIL')  ?> : <input type="text" class="validate[required,custom[email]]" value="<?php echo $this->user->email ?>" name="email" id="email" size="30"  validation="required email"/></label>
         <br/>
                        <label><?php echo JText::_('COM_VIRTUEMART_USER_FORM_PHONE')  ?> : <input type="text" class="validate[required]" value="<?php echo $this->user->phone ?>" name="phone" id="phone" size="30"  validation="required phone"/></label>
         <br/>
         <label>



Also need to edit the file com_virtuemart/views/askquestion/tmpl/mail_html_question.php

   <table class="html-email" cellspacing="0" cellpadding="0" border="0" width="100%">  <tr >

            <th width="100%">

                <?php echo JText::_('COM_VIRTUEMART_QUESTION_ABOUT').' '.$this->product->product_name ?>

            </th>

             </tr>

             <tr>

            <td valign="top" width="100%">

                <?php

                echo JText::sprintf('COM_VIRTUEMART_QUESTION_MAIL_FROM', $this->user['name'], $this->user['email']) . "<br />";
                                   
                echo $this->phone. "<br />";

                echo $this->comment. "<br />";

                ?>

            </td>

             </tr>

         </table>



Also need to edit the file com_virtuemart/views/askquestion/view.html.php in line 44

                echo JText::sprintf('COM_VIRTUEMART_QUESTION_MAIL_FROM', $this->user['name'], $this->user['email']) . "<br />";
               
                echo $this->phone. "<br />";
                echo $this->comment. "<br />";
                ?>



Also need to edit the file com_virtuemart/views/askquestion/tmpl/mail_raw_question.php

<?php

echo JText::sprintf('COM_VIRTUEMART_WELCOME_VENDOR', $this->vendor->vendor_store_name) . "\n" . "\n";
echo JText::_('COM_VIRTUEMART_QUESTION_ABOUT') . ' '. $this->product->product_name."\n" . "\n";
echo JText::sprintf('COM_VIRTUEMART_QUESTION_MAIL_FROM', $this->user->name, $this->user->email) . "\n";
echo $this->phone. "\n";
echo $this->comment. "\n";



Problem solved, the phone appears in the e-mail notification.

PS: It is important to check what files virtuemart is calling when loading the form. In my case, he was calling the folder template \ html \ com_virtuemart

I'm posting this because I have not found anything on the internet, if you had your problem solved sends a post, thanks!!

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10358
  • VirtueMart Version: 3+
Re: Add fields in Ask A Question
« Reply #5 on: May 31, 2012, 23:39:49 pm »
rodrigo-fuchs,

if you are a coder,
instead of hacking the "core"


Why not, add the form field.

Then, join the "phone", and "question" into the same string?

J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)

rodrigo-fuchs

  • Beginner
  • *
  • Posts: 3
Re: Add fields in Ask A Question
« Reply #6 on: June 01, 2012, 01:19:44 am »
Hi BanquetTables,

I'm not a programmer, working with webdesign.

I tried this way but could not.

You seem to have advanced knowledge in this field would help as would be the final code for this solution?

Thanks for the suggestion!

bugmenot

  • Beginner
  • *
  • Posts: 2
Re: Add fields in Ask A Question
« Reply #7 on: June 05, 2012, 01:54:45 am »
great work rodrigo-fuchs, I think that you should just correct the 4. group of changes. Namely, I think it is just a copy/paste error and it shouldn't be:

                echo JText::sprintf('COM_VIRTUEMART_QUESTION_MAIL_FROM', $this->user['name'], $this->user['email']) . "<br />";
               
                echo $this->phone. "<br />";
                echo $this->comment. "<br />";
                ?>


but

function renderMailLayout() {
   $this->setLayout('mail_html_question');
   $this->comment = JRequest::getString('comment');
   
   $this->phone = JRequest::getString('phone');


in view.html.php

Greets!

aaronv

  • Beginner
  • *
  • Posts: 2
  • Skype Name: test
Re: Add fields in Ask A Question
« Reply #8 on: August 14, 2015, 14:18:42 pm »
Can anyone tell me what to do with virtuemart 3 with joomla 3.4 version for extra field "phone" in ask a question form. Please help me.