Jump to content

Product Review "submit" button ADDS item to cart!!


djcaseanova
 Share

Recommended Posts

When someone goes to the store and tries to submit a review for the product it adds the product to the cart. This will occur whether a user is logged in or not. Has anyone else had this issue or know how to get this resolved?

 

It's a serious problem, because if someone has the intention of making an order, they could accidentally order items, OR this could eventually ruin my stock inventory by pulling tangibles out of stock.

Link to comment
Share on other sites

Sure.
http://www.treasure-post.com/store/

Interesting that it's a skin issue, I have received product reviews previously without issue. This is the first I have noticed this and I have not updated the skin. The ONLY recent update I have done that was button related was for the admin section with a fix from github. This fix was related to a "save" button issue for coupons not saving, but it had global implications.

That fix is located: https://github.com/cubecart/v6/commit/198f6dffbf56f96605a7e7be704b34602cc2ba37

Link to comment
Share on other sites

In your skin template 'galaxyx', please examine the template content.product.php. I don't have a copy so, you will need to find what looks like the following:

                  {foreach from=$PRODUCT.discounts item=discount}
                  <tr>
                     <td>{$discount.quantity}+</td>
                     <td>{$discount.price}</td>
                  </tr>
                  {/foreach}
               </tbody>
            </table>
         </div>
         {/if}
      </div>
   </form>

And look for:

{include file='templates/element.product_reviews.php'}

The problem is that the element.product_reviews.php statement is getting included above the final </form> tag. The element.product_reviews.php template has its own <form> block, which causes 'nesting' and that is illegal.

Considering there are no form inputs in the "tabbed section" (Product Information and Customer Reviews), the moving of the </form> tag higher in the code should be fine. I suggest above this location:

      <div class="clear"></div>

                  <table>
                     <thead>
                        <tr>
                            <th colspan="2">Specification</th>

I suggest you contact the developer and copy this analysis to him.

Link to comment
Share on other sites

Tried giving this fix a go. Couldn't get it to work.

When I move the </form> above the element.product_reviews.php or to any other location, I get the following error.

The following errors were detected:

  • Please complete all required fields.
  • Please enter a valid email address.

All fields are filled and no email address is asked for.

 

Here is the coding for the page. Again, I appreciate your help!! I am still getting complaints about this and can't seem to figure it out.
 

