Jump to content

[SOLVED] Strange problem with "Send to a friend" module


Recommended Posts

Hi everybody,

I have the 1.5.5 Prestashop version, with a custom template.

Now, after the upgrade, I have a strange problem with "send to a friend" module.

When I fill the module (Friend's name and e-mail) and send the form, this answer that I must complete all required fields... so... what?? :)

 

Anybody can help?

If you need some more informations, I'll try give you.

Link to comment
Share on other sites

Check module's sendtofriend-extra.tpl. Not sure about 1.5.5 but on 1.5.6.1 it looks slightly different:

<p class="text">
	<label for="friend_name">{l s='Name of your friend' mod='sendtoafriend'} <sup class="required">*</sup> :</label>
	<input id="friend_name" name="friend_name" type="text" value=""/>
</p>
<p class="text">
	<label for="friend_email">{l s='E-mail address of your friend' mod='sendtoafriend'} <sup class="required">*</sup> :</label>
	<input id="friend_email" name="friend_email" type="text" value=""/>
</p>

You have different id and name. Use the same for both. Also should be the same as that used in <script> section  at the beginning of this file.

 

Other problem is that this module doesn't work without some changes in .php, but this may be hosting related so we'll come to that if needed.

Edited by Sharak (see edit history)
Link to comment
Share on other sites

Here is the code, averything seems ok... But this not working...  <_<

 

 

<script text="javascript">

{literal}

$('document').ready(function(){

$('#send_friend_button').fancybox({

  autoScale : true,

  'hideOnContentClick': false

});

 

$('#sendEmail').click(function(){

  var datas = [];

  $('#fancybox-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 >= 1)

  {

   $.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}

    dataType: "json",

    success: function(result){

     $.fancybox.close();

    }

   });

  }

  else

   $('#send_friend_form_error').text("{/literal}{l s='You did not fill required fields' mod='sendtoafriend' js=1}{literal}");

});

});

{/literal}

</script>

<li class="sendtofriend">

<a id="send_friend_button" href="#send_friend_form"><i class="icon-envelope"></i>{l s='Send to a friend' mod='sendtoafriend'}</a>

</li>

 

<div style="display: none;">

<div id="send_friend_form">

   <h1 class="title clearfix">{l s='Send to a friend' mod='sendtoafriend'}</h1>

            <div class="row-fluid">

            <div class="span6 titled_box">

             <h2 class="product_name"><span>{$stf_product->name}</span></h2>

                <div class="product clearfix">

                    <img src="{$link->getImageLink($stf_product->link_rewrite, $stf_product_cover, 'small_default')}" alt="{$stf_product->name|escape:html:'UTF-8'}" />

                    <div class="product_desc">

                        {$stf_product->description_short}

                    </div>

                </div>

   </div>

            <div class="span6">

   <div class="send_friend_form_content">

    <div id="send_friend_form_error"></div>

    <div class="form_container titled_box">

     <h2 class="intro_form "><span>{l s='Recipient' mod='sendtoafriend'} :</span></h2>

     <p class="text">

      <label for="friend_name">{l s='Name of your friend' mod='sendtoafriend'} <sup class="required">*</sup> :</label>

      <input id="friend_name" name="friend_name" type="text" value=""/>

     </p>

     <p class="text">

      <label for="friend_email">{l s='E-mail address of your friend' mod='sendtoafriend'} <sup class="required">*</sup> :</label>

      <input id="friend_email" name="friend_email" type="text" value=""/>

     </p>

     <p class="txt_required"><sup class="required">*</sup> {l s='Required fields' mod='sendtoafriend'}</p>

    </div>

   </div>

            </div>

            </div>

            <p class="submit sendfrend_footer">

     <input id="id_product_comment_send" name="id_product" type="hidden" value="{$stf_product->id}" />

     <button class="btn btn-inverse" onclick="$.fancybox.close();">{l s='Cancel' mod='sendtoafriend'}</button>

     <button id="sendEmail" class="btn btn-inverse" name="sendEmail" type="submit" />{l s='Send' mod='sendtoafriend'}</button>

                    <!--<input id="sendEmail" class="btn btn-inverse" name="sendEmail" type="submit" value="{l s='Send' mod='sendtoafriend'}" />-->

    </p>

</div>

</div>

Link to comment
Share on other sites

And that's default for presta.1.5.5:

<script text="javascript">
{literal}
$('document').ready(function(){
	$('#send_friend_button').fancybox({
		'hideOnContentClick': false
	});

	$('#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)
		{
			$.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}
				dataType: "json",
				success: function(result){
					$.fancybox.close();
				}
			});
		}
		else
			$('#send_friend_form_error').text("{/literal}{l s='You did not fill required fields' mod='sendtoafriend' js=1}{literal}");
	});
});
{/literal}
</script>
<li class="sendtofriend">
	<a id="send_friend_button" href="#send_friend_form">{l s='Send to a friend' mod='sendtoafriend'}</a>
</li>

<div style="display: none;">
	<div id="send_friend_form">
			<h2 class="title">{l s='Send to a friend' mod='sendtoafriend'}</h2>
			<div class="product clearfix">
				<img src="{$link->getImageLink($stf_product->link_rewrite, $stf_product_cover, 'home_default')|escape:'html'}" height="{$homeSize.height}" width="{$homeSize.width}" alt="{$stf_product->name|escape:html:'UTF-8'}" />
				<div class="product_desc">
					<p class="product_name"><strong>{$stf_product->name}</strong></p>
					{$stf_product->description_short}
				</div>
			</div>
			
			<div class="send_friend_form_content" id="send_friend_form_content">
				<div id="send_friend_form_error"></div>
				<div class="form_container">
					<p class="intro_form">{l s='Recipient' mod='sendtoafriend'} :</p>
					<p class="text">
						<label for="friend_name">{l s='Name of your friend' mod='sendtoafriend'} <sup class="required">*</sup> :</label>
						<input id="friend_name" name="friend_name" type="text" value=""/>
					</p>
					<p class="text">
						<label for="friend_email">{l s='E-mail address of your friend' mod='sendtoafriend'} <sup class="required">*</sup> :</label>
						<input id="friend_email" name="friend_email" type="text" value=""/>
					</p>
					<p class="txt_required"><sup class="required">*</sup> {l s='Required fields' mod='sendtoafriend'}</p>
				</div>
				<p class="submit">
					<input id="id_product_comment_send" name="id_product" type="hidden" value="{$stf_product->id}" />
					<a href="#" onclick="$.fancybox.close();">{l s='Cancel' mod='sendtoafriend'}</a> {l s='or' mod='sendtoafriend'} 
					<input id="sendEmail" class="button" name="sendEmail" type="submit" value="{l s='Send' mod='sendtoafriend'}" />
				</p>
			</div>
	</div>
</div>

Try it, then correct stiling if it works

Edited by Sharak (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...