Author Topic: Basic Tabs - Ask Seller  (Read 17844 times)

lipes

  • Full Member
  • ***
  • Posts: 720
Basic Tabs - Ask Seller
« on: December 16, 2010, 19:19:50 pm »
Hi! I'm using this code of basic tabs http://forum.virtuemart.net/index.php?topic=46347.msg148313#msg148313

and now I'm trying to insert te ask page template on the Tab with this code:

Code: [Select]
echo $pane->startPanel( 'Questões?', 'panel3' );
echo "Tem alguma questão sobre este produto?";
echo "<div id=\"ask_inline\" class=\"ask_inline\" >";
echo "<form action=\" ".$mm_action_url."index.php\" method=\"post\" name=\"emailForm\" id=\"emailForm\" onsubmit=\"validateEnquiryForm(this.id); return false;\">";
echo "<label for=\"contact_name\"> ".$VM_LANG->_('NAME_PROMPT')." </label><br>";
echo "<input type=\"text\" name=\"name\" id=\"contact_name\" size=\"30\" class=\"inputbox\" value=\" ".$my->name." \"><br>";

echo "<label for=\"contact_mail\"> ".$VM_LANG->_('EMAIL_PROMPT')." </label><br>";
echo "<input type=\"text\" id=\"contact_mail\" name=\"email\" size=\"30\" label=\"Your email\" class=\"inputbox\" value=\" ".$my->email." \"><br>";

echo "<label for=\"contact_text\"> ".$VM_LANG->_('MESSAGE_PROMPT')." </label><br>";
echo "<textarea rows=\"6\" cols=\"40\" name=\"text\" id=\"contact_text\" class=\"inputbox\"> ".$subject." </textarea><br>";

echo "<input type=\"submit\" name=\"send\" value=\" ".$VM_LANG->_('SEND_BUTTON')." \" class=\"button\" />";

echo "<input type=\"button\" name=\"cancel\" class=\"button\" value=\" ".$VM_LANG->_('CMN_CANCEL')." \"  onclick=\"document.getElementById('ask_inline').style.display='none'; return false;\" />";


echo "<input type=\"hidden\" name=\"product_id\" value=\" ".$product_id."  \" />";
echo "<input type=\"hidden\" name=\"product_sku\" value=\" ".$product_sku." \" />";
echo "<input type=\"hidden\" name=\"set\" value=\"1\" />";
echo "<input type=\"hidden\" name=\"func\" value=\"productAsk\" />";
echo "<input type=\"hidden\" name=\"page\" value=\"shop.ask\" />";
echo "<input type=\"hidden\" name=\"option\" value=\"com_virtuemart\" />";
echo "<input type=\"hidden\" name=\"flypage\" value=\" ".$flypage." \" />";
echo "<input type=\"hidden\" name=\"Itemid\" value=\" ".$Itemid." \" />";

echo "<input type=\"hidden\" name=\" ".$validate." \" value=\"1\" />";
echo "</form>";
echo "</div>";
echo $pane->endPanel();

The layout is fine but problem is that the script dont work. How can I insert javacript here? and a php captcha plugin like this:
http://gruz.org.ua/en/about-joomla/25-faq/6-virtuemart-ask-seller-captcha.html

Code: [Select]
<?php global $mainframe$mainframe->triggerEvent('onShowOSOLCaptcha', array(false)); ?> ?
VM V. online: J2.5.14 | VM 2.0.20a | SQL 5.1.70 | PHP 5.3.25

Gruz

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 159
  • Copyleft (є) all rights reversed
Re: Basic Tabs - Ask Seller
« Reply #1 on: December 17, 2010, 12:27:55 pm »
Can you please show the web-site with the problem?
Your installable language for VM2: http://gruz.org.ua/virtuemart-language-files.html

lipes

  • Full Member
  • ***
  • Posts: 720
