v1.6-v1.7 Prestashop Product, Shop Reviews, Reminder, Profile, Rich Snippets Module- Feedback

d-shilko

Well-known member
☆☆ Special ☆☆
☆ Pro ☆
Joined
Jun 10, 2021
Messages
2,538
Reaction score
1,530
Points
113
NullCash
4,422
Stop. It is not error. If you want to add review you must choose rating stars. Without my code edition in native mode you would to select star too. If you try to sent review without choose star you receive error message. If you want to select 5 star by default.

Bu bir hata değil. Modül bu şekilde çalışır. Yıldızları seçmezseniz, bir hata olacaktır.
Varsayılan seçiminiz olarak 5 yıldız istiyorsunuz?

1624484141429.png
 

Marc

Active member
XNullUser
Joined
Feb 27, 2021
Messages
502
Reaction score
33
Points
28
NullCash
39
That's what I actually want, 5 stars selected by default, so the users don't need to click the stars if they want to give a 5-star rating, they only need to click the stars if they want to give less than 5-stars.
I really appreciate your help and thankful to you :)
Post automatically merged:

No, I want the 5 stars selected by default, and users can reduce the stars if they want to give a rating less than 5-stars.
 

d-shilko

Well-known member
☆☆ Special ☆☆
☆ Pro ☆
Joined
Jun 10, 2021
Messages
2,538
Reaction score
1,530
Points
113
NullCash
4,422
That's what I actually want, 5 stars selected by default, so the users don't need to click the stars if they want to give a 5-star rating, they only need to click the stars if they want to give less than 5-stars.
I really appreciate your help and thankful to you :)
Guy you want very match :)

{literal}
<script type="text/javascript">
{/literal}{if $spmgsnipreviewis17 == 1}{literal}document.addEventListener("DOMContentLoaded", function(event) { {/literal}{/if}
{literal}
jQuery(document).ready( function() {
init_rating();
read_rating_review_shop('rat_rel1');
rating_review_shop('rat_rel1',5); rating_checked1=true;
});
$("#idTab777-my-click").click(function() {
$('.total-info-tool-product-page .btn-spmgsnipreview').parent().hide();
});

{/literal}{if $spmgsnipreviewis17 == 1}{literal}}); {/literal}{/if}{literal}
</script>
{/literal}

JOIN my Turkish friend

1624485554778.png
 

Marc

Active member
XNullUser
Joined
Feb 27, 2021
Messages
502
Reaction score
33
Points
28
NullCash
39
You're awesome! it worked, however, when I submitted the review, it is posted without any rating :D Getting this error in chrome console- Uncaught TypeError: rat is null

Try to submit a review without clicking the stars and see it yourself :)
 

d-shilko

Well-known member
☆☆ Special ☆☆
☆ Pro ☆
Joined
Jun 10, 2021
Messages
2,538
Reaction score
1,530
Points
113
NullCash
4,422
it is set 5 star everytime click on button "write a review". This is little patch but not perfect code. Must work.
1624490765208.png


1624490570433.png

function show_form_review(par){

$('#add-review-block').toggle();
$('#no-customers-reviews').toggle();

if(par == 1){
$('.spr-summary-actions .btn-spmgsnipreview').parent().hide();
rating_review_shop('rat_rel1',5); rating_checked1=true;
} else {
$('.spr-summary-actions .btn-spmgsnipreview').parent().show();
}
}
 

Marc

Active member
XNullUser
Joined
Feb 27, 2021
Messages
502
Reaction score
33
Points
28
NullCash
39
Thank you so much! Should I discard the previous changes? Please let me know.
Post automatically merged:

I just removed the previous modifications and implemented the new code and it's working perfectly! But it is not working for the button beside the product, please see the image.Screenshot 2021-06-24 151227.jpg
 
Last edited:

d-shilko

