Forum for discussing general topics related to Couch.
6 posts Page 1 of 1
Think of this scenario:
1. A users adds a product to cart and is sent to the cart page.
2. User has a coupon and applies it ( Which means a coupon session will be created)
3. Now user decided to delete the item he added to the cart.
Now my question is will the coupon session be deleted? Does emptying the cart delete all sessions set?

Thank you
Does emptying the cart delete all sessions set?

No. Emptying the cart only clears out the cart's contents from the session. Anything else in the session remains untouched.
Ok ok. Will this behavior not be a problem if let’s say there is a change in users on the same computer?
Is there, by chance, a link to remove the coupon without interfering with the items? I don't want to do a session_destroy() since that kills everything.

Another question: I'd like to be able to use and IF statement for if coupon_found

My idea is if there is no coupon, have a button on the cart page that says "Add coupon". If coupon_found, have the button say "Clear coupon"

I've tried cms:dump in all the iterating tags and I'm not sure where to get it. I've even tried to get it from the cms:gpc tag, but was unsuccessful.
Anyone have any ideas on how I can make that IF statement?

EDIT: I did create a page to link to that runs the delete sessions then redirect back:

Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<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:pp_refresh_cart />
<cms:redirect url="<cms:link masterpage='cart.php' />" />
<?php COUCH::invoke(); ?>


That last line pp_refresh_cart is important because without it, the cart keeps the values for some reason.

I still wish I knew how to say IF coupon_found ....

anyone have any ideas?
Code: Select all
<cms:set has_coupon = "<cms:get_session 'coupon_found' default='0' />" />
<cms:if "<cms:not has_coupon />" >Add coupon<cms:else/>Clear coupon</cms:if>

That?
I'm not sure why I was tying to use get_session tag and it wasn't working. But yes, Anton, that's what I needed. So now it works with just an "if" statment:

Code: Select all
<cms:if "<cms:get_session 'coupon_found' />" >
                                <button><a href="<cms:link masterpage='clear_coupon.php' />" >Remove Coupon</a></button>
                            <cms:else />
                               <button><a href="<cms:link masterpage='coupons.php' />" >Add Coupon</a></button>
                            </cms:if>


Thanks so much.
6 posts Page 1 of 1