{*
 * CubeCart v6
 * ========================================
 * CubeCart is a registered trade mark of CubeCart Limited
 * Copyright CubeCart Limited 2015. All rights reserved.
 * UK Private Limited Company No. 5323904
 * ========================================
 * Web:   http://www.cubecart.com
 * Email:  [email protected]
 * License:  GPL-3.0 https://www.gnu.org/licenses/quick-guide-gplv3.html
 *}
{if isset($PRODUCT) && $PRODUCT}
<div itemscope itemtype="http://schema.org/Product">
   <form action="{$VAL_SELF}" method="post" class="add_to_basket">

      <h1 itemprop="name">{$PRODUCT.name}</h1>

      <div class="col-1-2">
         <div class="content gallery">
               <a href="#" data-thumb-index="0"><img src="{$PRODUCT.medium}" alt="{$PRODUCT.name}" id="img-preview"></a>
               {if $GALLERY}
               <div class="open-clearing thumb-wrap" data-clearing>
                  {foreach from=$GALLERY item=image}
                  <div class="col-1-3"><a href="{$image.source}" class="gallerya"><img src="{$image.small}" data-image-swap="{$image.medium}" data-caption="{$PRODUCT.name}{if !empty($image.description)}: {/if}{$image.description}" class="th image-gallery" alt="{$LANG.catalogue.click_enlarge}"></a></div>
                  {/foreach}
               </div>
               {/if}
         </div>
      </div>

      <div class="col-1-2">
         <div class="content prod-details">
            
            {if ($CTRL_ALLOW_PURCHASE) && (!$CATALOGUE_MODE)}
            <h3>
               {if $PRODUCT.ctrl_sale}
               <span class="old_price" id="fbp" data-price="{$PRODUCT.full_base_price}">{$PRODUCT.price}</span>
               <span class="sale_price" id="ptp" data-price="{$PRODUCT.price_to_pay}">{$PRODUCT.sale_price}</span>
               {else}
               <span id="ptp" data-price="{$PRODUCT.price_to_pay}">{$PRODUCT.price}</span>
               {/if}
            </h3>
            {if isset($PRODUCT.discounts)}
            <p>(<a href="#quantity_discounts">{$LANG.catalogue.bulk_discount}</a>)</p>
            {/if}
            
            {else}
            
            {/if}


            {if is_array($OPTIONS)}
            {foreach from=$OPTIONS item=option}
            {if $option.type == Catalogue::OPTION_RADIO}
            <div class="row">
               <div class="small-12 columns">
                  {* If we only have one required option replace with hidden field *}
                  {if $option.required && count($option.values)===1}
                  <label for="option_{$option.option_id}" class="return">{$option.option_name}</label>
                  {$option.values.0.value_name}{if $option.values.0.price} {$option.values.0.symbol}{$option.values.0.price}{/if}
                  <input type="hidden" name="productOptions[{$option.option_id}]" class="input" id="option_{$option.option_id}" value="{$option.values.0.assign_id}" data-price="{$option.values.0.decimal_price}">
                  {else}
                  <div class="pseudo-label">{$option.option_name}{if $option.required} ({$LANG.common.required}){/if}</div>
                  <span id="error_option_{$option.option_id}">
                     {foreach from=$option.values item=value name=options}
                     <div><input type="radio" name="productOptions[{$option.option_id}]" id="rad_option_{$value.assign_id}" value="{$value.assign_id}" class="nomarg" data-price="{$value.decimal_price}"{if $smarty.foreach.options.first} rel="error_option_{$option.option_id}" {if $option.required}required{/if}{/if}>
                        <label for="rad_option_{$value.assign_id}" class="return">{$value.value_name}{if $value.price} {$value.symbol}{$value.price}{/if}</label>
                     </div>
                     {/foreach}
                  </span>
                  {/if}
               </div>
            </div>
            {elseif $option.type == Catalogue::OPTION_SELECT}
            <div class="row">
               <div class="small-12 columns">
                  {* If we only have one required option replace with hidden field *}
                  {if $option.required && count($option.values)===1}
                  <label for="option_{$option.option_id}" class="return">{$option.option_name}</label>
                  {$option.values.0.value_name}{if $option.values.0.price} {$option.values.0.symbol}{$option.values.0.price}{/if}
                  <input type="hidden" name="productOptions[{$option.option_id}]" id="option_{$option.option_id}" value="{$option.values.0.assign_id}" data-price="{$option.values.0.decimal_price}">
                  {else}
                  <label for="option_{$option.option_id}" class="return">{$option.option_name}{if $option.required} ({$LANG.common.required}){/if}</label>
                  <select name="productOptions[{$option.option_id}]" class="select" id="option_{$option.option_id}" class="nomarg" {if $option.required}required{/if}>
                  <option value="">{$LANG.form.please_select}</option>
                  {foreach from=$option.values item=value}
                  <option value="{$value.assign_id}" data-price="{$value.decimal_price}">{$value.value_name}{if $value.price} {$value.symbol}{$value.price}{/if}</option>
                  {/foreach}
                  </select>
                  {/if}
               </div>
            </div>
            {else}
            <div class="row">
               <div class="small-12 columns">
                  <label for="option_{$option.option_id}" class="return">{$option.option_name}{if $option.price} {$option.symbol}{$option.price}{/if}{if $option.required} ({$LANG.common.required}){/if}</label>
                  {if $option.type == Catalogue::OPTION_TEXTBOX}
                  <input type="text" name="productOptions[{$option.option_id}][{$option.assign_id}]" id="option_{$option.option_id}" data-price="{$option.decimal_price}" {if $option.required}required{/if}>
                  {elseif $option.type == Catalogue::OPTION_TEXTAREA}
                  <textarea name="productOptions[{$option.option_id}][{$option.assign_id}]" id="option_{$option.option_id}" data-price="{$option.decimal_price}" {if $option.required}required{/if}></textarea>
                  {/if}
               </div>
            </div>
            {/if}
            {/foreach}
            {/if}

            {if $PRODUCT.review_score && $CTRL_REVIEW}
            <p itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
               <meta itemprop="ratingValue" content="{$REVIEW_AVERAGE}">
               <meta itemprop="reviewCount" content="{$REVIEW_COUNT}">
               {for $i = 1; $i <= 5; $i++}
               {if $PRODUCT.review_score >= $i}
               <img src="{$STORE_URL}/skins/{$SKIN_FOLDER}/images/star.png" alt="">
               {elseif $PRODUCT.review_score > ($i - 1) && $PRODUCT.review_score < $i}
               <img src="{$STORE_URL}/skins/{$SKIN_FOLDER}/images/star_half.png" alt="">
               {else}
               <img src="{$STORE_URL}/skins/{$SKIN_FOLDER}/images/star_off.png" alt="">
               {/if}
               {/for}
            <div>{$LANG_REVIEW_INFO}</div>
            </p>
            {/if}

   {if ($CTRL_ALLOW_PURCHASE) && (!$CATALOGUE_MODE)}
            
         <div class="add-wrap">
                     {if $CTRL_HIDE_PRICES}
                     <p class="buy_button"><strong>{$LANG.catalogue.login_to_view}</strong></p>
                     {else if $CTRL_OUT_OF_STOCK}
                     <p class="buy_button"><strong>{$LANG.catalogue.out_of_stock}</strong></p>
                     {/if}


                        {if $PRODUCT.available <= 0}

                           <input type="submit" value="{$LANG.common.unavailable}" class="button disabled" disabled>

                        {else}
                           
                           <input type="text" name="quantity" value="1" class="quantity required">
                           <input type="hidden" name="add" value="{$PRODUCT.product_id}"> 
                           <button type="submit" value="{$LANG.catalogue.add_to_basket}" class="button"><i class="fa fa-plus"></i>{$LANG.catalogue.add_to_basket}</button>

                        {/if}


         <div class="clear"></div>
         </div>

    {/if}


         </div>
      </div>


      <div class="clear"></div>

                  <table>
                     <thead>
                        <tr>
                            <th colspan="2">{$LANG.common.specification}</th>
                        </tr>
                    </thead>
                        <tbody>
                           <tr>
                              <td>{$LANG.catalogue.product_code}</td>
                              <td>{$PRODUCT.product_code}</td>
                           </tr>
                           {if $PRODUCT.manufacturer}
                           <tr>
                              <td>{$LANG.catalogue.manufacturer}</td>
                              <td>{$MANUFACTURER}</td>
                           </tr>
                           {/if}
                           {if $PRODUCT.stock_level}
                           <tr>
                              <td>{$LANG.catalogue.stock_level}</td>
                              <td>{$PRODUCT.stock_level}</td>
                           </tr>
                           {/if}
                           <tr>
                              <td>{$LANG.common.condition}</td>
                              <td>{$PRODUCT.condition}</td>
                           </tr>
                           {if $PRODUCT.product_weight > 0}
                           <tr>
                              <td>{$LANG.common.weight}</td>
                              <td>{$PRODUCT.product_weight}{$CONFIG.product_weight_unit}</td>
                           </tr>
                           {/if}
                        </tbody>
                     </table>

      <div id="tabs-container">
             <ul class="tabs-menu">
                 {if !empty($PRODUCT.description)}
                 <li class="current"><a href="#tab-1">{$LANG.catalogue.product_info}</a></li>
                 {/if}
                 {if isset($PRODUCT.discounts)}
                  <li><a href="#quantity_discounts">{$LANG.catalogue.quantity_discounts}</a></li>
                  {/if}

                  {if $CTRL_REVIEW}
                  <li><a href="#reviews">{$LANG.catalogue.customer_reviews}</a></li>
                  {/if}
             </ul>
             <div class="tab">
                 {if !empty($PRODUCT.description)}
                 <div id="tab-1" class="tab-content">
                     <p>{$PRODUCT.description}</p>
                 </div>
                 {/if}

               {if isset($PRODUCT.discounts)}
                 <div id="quantity_discounts" class="tab-content">
                     <p>{$LANG.catalogue.quantity_discounts_explained}</p>
                     <br>
                     <table>
                        <thead>
                           <tr>
                              <th>{$LANG.common.quantity}</th>
                              <th>{$LANG.catalogue.price_per_unit}</th>
                           </tr>
                        </thead>
                        <tbody>
                           {foreach from=$PRODUCT.discounts item=discount}
                           <tr>
                              <td>{$discount.quantity}+</td>
                              <td>{$discount.price}</td>
                           </tr>
                           {/foreach}
                        </tbody>
                     </table>
                 </div>
                 {/if}

               {if $CTRL_REVIEW}
                  <div id="reviews" class="tab-content">
                  	
                     {include file='templates/element.product_reviews.php'}

                     {foreach from=$COMMENTS item=html}
                     {$html}
                     {/foreach}
                 </div>
                 {/if}

            </div>
         <div class="clear"></div>



      </div>
