Problems, need help? Have a tip or advice? Post it here.
13 posts Page 1 of 2
Hi,

I've nearly completed my cart implementation and am at the stage of testing a coupon code - when I apply it I get my flash message "Your coupon discount has been applied!" but the price / discount etc does not show on the page.

This is my template code for checkout.php - It's as per the example with a few layout adjustments to suit my template, unless I am missing something

Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:no_cache />

<cms:embed 'header.inc' />

<cms:embed 'masthead.inc' />

<cms:embed 'breadcrumbs.inc' />



<div class="container">
   <div class="row">
           
        <div class="span12">

           <div class="page-header">
             <h1>Checkout <small>Review your order and checkout</small></h1>
          </div>
            
            
            <cms:if "<cms:pp_count_items />" >
            <div class="alert">
                Please review your order before we proceed to PayPal to make the payment. <br>
                If you have a discount coupon, please apply it below.
            </div>


                    <table class="table table-striped" id="cart">
                        <thead>
                            <tr>
                                <th class="col-desc">Item</th>
                                <th class="col-quantity">Qty</th>
                                <th class="col-price">Price</th>
                                <th class="col-subtotal">Total</th>
                            </tr>
                        </thead>
                        <tbody>
                            <cms:pp_cart_items>
                                <tr>
                                    <td class="col-desc">
                                        <a href="<cms:show link />" class="cart-thumb">
                                            <img src="<cms:show product_thumb />" width="70" height="64" alt="<cms:show title />">
                                        </a>
                                        <div class="desc-box">
                                            <a href="<cms:show link />"><cms:show title /></a>
                                            <p><cms:pp_selected_options separator='<br>' /></p>
                                        </div>
                                    </td>
                                    <td class="col-quantity"><cms:show quantity /></td>
                                    <td class="col-price">
                                        <cms:if line_discount><span class="compare-price"><cms:get_custom_field 'store_currency' masterpage='globals.php' /><cms:number_format orig_price /></span></cms:if>
                                        <cms:get_custom_field 'store_currency' masterpage='globals.php' /><cms:number_format price />
                                    </td>
                                    <td class="col-subtotal"><cms:get_custom_field 'store_currency' masterpage='globals.php' /><cms:number_format line_total /></td>
                                </tr>
                            </cms:pp_cart_items>
                           
                            <cms:if "<cms:pp_discount />" || "<cms:pp_shipping />" || "<cms:pp_taxes />" >
                                <tr class="row-extras">
                                    <td class="col-extras-label" colspan="3">Subtotal</td>
                                    <td class="col-extras"><cms:get_custom_field 'store_currency' masterpage='globals.php' /><cms:number_format "<cms:pp_sub_total />" /></td>
                                </tr>
                            </cms:if>
               
                            <cms:if "<cms:pp_discount />">
                                <tr class="row-extras">
                                    <td class="col-extras-label" colspan="3">Discount:</td>
                                    <td class="col-extras col-discount"><span class="subtract">-</span><cms:get_custom_field 'store_currency' masterpage='globals.php' /><cms:number_format "<cms:pp_discount />" /></td>
                                </tr>
                            </cms:if>
                           
                            <cms:if "<cms:pp_shipping />">
                                <tr class="row-extras">
                                    <td class="col-extras-label" colspan="3">Shipping:</td>
                                    <td class="col-extras"><cms:get_custom_field 'store_currency' masterpage='globals.php' /><cms:number_format "<cms:pp_shipping />" /></td>
                                </tr>
                            </cms:if>
                           
                            <cms:if "<cms:pp_taxes />">
                                <tr class="row-extras">
                                    <td class="col-extras-label" colspan="3">Taxes:</td>
                                    <td class="col-extras"><cms:get_custom_field 'store_currency' masterpage='globals.php' /><cms:number_format "<cms:pp_taxes />" /></td>
                                </tr>
                            </cms:if>
                           
                            <tr class="row-total">
                                <td class="col-total-label" colspan="3">Total:</td>
                                <td class="col-total"><cms:get_custom_field 'store_currency' masterpage='globals.php' /><cms:number_format "<cms:pp_total />" /></td>
                            </tr>
                        </tbody>
                    </table>
                    <div class="cart-operations">
                        <div class="coupon-box pull-left">
                       
                            <!-- START COUPON FORM -->
                            <cms:form method="post" anchor='0'>
                                <cms:if k_success >
                                    <cms:pages masterpage="<cms:pp_config 'tpl_coupons' />" custom_field="code==<cms:show frm_coupon_code /> | end_date>=<cms:date format='Y-m-d' />" limit='1'>
                                        <cms:no_results>
                                            <cms:delete_session 'coupon_found' /> 
                                            <cms:delete_session 'coupon_code' />
                                            <cms:delete_session 'coupon_discount' />
                                            <cms:delete_session 'coupon_type' />
                                            <cms:delete_session 'coupon_min_amount' />
                                            <cms:delete_session 'coupon_free_shipping' />
                                           
                                            <cms:set_flash name='coupon_flash_msg' value="<p class='error'>Coupon is invalid or expired!</p>" />
                                            <cms:pp_refresh_cart />
                                        </cms:no_results>
                                       
                                        <cms:set_session name='coupon_found' value='1' /> 
                                        <cms:set_session name='coupon_code' value=code />
                                        <cms:set_session name='coupon_discount' value=discount />
                                        <cms:set_session name='coupon_type' value=type />
                                        <cms:set_session name='coupon_min_amount' value=min_amount />
                                        <cms:set_session name='coupon_free_shipping' value=free_shipping />
                                       
                                        <cms:if min_amount ge "<cms:pp_sub_total />" >
                                            <cms:set_flash name='coupon_flash_msg' value="<p class='notice'>Coupon discount will be applied when cart total is more than <cms:pp_config 'currency_symbol' /><cms:show min_amount />!</p>" />
                                        <cms:else />
                                            <cms:set_flash name='coupon_flash_msg' value="<p class='success'>Your coupon discount has been applied!</p>" />                   
                                        </cms:if>
                                        <cms:pp_refresh_cart />
                                    </cms:pages>
                                   
                                    <cms:redirect k_page_link />
                                </cms:if>
                               
                                <div class="input-append input-prepend">
                                   <cms:input type="text" placeholder="Enter coupon code" name="coupon_code" value="<cms:get_session 'coupon_code' />" class="coupon-input"/>
                                   <button type="submit" class="btn coupon-button"/>Apply Coupon</button>
                                </div>
                                <cms:get_flash 'coupon_flash_msg' />
                               
                            </cms:form>
                            <!-- END COUPON FORM -->
                           
                           
                        </div>


               
                    <cms:form method="post" anchor='0'>
                        <cms:if k_success >
                            <cms:pp_payment_gateway empty_cart='0' />
                        </cms:if>
                        <div class="pull-right">
                              <a href="<cms:pp_cart_link />" class="btn" >Edit Cart</a>
                            <cms:input name="paypal" class="btn btn-primary checkout-button" type="submit" value="Continue to PayPal" />
                        </div>
                    </cms:form>
                   
                   


 
         </div>
            <cms:else />
                <div class="message">
                    <p class="info">Your cart is empty!</p>
                </div>
            </cms:if>


        </div> 
           
   </div>
