diff --git a/modules/sendtoafriend/sendtoafriend-extra.tpl b/modules/sendtoafriend/sendtoafriend-extra.tpl index b438a4ad5..4b3c9e597 100755 --- a/modules/sendtoafriend/sendtoafriend-extra.tpl +++ b/modules/sendtoafriend/sendtoafriend-extra.tpl @@ -31,23 +31,17 @@ $('document').ready(function(){ }); $('#sendEmail').click(function(){ - var datas = []; - $('#send_friend_form_content').find(':input').each(function(index){ - var o = {}; - o.key = $(this).attr('name'); - o.value = $(this).val(); - - if (o.value != '') - datas.push(o); - }); - - if (datas.length >= 3) + + var name = $('#friend_name').val(); + var email = $('#friend_email').val(); + var id_product = $('#id_product_comment_send').val(); + if (name && email && !isNaN(id_product)) { $.ajax({ {/literal}url: "{$module_dir}sendtoafriend_ajax.php",{literal} type: "POST", headers: {"cache-control": "no-cache"}, - data: {action: 'sendToMyFriend', secure_key: '{/literal}{$stf_secure_key}{literal}', friend: unescape(JSON.stringify(datas).replace(/\\u/g, '%u'))},{/literal}{literal} + data: {action: 'sendToMyFriend', secure_key: '{/literal}{$stf_secure_key}{literal}', name: name, email: email, id_product: id_product},{/literal}{literal} dataType: "json", success: function(result) { $.fancybox.close(); diff --git a/modules/sendtoafriend/sendtoafriend_ajax.php b/modules/sendtoafriend/sendtoafriend_ajax.php index 415b62298..a08e2ef77 100644 --- a/modules/sendtoafriend/sendtoafriend_ajax.php +++ b/modules/sendtoafriend/sendtoafriend_ajax.php @@ -33,19 +33,9 @@ $module = new SendToAFriend(); if (Tools::getValue('action') == 'sendToMyFriend' && Tools::getValue('secure_key') == $module->secure_key) { - $friend_infos = Tools::jsonDecode(Tools::getValue('friend')); - $friendName = ""; - $friendMail = ""; - $id_product = null; - foreach ($friend_infos as $entry) - { - if ($entry->key == "friend_name") - $friendName = $entry->value; - else if ($entry->key == "friend_email") - $friendMail = $entry->value; - else if ($entry->key == "id_product") - $id_product = $entry->value; - } + $friendName = Tools::getValue('name'); + $friendMail = Tools::getValue('email'); + $id_product = Tools::getValue('id_product'); if (!$friendName || !$friendMail || !$id_product) die('0');