</form>
   {if $SHARE}
   {foreach from=$SHARE item=html}
   {$html}
   {/foreach}
   {/if}

   


   
</div>
{else}
<p>{$LANG.catalogue.product_doesnt_exist}</p>
{/if}

 

Link to comment
Share on other sites

I used the code above and replaced content.product.php with it. Aside from some layout issues, moving the </form> tag as described above allows for a Review submission without adding an item to the cart, and allows adding to the cart without complaining about empty review form elements..

I cannot come to any conclusion because there could very well be other factors in play that do not match how Foundation behaves.

Link to comment
Share on other sites

That's interesting. If you have time, can you take a peek at the live site (without the </form> moved) and see what comes up on your end? I  have tried multiple browsers and computers.

www.treasure-post.com/store/

To confirm, move </form> tag to above:

<div class="clear"></div>

                  <table>
                     <thead>
                        <tr>
                            <th colspan="2">{$LANG.common.specification}</th>
                        </tr>
                    </thead>
                        <tbody>

Here is a cart WITH the </form> moved
www.treasure-post.com/custom/

<div class="clear"></div>

                  <table>
                     <thead>
                        <tr>
                            <th colspan="2">{$LANG.common.specification}</th>
                        </tr>
                    </thead>
                        <tbody>

 

This gives the error as mentioned:

