Issue: Prestashop Module send to a friend add field
Add a Comment input text field or textarea in smarty template /themes/mytheme/modules/sendtoafriend/sendtoafriend-extra.tpl (Line 64)
<p class="text">
<[label for="friend_comment">
{l s='Friend Comment' mod='sendtoafriend'}]>
<[/label]>
<[input id="friend_comment" name="friend_comment" type="text" value=""]>
</p>
Get your id value in javascript in /themes /mytheme /js /modules /sendtoafriend /sendtoafriend.js (Line 40)
var name = $('#friend_name').val();
var email = $('#friend_email').val();
var stf_comment = $('#friend_comment').val();
Put your value into ajax post function (Line 54)
$.ajax({
url: baseDir + 'modules/sendtoafriend/sendtoafriend_ajax.php?rand='
+ new Date().getTime(),
type: "POST",
headers: {"cache-control": "no-cache"},
data: {
action: 'sendToMyFriend',
secure_key: stf_secure_key,
name: name,
email: email,
id_product: id_product,
stf_comment: stf_comment
}
Now go to file /modules/sentoafriend/sendtoafriend_ajax.php (Line 50)
foreach ($friend as $key => $value)
{
if ($value['key'] == 'friend_name')
$friendName = $value['value'];
elseif ($value['key'] == 'friend_email')
$friendMail = $value['value'];
elseif ($value['key'] == 'id_product')
$id_product = $value['value'];
elseif ($value['key'] == 'friend_comment')
$friendComment = $value['value'];
}
}
else
{
$friendName = Tools::getValue('name');
$friendMail = Tools::getValue('email');
$id_product = Tools::getValue('id_product');
$friendComment = Tools::getValue('stf_comment');
}
(Line 77)
$templateVars = array(
'{product}' => $product->name,
'{product_link}' => $productLink,
'{customer}' => $customer,
'{name}' => Tools::safeOutput($friendName),
'{friend_comment}' => Tools::safeOutput($friendComment)
);