</div>



<cms:embed 'footer.inc' />


<?php COUCH::invoke(); ?>



Also - I've set shipping on each product and that breakdown does not show.
Hi Patrick,

Just to be on the same page - could you please confirm that you've renamed 'cart_ex.example.php' to 'cart_ex.php'?
@KK - Oops, my bad there, renaming has resolved the issue in terms of applying coupons etc. problem I still have is the Continue to PayPal button is not working.
.. Continue to PayPal button is not working

That is implemented in the success condition of the form shown below.
Let us troubleshoot if it is the form that is not working or is it the cms:pp_payment_gateway tag.
For this, please remove the <cms:if k_success > condition to use <cms:pp_payment_gateway empty_cart='0' /> unconditionally (make sure that the cart has at least one item in it)
Code: Select all
<cms:form method="post" anchor='0'>
    <cms:if k_success >
        <cms:pp_payment_gateway empty_cart='0' />
    </cms:if>
    <div class="pull-right">
        <a href="<cms:pp_cart_link />" class="btn" >Edit Cart</a>
        <cms:input name="paypal" class="btn btn-primary checkout-button" type="submit" value="Continue to PayPal" />
    </div>
</cms:form>

Please let me know if using <cms:pp_payment_gateway empty_cart='0' /> unconditionally redirects to PayPal.
I can confirm the following simply redirects without even a glimpse of the checkout.php page:

Code: Select all
                    