Re: Basic Tabs - Ask Seller
« Reply #2 on: December 17, 2010, 17:50:18 pm »
:( i'm in a production site using a local host.
Isn't online yet
I'm editing the default VM theme
VM V. online: J2.5.14 | VM 2.0.20a | SQL 5.1.70 | PHP 5.3.25

Gruz

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 159
  • Copyleft (є) all rights reversed
Re: Basic Tabs - Ask Seller
« Reply #3 on: December 17, 2010, 18:41:38 pm »
Please attach the file so I can quickly place it to my sandbox to test it.
Your installable language for VM2: http://gruz.org.ua/virtuemart-language-files.html

lipes

  • Full Member
  • ***
  • Posts: 720
Re: Basic Tabs - Ask Seller
« Reply #4 on: December 17, 2010, 22:45:44 pm »
Yep.

Here's the file, please rename it to .php
i've rename to .php.png because the forum does not permit upload php files :S


[attachment cleanup by admin]
VM V. online: J2.5.14 | VM 2.0.20a | SQL 5.1.70 | PHP 5.3.25

lipes

  • Full Member
  • ***
  • Posts: 720
Re: Basic Tabs - Ask Seller
« Reply #5 on: December 17, 2010, 23:44:07 pm »
How to include the path to include the file on TAB?

<?php include (VM_THEMEPATH . 'templates/pages/shop.ask.tpl.php' ) ?> ?
VM V. online: J2.5.14 | VM 2.0.20a | SQL 5.1.70 | PHP 5.3.25

Gruz

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 159
  • Copyleft (є) all rights reversed
Re: Basic Tabs - Ask Seller
« Reply #6 on: December 18, 2010, 00:32:38 am »
Hi. Here is the solution.

My changes are marked with ##my

The
shop.ask.tpl.php
has only the captcha Osol addition.

And the flypage.tpl.php has the main logic.

So for others.

To include the "Ask seller" form into flypage.tpl.php, add this code:
Code: [Select]
/*##my#2010-12-18 01:20:28 { */
//Set variables for future fetching templates
$this->set('set',0);

//user object
global $my;
$this->set('name',$my->name);
$this->set('email',$my->email);

//This is needed to hide "return to product" link
$document =& JFactory::getDocument();
$styles = "dd a.button {display:none;}";
$document->addStyleDeclaration($styles);
$this->set('product_link','');

//I need $db_product object in the template. This part is copied from administrator/components/com_virtuemart/html/shop.ask.php
$db_product = new ps_DB;
// Get the product info from the database
$q = "SELECT * FROM `#__{vm}_product` WHERE ";
if( !empty($product_id)) {
    $q .= "`product_id`=$product_id";
}
elseif( !empty($product_sku )) {
    $q .= "`product_sku`='$product_sku'";
}
if( !$perm->check("admin,storeadmin") ) {
    $q .= " AND `product_publish`='Y'";
    if( CHECK_STOCK && PSHOP_SHOW_OUT_OF_STOCK_PRODUCTS != "1") {
        $q .= " AND `product_in_stock` > 0 ";
    }
}
$db_product->query( $q );
$this->set('db_product',$db_product);

//You can redefine the subject variable like: $this->set('subject',"Hi, I have a question about ".$product_name);
$this->set('subject',$product_name);
echo $this->fetch('pages/shop.ask.tpl.php' );
/*##my#2010-12-18 01:20:28 } */

[attachment cleanup by admin]
Your installable language for VM2: http://gruz.org.ua/virtuemart-language-files.html

lipes

  • Full Member
  • ***
  • Posts: 720
Re: Basic Tabs - Ask Seller
« Reply #7 on: December 18, 2010, 01:13:59 am »
Great Fantastic Excelent!!!! :D
I saw the pop mail and it works!

Many thanks and if i could retribute in something you're welcome!

I will see the hack and i'll try to implement the captcha plugin and that hack in the Tab "Recomend to a friend"
VM V. online: J2.5.14 | VM 2.0.20a | SQL 5.1.70 | PHP 5.3.25

Gruz

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 159
  • Copyleft (є) all rights reversed
Re: Basic Tabs - Ask Seller
« Reply #8 on: December 18, 2010, 16:07:39 pm »
Prolipes, does it work with ask seller?

I didn't do anything with any "pop mail". I don't know what you mean.

It's not a hack, but a template customization. This means that future VM updates will not overwrite these changes. Surely, if you rename your VM theme folder fromdefault to another.

Your flypage has many other problems. You should work with php errors turned on to see php warnings. It helps very much when customizing/developing.

Add to your .htaccess
Code: [Select]
php_value error_reporting E_ALL
But this is not good at your production site as it helps a potential hacker to get some info.
Your installable language for VM2: http://gruz.org.ua/virtuemart-language-files.html

lipes

  • Full Member
  • ***
  • Posts: 720
Re: Basic Tabs - Ask Seller
« Reply #9 on: December 18, 2010, 16:14:18 pm »
ok :)
what i mean its that everything working fine! I recieve a email with the question.

