- This topic has 3 replies, 2 voices, and was last updated 12 years, 11 months ago by .
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- You must be logged in to reply to this topic.
Support site for Tips and Tricks HQ premium products
by
Tips and Tricks HQ Support Portal › Forums › WP eStore Forum › WP eStore General Questions › Automatic Coupon from session var
I’d like to pre-fill coupon codes based on the entry page a customer is using. For example, they use a link to a landing page from an ad that promises 10% discount. When the user gets to the landing page, I write the coupon code into a session variable (easy so far).
Now, when the same user checks out, I’d like to have the coupon code applied (pre-filled) into the coupon field. How could I best achieve this in eStore?
When the customer goes to your “Checkout page” you can call the following function and pass in the coupon code value from the session var which will apply the discount in the cart.
eStore_apply_discount($coupon_code)
So before calling this function your code should check that the current page is the checkout page and that there is a coupon code saved in the session.
Thanks, that works great!
However, when the customer clicks on the checkout page again, I get the ESTORE_DISCOUNT_LIMIT. Makes sense, since the coupon can only be applied once. How can I check in PHP if a coupon code has been applied or reset the coupon code?
I just couldn’t find a reference of available eStore functions, great if you can point me to it (similar to your eStore shortcodes).
I used if ($_SESSION['discount_applied_once'] != 1)
before applying the discount code. Seems to resolve the issue.