Well-known member
☆☆ Special ☆☆
☆ Pro ☆
Joined
Jun 10, 2021
Messages
2,538
Reaction score
1,530
Points
113
NullCash
4,422
{if $spmgsnipreviewis_add != 1}
<a class="btn-spmgsnipreview btn-primary-spmgsnipreview"
href="{if $spmgsnipreviewajax == 1}{$spmgsnipreviewsharing_url|escape:'htmlall':'UTF-8'}{/if}#idTab777"
id="idTab777-my-click"
{if $spmgsnipreviewis_bug == 1 && $spmgsnipreviewajax == 0}onclick="rating_review_shop('rat_rel1',5); rating_checked1=true;$.scrollTo('#idTab777');return false;"{/if}>
<span>
<i class="icon-pencil"></i>&nbsp;

{l s='Add Review' mod='spmgsnipreview'}

</span>
</a>
{/if}



<a class="btn-spmgsnipreview btn-default-spmgsnipreview"
href="{if $spmgsnipreviewajax == 1}{$spmgsnipreviewsharing_url|escape:'htmlall':'UTF-8'}{/if}#idTab777"
{if $spmgsnipreviewis_bug == 1 && $spmgsnipreviewajax == 0}onclick="rating_review_shop('rat_rel1',5); rating_checked1=true;$.scrollTo('#idTab777');return false;"{/if}>
<span>
<img src="{$base_dir_ssl|escape:'htmlall':'UTF-8'}modules/spmgsnipreview/views/img/{$spmgsnipreviewactivestar|escape:'htmlall':'UTF-8'}" class="title-rating-one-star" alt="{l s='View Reviews' mod='spmgsnipreview'}"/>
{l s='View Reviews' mod='spmgsnipreview'}
</span>
</a>

1624531212183.png
Post automatically merged:

<a class="btn-spmgsnipreview btn-primary-spmgsnipreview"
href="{if $spmgsnipreviewajax == 1}{$spmgsnipreviewsharing_url|escape:'htmlall':'UTF-8'}{/if}#idTab777"
id="idTab777-my-click"
{if $spmgsnipreviewis_bug == 1 && $spmgsnipreviewajax == 0}onclick="rating_review_shop('rat_rel1',5); rating_checked1=true;$.scrollTo('#idTab777');return false;"{/if}>

<span>
<i class="icon-pencil"></i>&nbsp;

{l s='Add Review' mod='spmgsnipreview'}

</span>
</a>
{/if}


<a class="btn-spmgsnipreview btn-default-spmgsnipreview"
href="{if $spmgsnipreviewajax == 1}{$spmgsnipreviewsharing_url|escape:'htmlall':'UTF-8'}{/if}#idTab777"
{if $spmgsnipreviewis_bug == 1 && $spmgsnipreviewajax == 0}onclick="rating_review_shop('rat_rel1',5); rating_checked1=true;$.scrollTo('#idTab777');return false;"{/if}>

1624531307973.png
Post automatically merged:

1624531376097.png
 

Marc

Active member
XNullUser
Joined
Feb 27, 2021
Messages
502
Reaction score
33
Points
28
NullCash
39
Awesome!! Now It's working perfectly!! You're a GREAT coder (y)
However, I'm getting this error in the chrome console after posting the review-

Uncaught TypeError: document.getElementById(...) is null

Should I worry about that?
Post automatically merged:

Sorry for the incomplete information, I get the above error when I click the "View Reviews" button.
 

d-shilko

Well-known member
☆☆ Special ☆☆
☆ Pro ☆
Joined
Jun 10, 2021
Messages
2,538
Reaction score
1,530
Points
113
NullCash
4,422
Don't worry if all work ok. I told not perfect code just patch.
 

Marc

Active member
XNullUser
Joined
Feb 27, 2021
Messages
502
Reaction score
33
Points
28
NullCash
39
It's working fine so far, I'll update if I find any errors.
Thank you so much for your help, it's priceless.
And I am amazed by your patience! You're such a great guy :)
Thanks again and God bless you!
Kind Regards
 

d-shilko

Well-known member
☆☆ Special ☆☆
☆ Pro ☆
Joined
Jun 10, 2021
Messages
2,538
Reaction score
1,530
Points
113
NullCash
4,422
And one more. If rating 0 you see empty star. It is bad for customer psychology. My previous code have condition If rating 0 you see 5 star.
Consider this.
Post automatically merged:

You can ask me for help if find error :)
 

Marc

