=== The Uni Deals ===
Contributors: theunideals
Tags: woocommerce, coupons, discounts, students, student discount
Requires at least: 5.8
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Adds The Uni Deals student verification widget to your store and applies verified student discount codes to the cart automatically.

== Description ==

The Uni Deals verifies that a shopper really is a student, then hands your
store a discount code that the shopper never has to copy or paste. This
plugin puts the verification widget on your cart and checkout pages and
turns a verified code into a real WooCommerce coupon on the cart.

**How it works for the shopper**

1. The widget appears on the cart and checkout pages once you have saved
   your partner key, or wherever you place the `[unideals_widget]`
   shortcode.
2. The shopper clicks the widget and verifies their student status with
   The Uni Deals in a popup.
3. The widget hands the code back to the page, and this plugin sends it to
   your own site to be checked.
4. Your site asks The Uni Deals, server to server, whether that code was
   genuinely issued and what discount it carries. The shopper's browser
   never talks to that endpoint, so a code cannot be forged from the
   browser.
5. If the code checks out, the plugin creates a single use WooCommerce
   coupon that matches the confirmed discount and applies it to the cart.
   The totals update in place.

The plugin works on both the block based cart and checkout that ship with
current WooCommerce and the older shortcode based templates.

**Make it yours**

The widget wears your store's design, not ours. From **WooCommerce > The
Uni Deals** you choose a button or a full banner, pick one of four button
styles (your theme's primary or secondary button, a minimal outline, or
The Uni Deals orange), set the label, alignment and width, and color the
banner yourself. A live preview on the settings screen updates as you
type. If none of that is enough, a custom HTML slot replaces the whole
widget with your own markup and a custom CSS box styles any of it. Every
appearance option can also be set per shortcode:

`[unideals_widget layout="banner" align="center" full_width="yes"]`

or wrap your own markup and mark the clickable element:

`[unideals_widget]<button data-tud-trigger>Students click here</button>[/unideals_widget]`

**What it never does**

It never guesses a discount. If the confirmed discount cannot be turned
into a coupon with confidence, no coupon is created. The shopper is told
plainly what happened and asked to paste the code into the coupon field,
where the widget has already put it.

**What it stores**

The only thing this plugin saves is your settings, which is your partner
key and your display preferences, plus the ordinary WooCommerce coupons
it creates. It stores nothing about students.

**External services**

This plugin relies on The Uni Deals, which is a third party service.

* The widget script is loaded in the shopper's browser from
  `https://theunideals.com/sdk/v1.js` on any page where the widget is
  shown. It renders the verification button and runs the verification
  popup.
* Your server sends the discount code and your public partner key to
  `https://api.theunideals.com` to confirm that the code was genuinely
  issued and to read the discount it carries. This request happens only
  when a shopper submits a code.
* When an order that used a student code is paid, marked processing, or
  marked completed, your server sends the order ID, the code, its subtotal
  and its currency to `https://api.theunideals.com` so commission is
  calculated from the real order value. This is on by default and can be
  turned off from **WooCommerce > The Uni Deals**. Nothing about the
  customer is sent. If you have set a partner secret, the request is signed
  with an `X-TUD-Signature` header so only your store can report your
  orders; without one, orders are still recorded but do not count toward
  commission.

Terms of service: https://theunideals.com/terms
Privacy policy: https://theunideals.com/privacy

You need a partner key to use this plugin. Email hello@theunideals.com to
get one for your store.

== Installation ==

1. Upload the plugin through **Plugins > Add New > Upload Plugin**, or
   install it from the WordPress plugin directory.
2. Activate it. WooCommerce must be installed and active.
3. Go to **WooCommerce > The Uni Deals**.
4. Paste your partner key.
5. Leave **Auto-inject widget** on to show the widget on the cart and
   checkout pages, or turn it off and place `[unideals_widget]` yourself.
6. Save. That is the whole setup.

== Frequently Asked Questions ==

= Do I need a partner key? =

Yes. The widget will not render without one, and the plugin will not
confirm any codes. Email hello@theunideals.com to get a key for your
store.

= Does it work with the new block cart and checkout? =

Yes. The widget is injected above the WooCommerce cart and checkout
blocks, and it also hooks the classic shortcode templates, so either
setup works.

= Can a shopper fake a code? =

No. Confirmation happens server to server between your site and The Uni
Deals. Nothing the shopper's browser sends is trusted on its own.

= What happens if The Uni Deals is unreachable? =

Nothing is applied and no coupon is created. The shopper sees an honest
message asking them to paste the code into the coupon field manually. The
widget has already filled that field as a fallback.

= What coupons does it create? =

One coupon per confirmed code, named exactly after the code, limited to
one use overall and one use per customer, expiring after two days, with
the discount type and amount that The Uni Deals confirmed.

= Does it collect any student data? =

No. Verification happens inside The Uni Deals. Your store only ever sees
a discount code and the discount it carries.

= Where do I put the widget if I do not want it on the cart? =

Turn off auto-inject and place the `[unideals_widget]` shortcode on any
page or template you like.

= Can I change how the widget looks? =

Yes. The settings screen has a live preview and controls for layout
(button or banner), button style, label, alignment, width, banner colors
and the powered-by line. For full control, the custom HTML slot replaces
the widget with your own markup (mark the clickable element with
`data-tud-trigger`) and the custom CSS box styles anything. The same
options work as shortcode attributes.

== Screenshots ==

1. The verification widget on the WooCommerce cart page, above the cart.
2. The cart after a verified code, with the coupon applied and the
   discount in the totals.

== Changelog ==

= 1.1.0 =
* Reports orders that used a student code so commission is based on real
  order value. Optional, on by default.

= 1.0.0 =
* First release.
* Widget embed on the block cart and checkout, the classic cart and
  checkout, and anywhere via the `[unideals_widget]` shortcode.
* Server side code confirmation against The Uni Deals before any coupon
  is created.
* Single use coupon creation and automatic application to the cart.
* Settings screen under WooCommerce with a live preview: layout, button
  styles, alignment, banner colors, custom HTML and custom CSS.

== Upgrade Notice ==

= 1.0.0 =
First release.
