Tips and Tricks HQ Support

Support site for Tips and Tricks HQ premium products

  • Home
  • Contact Us
  • Documentation
  • Forum Home
    • Forum
    • Forum Search
    • Forum Login
    • Forum Registration

Scripting API to validate a coupon code from an external site?

by

Tips and Tricks HQ Support Portal › Forums › WP eStore Forum › Scripting API to validate a coupon code from an external site?

Tagged: api, coupon code, php functions, scripting api

  • This topic has 2 replies, 3 voices, and was last updated 11 years ago by admin.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • May 1, 2014 at 11:28 pm #10754
    ncarling
    Member

    Hi,

    I’ve figured out a way to pass a coupon code directly from a GET parameter into the shopping cart using the php function eStore_apply_discount(), but I’m wanting to take this a bit further, and am not sure if the functionality exists.

    The workflow I’m going for is to send an email with a “discounted” link (or button – whatever), that sends the buyer to the product’s website, which is a standalone webpage, written in PHP (not part of the WordPress site where eStore lives). If they subsequently hit this page’s Add to Cart button, they’ll go to the cart, and a coupon code gets applied automatically.

    I’m most of the way there, but am missing one piece. Here’s what I have so far:

    1. link/button in email points to example.com/?pc=COUPONCODE

    2. productsite.com grabs the GET param (PHP code), validates it (against my standards – less than N characters and only contains letters/numbers)

    3. if everything looks ok, the PHP code stores the coupon in a hidden POST field (in the <form> where the add to cart button is at the bottom of the page). It also adds a cogratulatory note right above the button that says that a coupon has been detected and will be applied in the shopping cart.

    4. User clicks Add to Cart, coupon code is sent to eStore shopping cart page (let’s say the URL is something like example.com/store/shopping-cart/ as a hidden POST param

    5. shopping cart page grabs the coupon code, validates it and applies the coupon using the eStore_apply_discount() function.

    This all works fine, but I’d like to take it one more step and have step 2 actually validate the coupon code against eStore’s list of coupons – last thing I want is for a buyer to try using an expired discount link and not find out the coupon’s no good until they get to the shopping cart (!).

    Is there a way I can have PHP code on an external site reach into eStore and check a coupon code to make sure it’s valid (and for bonus points, bring back the discount terms – i.e., 10% or $5 off), so I can reflect the final pricing on the sales page itself, *before* the user clicks Add to Cart?

    Unfortunately, I think this is a fairly simple question that I fear I’m asking in an overly-complex way… my apologies in advance… :D

    May 2, 2014 at 2:12 am #62670
    wzp
    Moderator

    Since the standalone page is “special,” why not have the button add a product that is identical in every way to the non discounted item; except the price?

    May 2, 2014 at 4:50 am #62671
    admin
    Keymaster

    We don’t have an API to check the discount coupon code from an external site. We can do a custom job for this if you really need it:

    https://support.tipsandtricks-hq.com/need-custom-work-done

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Log In

Forum Related

  • Forum Home
  • Forum Search
  • Forum Registration
  • Forum Login

Support Related Forms

  • Contact Us
  • Customer Support
  • Request a Plugin Update
  • Request Fresh Download Links

Useful Links

  • Plugin Upgrade Instructions
  • WP eStore Documentation
  • WP eMember Documentation
  • WP Affiliate Platform Documentation
  • Tips and Tricks HQ Home Page
  • Our Projects

Quick Setup Video Tutorials

  • WP eStore Video Tutorial
  • WP eMember Video Tutorial
  • WP Affiliate Platform Video Tutorial
  • Lightbox Ultimate Video Tutorial

Our Other Plugins

  • WP Express Checkout
  • Stripe Payments Plugin
  • Simple Shopping Cart Plugin
  • Simple Download Monitor

Copyright © 2025 | Tips and Tricks HQ