Hello and Greetings to one and all and KK Sir.
I am trying to do a Rating and Review system for an ecommerce site.
I am using the following:
1. Comment System (viewtopic.php?f=8&t=8397)
2. Votes, Ratings & Polls Module (viewtopic.php?f=5&t=8133)
What I have:
1. product.php (holding the products, clonable template and the couch cart)
2. review.php (holding the product id on which review is being posted, user id of the user posting the review, the review, star rating given by the user)
review.php template
Snippet from the product.php template that is implementing the review and rating
The Issue
The review gets saved as intended, but the rating doesnot. What happens is that only the latest rating gets saved. while the remaining do not.
For example, if I give a 4-star rating, its saves in the backend. Now when I give a new rating, lets say 1 star, this saves in the back end, but the total votes are always shown to be 1.
How can all the star ratings be saved in the backend?
Thanks in advance.
Regards,
GenXCoders
I am trying to do a Rating and Review system for an ecommerce site.
I am using the following:
1. Comment System (viewtopic.php?f=8&t=8397)
2. Votes, Ratings & Polls Module (viewtopic.php?f=5&t=8133)
What I have:
1. product.php (holding the products, clonable template and the couch cart)
2. review.php (holding the product id on which review is being posted, user id of the user posting the review, the review, star rating given by the user)
review.php template
- Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Product Comments' clonable='1' parent="_product_" executable='0' order="4" >
<cms:editable name='ticket_comments' type='relation' label="Product Reviewed" masterpage='product.php' has='one' order="1" required="1" />
<cms:editable name='username' type='relation' label='Username' masterpage='users/index.php' has='one' order="2" required="1" />
<cms:editable name='review' type='textarea' label='Review' order="3" required="1" />
<cms:editable name='rating_by_user' label="Rating by User" type='text' order="4" />
</cms:template>
<?php COUCH::invoke(); ?>
Snippet from the product.php template that is implementing the review and rating
- Code: Select all
<cms:editable name="rating" label="Product Rating" type="group" order="12" />
<cms:editable name='rating_product' label="Product Rating" type='vote_stars' search_type='decimal' allow_zero_stars='0' group="rating" order="1" />
- Code: Select all
<cms:form
masterpage='review.php'
mode='create'
enctype='multipart/form-data'
method='post'
anchor='0'
>
<cms:if k_success >
<!-- New Review Added -->
<!-- k_page_title = Product Page Id - User Id -->
<cms:db_persist_form
_invalidate_cache='0'
_auto_title='0'
k_page_title = "<cms:show product_id_rating />-<cms:show k_user_id />"
username=k_user_id
ticket_comments=k_page_id
rating_by_user = frm_rating_by_user
/>
<cms:if k_success>
<!-- Star Rating Update -->
<cms:db_persist
_masterpage="product.php"
_mode='edit'
_page_id=product_id_rating
rating_product = frm_rating_by_user
/>
<cms:set_flash name='submit_success' value='1' />
<cms:redirect k_page_link />
</cms:if>
</cms:if>
<cms:if k_error >
<div class="row">
<cms:each k_error >
<div class="col-md-12">
<div class="alert alert-danger shadow-z-1">
<cms:show item />
</div>
</div>
</cms:each>
</div>
</cms:if>
<cms:if "<cms:not submit_success />" >
<div class="col-md-3">
<strong>Your Rating</strong>
<div class="gxcpl-ptop-5"></div>
<cms:input type='bound' name='rating_by_user' opt_values='1 | 2 | 3 | 4 | 5' />
<div class="gxcpl-ptop-10"></div>
</div>
<div class="col-md-9">
<cms:hide>
<cms:input type="bound" name="review" placeholder="Your Review" class="form-control" />
</cms:hide>
<textarea name="f_review" class="form-control" placeholder="Your Review" validator_msg="required=You cannot submit a blank review" required="1"></textarea>
<div class="gxcpl-ptop-10"></div>
</div>
<div class="col-md-12 text-center">
<cms:input type="submit" class="btn gxcpl-btn-grey-blue" value="SUBMIT REVIEW" name="submit"/>
<div class="gxcpl-ptop-40"></div>
</div>
</cms:if>
</cms:form>
The Issue
The review gets saved as intended, but the rating doesnot. What happens is that only the latest rating gets saved. while the remaining do not.
For example, if I give a 4-star rating, its saves in the backend. Now when I give a new rating, lets say 1 star, this saves in the back end, but the total votes are always shown to be 1.
How can all the star ratings be saved in the backend?
Thanks in advance.
Regards,
GenXCoders