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

I am having issues with the Coupon Code system, I have applied it to my cart.php page, but when the code is applied, the page refreshes with no result, and no flash message.

My code:

Code: Select all
<?php require_once( 'bfwadmin/cms.php' ); ?>
<cms:template title='Cart' />
<cms:no_cache />

<body>
   <div id="filter"></div>
   <section class="content_width inner_ol">
      <h1>Shopping Cart</h1>
      <br>
      <cms:if "<cms:pp_count_items />" >
         <cms:pp_cart_form style="width: 100%;">
            <table class="ol">
                  <tr>
                     <td class="cart-remove">
                     </td>
                     <td class="ol">
                        <h4>Item</h4>
                     </td>
                     <td class="ol">
                        <h4>Qty</h4>
                     </td>
                     <td class="ol">
                        <h4>Price</h4>
                     </td>
                     <td class="ol">
                        <h4>Total</h4>
                     </td>
                  </tr>
                  <cms:pp_cart_items>
                     <tr class="cart-row ol">
                        <td class="cart-remove">
                           <a href="<cms:pp_remove_item_link />" title="Remove" class="hover"><p>&#x2717;</p></a>
                        </td>
                        <td class="cart-details ol">
                           <a href="<cms:show link />" class="cart-thumb">
                              <img src="<cms:show product_thumb />">
                           </a>
                           <div>
                              <a href="<cms:show link />"><h4><cms:show title /></h4></a>
                              <p><cms:pp_selected_options separator='<br>' /></p>
                           </div>
                        </td>
                        <td class="qty ol">
                           <input name="qty[<cms:show line_id />]" class="qty" type="number" min="0" step="1" value="<cms:show quantity />" title="Quantity">
                        </td>
                        <td class="ol">
                           <cms:if line_discount><h4>$<cms:number_format orig_price /></h4></cms:if>
                           <h4>$<cms:number_format price /></h4>
                        </td>
                        <td><h4>$<cms:number_format line_total /></h4></td>
                     </tr>
                  </cms:pp_cart_items>
                     
                     <cms:if "<cms:pp_shipping />">
                        <tr class="cart-row ol">
                           <td colspan="3"></td>
                           <td><h4>Shipping:</h4></td>
                           <td><h4>$<cms:number_format "<cms:pp_shipping />" /></h4></td>
                        </tr>
                     </cms:if>
               
                     <tr>
                        <td colspan="3">
                        </td>
                        <td><h4>Total: </h4></td>
                        <td><h4>$<cms:number_format "<cms:pp_total />" /></h4></td>
                     </tr>
               </table>
               <div class="cart-operations">
                  <div class="coupon">
                     
                     <!-- 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>
                               
                                <cms:input type="text" placeholder="Enter coupon code." name="coupon_code" value="<cms:get_session 'coupon_code' />" class="coupon"/>
                                <button class="button" type="submit" ><p>Apply Discount</p></button>
                               
                            </cms:form>
                            <!-- END COUPON FORM -->
                     
                  </div>
                  <div class="update">
                     <button class="button hover"  type="submit" value="Update Quantities"><p>Update Quantity</p></button>
                  </div>
                  <div class="checkout">
                     <button class="button hover" type="submit" name="checkout" value="Checkout"><p>Check Out</p></button>
                  </div>
               </div>
            </cms:pp_cart_form>
         <cms:else />
            <table class="ol">
                  <tr>
                     <td class="cart-remove">
                     </td>
                     <td class="ol">
                        <h4>Item</h4>
                     </td>
                     <td class="ol">
                        <h4>Qty</h4>
                     </td>
                     <td class="ol">
                        <h4>Price</h4>
                     </td>
                     <td class="ol">
                        <h4>Total</h4>
                     </td>
                  </tr>
                  <tr><td colspan="5" class="ol"><h2>Your cart is empty</h2></td></tr>
            </table>
            <br>
         </cms:if>
   </section>
</body>

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


I have remembered to rename the cart_ex.php file also, I noticed some people did not do that which caused the system to not work.

What else am I missing?
Hi,

As far as I could you see, you are setting the flash message but not displaying it anywhere when the page refreshes.

Please place the following somewhere at the top of the page and that should show it -
Code: Select all
<h3><cms:get_flash 'coupon_flash_msg' /></h3>

Hope this helps.
Doesn't seem to work - neither does the actual updating of the prices.

I think the issue may be somewhere in my file structure? I renamed my couch folder, do I have to update the root URL somewhere perhaps?

It seems as if the coupon system is not finding correct files to act accordingly
Is your installation online?
If yes, please grant me FTP+Couch access to it and I'll have a look at the problem.

Thanks.
4 posts Page 1 of 1
cron