<cms:form method="post" anchor='0'>
<cms:pp_payment_gateway empty_cart='0' />
<div class="pull-right checkout-box">
<a href="<cms:pp_cart_link />" class="btn" >Edit Cart</a>
<cms:input name="paypal" class="btn btn-primary checkout-button" type="submit" value="Continue to PayPal" />
</div>
</cms:form>
OK, so that means the cms:pp_payment_gateway tag is working fine.
We need to now simply debug the form as to why the k_success condition is not being triggered.

Please place a cms:dump tag within the form while commenting out the pp_payment_gateway tag
<cms:form method="post" anchor='0'><cms:dump />
<cms:if k_success >
<cms:ignore><cms:pp_payment_gateway empty_cart='0' /></cms:ignore>
</cms:if>
<div class="checkout-box">
<cms:input name="paypal" class="button checkout-button" type="submit" value="Continue to PayPal" />
</div>
</cms:form>

Upon submitting the form, do you see the 'k_success' variable being set to '1'?
Hi KK,

When I tried that I could not see reference to k_success

This is the code after submitting

Code: Select all
<a name="kformname1"></a><form  method="post" name="kformname1" action="" accept-charset="utf-8">

<div class="checkout-box">
<input type="submit" name="paypal"  id="paypal" value="Continue to PayPal"  class="button checkout-button"/>
</div>
<UL><LI><b><font color="red">form</font></b><UL><LI><b>k_cur_form: </b>kformname1</LI><LI><b>k_cur_form_method: </b>post</LI><LI><b>k_cur_form_separator: </b>|</LI></UL></LI></UL>
<input type="hidden" name="k_hid_kformname1"  id="k_hid_kformname1" value="kformname1" /></form>
If that is indeed the output after form submission ('Continue to PayPal' button), strangely I don't see 'k_submitted' being set either.

Anyways, please try adding this to the form
Code: Select all
<cms:input type="hidden" name="dummy" value="dummy" />

Does this make the k_success variable appear? Please let me know. Thanks.
Hi KK,

Still didn't work or output - however, I took your starter / example checkout.php again and replaced mine.

I then removed the header and tested - it work, I proceed to include my own header - it worked.

I add my footer in and it does not work...it's something to do with my footer which looks like this, more specifically I think it's the site wide inclusion of the cart-modal.js + input-restriction.js

Code: Select all
<hr>

   <footer>
      <div class="container">
         <div class="row">
            <div class="span12">
            &copy; <cms:php>echo date('Y');</cms:php> <cms:get_custom_field 'club_name' masterpage='globals.php' /></div>
            </div>
         </div>
      </div>
   </footer>



    <!-- Le javascript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="assets/js/bootstrap-transition.js"></script>
    <script src="assets/js/bootstrap-alert.js"></script>
    <script src="assets/js/bootstrap-modal.js"></script>
    <script src="assets/js/bootstrap-dropdown.js"></script>
    <script src="assets/js/bootstrap-scrollspy.js"></script>
    <script src="assets/js/bootstrap-tab.js"></script>
    <script src="assets/js/bootstrap-tooltip.js"></script>
    <script src="assets/js/bootstrap-popover.js"></script>
    <script src="assets/js/bootstrap-button.js"></script>
    <script src="assets/js/bootstrap-collapse.js"></script>
    <script src="assets/js/bootstrap-carousel.js"></script>
    <script src="assets/js/bootstrap-typeahead.js"></script>
   
   <script src="assets/js/cart-modal.js" type="text/javascript"></script>
   <script src="assets/js/input-restriction.js" type="text/javascript"></script>



  </body>
</html>






EDIT: Perhaps not specific to those two JS files, seems to be all of them - as when removed I get success_1 and if I take the ignore of it will go to paypal.
OK, so if you think inclusion of cart-modal.js + input-restriction.js is the problem, make that inclusion conditional - i.e. test first which template we are on and then include them only on the required templates (instead of doing it globally for all templates) e.g.
Code: Select all
<cms:if k_template_name='index.php' >
   <script type="text/javascript">
        // Set global values for 'js/cart-modal.js' that follows
        var cart_link = "<cms:link "<cms:pp_config 'tpl_ajax_cart' />" />";
        var checkout_link = "<cms:pp_checkout_link />";
    </script>
   <script src="assets/js/cart-modal.js" type="text/javascript"></script>
</cms:if>
<cms:if k_template_name='index.php' ||  k_template_name='cart.php' >
   <script src="assets/js/input-restriction.js" type="text/javascript"></script>
</cms:if>

Does this help?
13 posts Page 1 of 2
cron