humm.. ok! i'll add that code on .htaccess to see.. but i'm not a coder :S
i'm only trying to help my dad in he's litle store...
VM V. online: J2.5.14 | VM 2.0.20a | SQL 5.1.70 | PHP 5.3.25

lipes

  • Full Member
  • ***
  • Posts: 720
Re: Basic Tabs - Ask Seller
« Reply #10 on: December 18, 2010, 18:59:40 pm »
500 Internal Server Error error was encountered :S
VM V. online: J2.5.14 | VM 2.0.20a | SQL 5.1.70 | PHP 5.3.25

Gruz

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 159
  • Copyleft (є) all rights reversed
Re: Basic Tabs - Ask Seller
« Reply #11 on: December 18, 2010, 19:02:16 pm »
This means that your hosting doesn't allow users to enable all errors.

This instead or combination of these lines:

Code: [Select]
php_flag    display_errors          on

php_flag    display_startup_errors  on

php_value   error_reporting         2047
Your installable language for VM2: http://gruz.org.ua/virtuemart-language-files.html

lipes

  • Full Member
  • ***
  • Posts: 720
Re: Basic Tabs - Ask Seller
« Reply #12 on: December 18, 2010, 21:03:32 pm »
i will try! One more question please:
To insert "Recommend a friend" in the last Tab i have to do the same process than "Ask to a Seller"?

I cannot import the
Code: [Select]
<form action="index2.php" method="post">
   
    <table border="0" cellspacing="2" cellpadding="1" width="80%">
      <tr>
        <td>'.$VM_LANG->_('EMAIL_FRIEND_ADDR').'</td>
        <td><input type="text" name="recipient_mail" size="50" value="'.(!empty($recipient_mail)?$recipient_mail:'').'" /></td>
      </tr>
      <tr>
        <td>'.$VM_LANG->_('EMAIL_YOUR_NAME').'</td>
        <td><input type="text" name="sender_name" size="50" value="'.(!empty($sender_name)?$sender_name:$my->name).'" /></td>
      </tr>
      <tr>
        <td>'.$VM_LANG->_('EMAIL_YOUR_MAIL').'</td>
        <td><input type="text" name="sender_mail" size="50" value="'.(!empty($sender_mail)?$sender_mail:$my->email).'" /></td>
      </tr>
      <tr>
        <td colspan="2">'.$VM_LANG->_('VM_RECOMMEND_FORM_MESSAGE').'</td>
      </tr>
      <tr>
        <td colspan="2">
          <textarea name="recommend_message" style="width: 100%; height: 200px">';
     
    if (!empty($message)) {
        echo stripslashes(str_replace( array('\r', '\n' ), array("\r", "\n" ), $message ));
    }
    else {
        $msg = sprintf($VM_LANG->_('VM_RECOMMEND_MESSAGE',false), $vendor_store_name, $sess->url( URL.'index.php?page=shop.product_details&product_id='.$product_id, true ));
        echo shopMakeHtmlSafe(stripslashes( str_replace( 'index2.php', 'index.php', $msg )));
    }

    echo '</textarea>
        </td>
      </tr>
    </table>
   
    <input type="hidden" name="option" value="com_virtuemart" />
    <input type="hidden" name="page" value="shop.recommend" />
    <input type="hidden" name="product_id" value="'.$product_id.'" />
    <input type="hidden" name="'.vmCreateHash().'" value="1" />
    <input type="hidden" name="Itemid" value="'.$sess->getShopItemid().'" />
    <input type="hidden" name="func" value="recommendProduct" />
    <input class="button" type="submit" name="submit" value="'.$VM_LANG->_('PHPSHOP_SUBMIT').'" />
    <input class="button" type="button" onclick="window.close();" value="'.$VM_LANG->_('CMN_CANCEL').'" />
    </form>