The following errors were detected:

  • Please complete all required fields.
  • Please enter a valid email address.
Edited by djcaseanova
Link to comment
Share on other sites

At the /custom/ site, I see a rogue </form> tag, but otherwise, I do not get these error messages. (And now I can't access that site at all. Maybe you are doing things to it?)

The rogue </form> is here:

        <div id="reviews" class="tab-content">
    </form>
                     
    <div id="element-reviews">

 

Link to comment
Share on other sites

Bsmither, I may have been messing with it. It is up again. I am at a completely different location now, and I still get the errors in the /custom/ thread. I can't figure out why you wouldn't get the errors and I do. I am attaching a screenshot of the errors. I have also removed the rogue </form> and made no difference.

All the more reason to pull away from the Galaxy skin I believe. Developer has gone radio silent for quite sometime in the other forums. Once I changed the skin over to something else, worked without an issue, and asked for an email address. I wonder if somewhere along the line the email address textbox which is required, went missing.

Screen Shot 2015-11-04 at 3.19.28 PM.png

Edited by djcaseanova
Link to comment
Share on other sites

I was visiting the /custom/ site and when looking at the page referenced by the image above, I clicked Add to Basket. The AJAX was sent and response received but the sidebasket did not have the item added. (The AJAX is the info from the "add to basket" form and the response is only just the appropriate HTML that draws the sidebasket.)

I dumped all the cookies to this domain and tried to refetch the page. I got a MySQL Server has gone away.

A few minutes later, I requested the page again and it was received.

This time, Add to Basket worked.

The error banner seems to be CubeCart's banner, not the  javascript-powered 'validator' error message, which should appear adjacent to the required field that is empty.

If it is CubeCart's banner, it won't come in with the AJAX response. These banners only come in with a complete new page.

Are you testing this page when your are signed in as admin, signed in as a regular customer, or both?

Link to comment
Share on other sites

Sorry, yes I may have been tinkering again. Okay, so with the suggested </form> change, when I am logged in to a standard user account, the review seems to be working now.

However, in other skins, a user does not need to be logged in to post a review. This may be where the problem comes in. If I am not logged in as any user and go to post a review, I get the error banner as I attached above. I am totally okay with that... IF I can now find a way to modify the language so I can make people aware that they need to be logged in we can make it work!

 

 

Link to comment
Share on other sites

Well, I got the MySQL went away again.

But I filled out the Review form and there is NO email field presented for a visitor who is not logged in. A value for this field is checked in the CubeCart code, for a value's presence, and that it looks like an email address.

So, we need to check the contents of the template element.product_reviews.php. This what I see for your template:

{else}
    <div class="col-3-12">
        <div class="content">
            <label for="rev_name">{$LANG.common.name}</label>
        </div>
    </div>
    <div class="col-9-12">
        <div class="content">
            <input id="rev_name" type="text" name="review[name]" value="{$WRITE.name}" class="input" placeholder="{$LANG.common.name} {$LANG.form.required}" required>
        </div>
    </div>
{/if}

It needs to be this:

{else}
    <div class="col-3-12">
        <div class="content">
            <label for="rev_name">{$LANG.common.name}</label>
        </div>
    </div>
    <div class="col-9-12">
        <div class="content">
            <input id="rev_name" type="text" name="review[name]" value="{$WRITE.name}" class="input" placeholder="{$LANG.common.name} {$LANG.form.required}" required>
        </div>
    </div>
    <div class="col-3-12">
        <div class="content">
            <label for="rev_email">{$LANG.common.email}</label>
        </div>
    </div>
    <div class="col-9-12">
        <div class="content">
            <input id="rev_email" type="text" name="review[email]" value="{$WRITE.email}" placeholder="{$LANG.common.email} {$LANG.form.required}" required>
        </div>
    </div>
{/if}

I think this is not a case where Cubecart added this field at some time later than what the skin was coded for. (But I can check if that was the case.)

Link to comment
Share on other sites

Checked into the server going away. This must be related to something the host was working on today. They claim it wouldn't cause any problems. I wonder if that's it. I have NOT seen it on my systems yet. However, I did get an error email from my forum the other day with this same error, but doesn't give me any causes.

The replacement of code worked, now it's a formatting issue. The textbox for the email is incorrectly sized.

I have compared the element.product_reviews.php to other skins and this is the only skin with the missing elements. I do not believe this is a cubecart fault... but the skins I checked against were bundled with Cubecart, so they may have been upgraded to match.

Link to comment
Share on other sites

Yes. There is a class="input" I failed to copy over from the "name" input element.

According to the code repository history for this file, the code to check for the presence of a value for 'email' has been there since the code for CC6 was imported from CC5 on day-one.

Link to comment
Share on other sites

Found the input error. With that fixed, there is an alignment issue for the actual "Rating" lining up with the radio buttons. I don't want to bug you too much further on this issue, but I may be overlooking it in the code, is there a break somewhere I am not seeing that needs to be inserted to align them?

Link to comment
Share on other sites

Just after the <form> tag, there is a <div class="content"> tag. Then starts a repeating series of <div class="col-3-12"> and <div class="col-9-12"> pairs of code blocks.

All of those pairs of <div> code blocks are "floating", which is a moderate design flaw.

Just after the "Rating" pair of <div> code blocks, there is: <div class="clear"></div>

Try adding that after each other pair of <div> code blocks and see if that straightens out the alignment.

Also, try this:

<div class="col-9-12">
  <div class="content input">
{foreach from=$RATING_STARS item=star}
    <input type="radio" id="rating_{$star.value}" name="rating" class="radio" value="{$star.value}" class="rating" {$star.checked}>{$star.value}
{/foreach}
  </div>
</div>

Just above the {foreach}, I've added the 'input' class which makes the radio button group look like all the other form elements.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...