Active member
XNullUser
Joined
Feb 27, 2021
Messages
502
Reaction score
33
Points
28
NullCash
39
Where will I see the empty star? on the product page or somewhere else? Please let me know.
Post automatically merged:

And one more thing, is there any easy way to replace the comma with a dot? currently, it shows a rating like this everywhere- 5,00/5 and I want to show it like this- 5.00/5
 

d-shilko

Well-known member
☆☆ Special ☆☆
☆ Pro ☆
Joined
Jun 10, 2021
Messages
2,538
Reaction score
1,530
Points
113
NullCash
4,422
I think no. Because module read this float variable from database. And save to DB as comma separate.
May be required many addition of module. I will watch later.
Post automatically merged:

comma everywhere in prestashop 1.6 it is core setup.
1624536709747.png
 
Last edited:

Marc

Active member
XNullUser
Joined
Feb 27, 2021
Messages
502
Reaction score
33
Points
28
NullCash
39
I think that depends on the currency, select USD as currency and you'll see a dot.
Screenshot 2021-06-24 174607.jpg
 

d-shilko

Well-known member
☆☆ Special ☆☆
☆ Pro ☆
Joined
Jun 10, 2021
Messages
2,538
Reaction score
1,530
Points
113
NullCash
4,422
Yes. I was talking about this. Module not support localization. Comma or dot always depends of localization, for example you OS.
 

Marc

Active member
XNullUser
Joined
Feb 27, 2021
Messages
502
Reaction score
33
Points
28
NullCash
39
That’s a good point 👍
And it is not a necessary thing, so can be ignored, you have already done lots of work on this.
Thanks again 🙂
 

d-shilko

Well-known member
☆☆ Special ☆☆
☆ Pro ☆
Joined
Jun 10, 2021
Messages
2,538
Reaction score
1,530
Points
113
NullCash
4,422
Specially for you. And like i said module have not localization. Module use patch.
/modules/spmgsnipreview/classes/spmgsnipreviewhelp.class.php
line 291 replace comma to dot

all function from 257 line

public function getAvgReview($data = null){


$id_product = isset($data['id_product'])?$data['id_product']:null;

$sql_cond_product = '';
if($id_product){
$sql_cond_product = '`id_product` = '.(int)($id_product).' AND ';
}


$sql_cond_customer = '';
$user_id = (int)Tools::getValue('uid');
if($user_id){
$sql_cond_customer = '`id_customer` = '.(int)($user_id).' AND ';
}




$sql_condition = $this->getConditionMultilanguageAndMultiStore(array('and'=>1));

$sql = '
SELECT round(AVG(`rating`),1) AS "avg_rating", round(AVG(`rating`),2) AS "avg_rating_decimal"
FROM `'._DB_PREFIX_.'spmgsnipreview` pc
WHERE '.$sql_cond_product.' '.$sql_cond_customer.' rating != 0 '.$sql_condition.' and is_active = 1';



$result = Db::getInstance()->getRow($sql);

//var_dumP($result);

return array('avg_rating'=>isset($result['avg_rating'])?$result['avg_rating']:0,
'avg_rating_decimal'=>(isset($result['avg_rating_decimal'])?str_replace(".",".",$result['avg_rating_decimal']):0));
}

1624541987062.png
1624541852129.png
Post automatically merged:

That’s a good point 👍
And it is not a necessary thing, so can be ignored, you have already done lots of work on this.
Thanks again 🙂
Done?
 
Last edited:

Marc

Active member
XNullUser
Joined
Feb 27, 2021
Messages
502
Reaction score
33
Points
28
NullCash
39
OMG! You're a LEGEND :love: Thank you thank you thank you :)
Kindest regards
Post automatically merged:

Hello again! I'm having another problem, the product link URLs in the reminder emails are expanded with this code- #idTab777.

Example URL- www.domain.com/tshirts/1-faded-short-sleeves-tshirt#idTab777.html

When I click the link, it directly opens the review form on the product page with 0 stars instead of the default 5 stars.
I'm struggling to find the code for the last two hours to fix it with no luck :(

So is there any way to remove it from the URL? or is this possible to have the 5 stars by default when clicking the URL?
Screenshot 2021-06-24 224322.jpg
 
Last edited:
Top