in ps_communication.php file?

Or I must work with shop.recommend.php file?

[attachment cleanup by admin]
VM V. online: J2.5.14 | VM 2.0.20a | SQL 5.1.70 | PHP 5.3.25

Gruz

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 159
  • Copyleft (є) all rights reversed
Re: Basic Tabs - Ask Seller
« Reply #13 on: December 18, 2010, 22:51:09 pm »
1. Read this http://www.vm-expert.com/virtuemart-expert-blog/80-extending-virtuemart-114
2. Enable user classes in VM configuration.
3. Place the attached file (unpack before) into
components/com_virtuemart/themes/YOURTHEME/user_class/ps_communication.php

It contains two modified functions which overrride core VM functions. But you are still free to upgrade VM as it doesn't touch core VM files.

4. Add this code to your flypage.tpl.php

Code: [Select]
global $ok, $vm_mainframe;

include_once(CLASSPATH.'ps_communication.php');

$vm_mainframe->addStyleSheet( 'templates/'. $mainframe->getTemplate() );

if( empty( $_POST['submit'] ) || !$ok ) {
    $mainframe->setPageTitle( $VM_LANG->_('VM_RECOMMEND_FORM_LBL') );
    echo '<h3>'.$VM_LANG->_('VM_RECOMMEND_FORM_LBL').'</h3>';
    ps_communication::showRecommendForm($product_id);
}
else {
    $mainframe->setPageTitle( $VM_LANG->_('VM_RECOMMEND_FORM_LBL') );
    echo '<span class="contentheading">'. $VM_LANG->_('VM_RECOMMEND_DONE').' '. shopMakeHtmlSafe(vmGet($_POST,'recipient_mail')).'</span> <br />
   
}



You may also add some JS checks like there at "Ask Seller" page to prevent submitting form with empty fields.

There is a possible problem - when a wrong email adress is entered at least in Russian VM it shows error message, but it's empty. It's not critical, I think.



This is a quite another way I'd go. Briefly.
1. Install aicontactsafe Joomla extension, which allow to create custom forms. Install it's plugin, which allows to insert forms in articles.
2. Generate plugin code in flypage, result something like
{aicontactsafeform pf=1|name='My product'|subject='Hi'}
and so on. Store the code in a variable like $text_to_be_parsed;
3. Parse the variable  $text_to_be_parsed with plugins in the flypage with vmCommonHTML::ParseContentByPlugins

Here is my example used at i.e.
http://hearthandhomefireplace.com/contemporary/high-efficiency-gas-inserts/details/418/29/sunrise-u32s.html


Code: [Select]
$juribase = str_replace ("www.","", JURI::base());
$url_for_mail = $juribase.'index.php?page=shop.product_details&product_id='.$product_id.'&flypage='.$flypage.'&category_id='.$category_id.'&option=com_virtuemart&Itemid='.$Itemid;

$form = vmCommonHTML::ParseContentByPlugins( '{aicontactsafeform pf=2|use_css=0|use_ajax=0|aics_prod_url='.$url_for_mail.'|aics_prod_name='.$product_name.'|aics_prod_email=email|aics_prod_phone=telephone}' );

echo $form;


This approach allows you to use built in aicontactsafe CAPTCHA, Ajax submitting, storing sent mails in DB.


[attachment cleanup by admin]
Your installable language for VM2: http://gruz.org.ua/virtuemart-language-files.html

chenda0331

  • Beginner
  • *
  • Posts: 1
Re: Basic Tabs - Ask Seller
« Reply #14 on: December 22, 2010, 09:19:07 am »
Thank you for giving me this! That's what I need!