Skip to content

Commit bebe488

Browse files
committed
Scaffold WebToffee Smart Coupons extension
0 parents  commit bebe488

15 files changed

Lines changed: 5885 additions & 0 deletions

.github/workflows/release.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: false
11+
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
22+
with:
23+
fetch-depth: 0
24+
persist-credentials: false
25+
26+
- name: Set up PHP
27+
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2
28+
with:
29+
php-version: '8.2'
30+
tools: composer
31+
32+
- name: Check if version has changed
33+
id: check_version
34+
run: |
35+
VERSION=$(grep -oP "Version:\s*\K\d+(\.\d+)*" wcpos-webtoffee-smart-coupons.php | head -n 1)
36+
if [ -z "$VERSION" ]; then
37+
echo "Could not find plugin version in wcpos-webtoffee-smart-coupons.php"
38+
exit 1
39+
fi
40+
41+
git fetch --tags --force
42+
43+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
44+
45+
if git tag --list "v$VERSION" | grep -q .; then
46+
echo "Version has not changed. Skipping release..."
47+
echo "release=false" >> "$GITHUB_OUTPUT"
48+
else
49+
echo "Version has changed. Creating new release..."
50+
echo "release=true" >> "$GITHUB_OUTPUT"
51+
fi
52+
53+
- name: Install composer dependencies
54+
if: steps.check_version.outputs.release == 'true'
55+
run: composer install --no-dev --optimize-autoloader
56+
57+
- name: Build ZIP
58+
if: steps.check_version.outputs.release == 'true'
59+
run: |
60+
rm -rf dist wcpos-webtoffee-smart-coupons.zip
61+
mkdir -p dist/wcpos-webtoffee-smart-coupons
62+
63+
rsync -a ./ dist/wcpos-webtoffee-smart-coupons/ \
64+
--exclude '.git*' \
65+
--exclude '.github/' \
66+
--exclude 'node_modules/' \
67+
--exclude 'tests/' \
68+
--exclude 'vendor/' \
69+
--exclude '.wp-env.json' \
70+
--exclude '.wp-env.override.json' \
71+
--exclude 'phpunit.xml.dist' \
72+
--exclude '.phpunit.result.cache' \
73+
--exclude 'composer.json' \
74+
--exclude 'composer.lock' \
75+
--exclude 'package.json' \
76+
--exclude 'pnpm-lock.yaml' \
77+
--exclude 'pnpm-workspace.yaml' \
78+
--exclude 'dist/'
79+
80+
cd dist
81+
zip -r ../wcpos-webtoffee-smart-coupons.zip wcpos-webtoffee-smart-coupons
82+
83+
- name: Create release and upload ZIP
84+
if: steps.check_version.outputs.release == 'true'
85+
run: |
86+
gh release create "v${{ steps.check_version.outputs.version }}" \
87+
wcpos-webtoffee-smart-coupons.zip \
88+
--title "Release v${{ steps.check_version.outputs.version }}" \
89+
--notes "Automated release for version ${{ steps.check_version.outputs.version }}"
90+
env:
91+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/vendor/
2+
/node_modules/
3+
.phpunit.result.cache
4+
/.wp-env.override.json
5+
/.worktrees/
6+
.DS_Store

.wp-env.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"core": null,
3+
"plugins": [
4+
"https://downloads.wordpress.org/plugin/woocommerce.zip",
5+
"../woocommerce-pos",
6+
"../woocommerce-pos-pro",
7+
"."
8+
],
9+
"config": {
10+
"WP_DEBUG": true,
11+
"SCRIPT_DEBUG": true,
12+
"WP_PHP_BINARY": "php"
13+
}
14+
}

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# WCPOS WebToffee Smart Coupons
2+
3+
WebToffee Smart Coupons compatibility extension for WCPOS.
4+
5+
## Scope
6+
7+
This extension targets **Smart Coupons for WooCommerce Coupons by WebToffee** only. It intentionally uses the `wcpos-webtoffee-smart-coupons` slug because other plugins also use “Smart Coupons” naming.
8+
9+
Current compatibility layer:
10+
11+
- scaffolds the WCPOS extension repository and release/test structure using the existing smart-coupons extension pattern;
12+
- detects WebToffee Smart Coupons premium store-credit support before registering integration behavior;
13+
- remains inert for sites without WebToffee Smart Coupons, sites with only the free/basic plugin, and sites where the `store_credit` coupon type is not registered;
14+
- documents the premium-source verification still required before implementing production balance mutation, restoration, or receipt label enrichment.
15+
16+
Production store-credit balance handling is intentionally blocked until WebToffee premium source or a local premium installation verifies the exact hooks, metadata, lookup-table semantics, and REST/HPOS behavior.
17+
18+
## Premium verification required
19+
20+
Before implementing balance mutation, confirm and document:
21+
22+
- where WebToffee premium registers the `store_credit` coupon discount type;
23+
- which class/function deducts store-credit balance after checkout or order creation;
24+
- which metadata stores current and original balance;
25+
- whether coupon amount represents current remaining balance;
26+
- how `wt_sc_coupon_lookup.amount` is updated;
27+
- whether REST-created WCPOS orders trigger native WebToffee deduction and restoration hooks;
28+
- whether wallet coupons (`is_wt_gc_wallet_coupon`) differ from gift/store-credit coupons.
29+
30+
Record findings in `docs/webtoffee-premium-verification.md` before enabling production behavior.
31+
32+
## Development
33+
34+
```bash
35+
composer install
36+
pnpm install
37+
pnpm exec wp-env start
38+
pnpm test
39+
```
40+
41+
PHP/WordPress tests should run through Docker/wp-env.

composer.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "wcpos/wcpos-webtoffee-smart-coupons",
3+
"description": "WebToffee Smart Coupons compatibility for WCPOS",
4+
"type": "wordpress-plugin",
5+
"license": "GPL-3.0+",
6+
"require": {
7+
"php": ">=7.4"
8+
},
9+
"require-dev": {
10+
"wp-phpunit/wp-phpunit": "6.9.4",
11+
"yoast/phpunit-polyfills": "4.0.0",
12+
"squizlabs/php_codesniffer": "^3.13",
13+
"wp-coding-standards/wpcs": "^3.3"
14+
},
15+
"scripts": {
16+
"lint": "phpcs --standard=WordPress-Extra wcpos-webtoffee-smart-coupons.php includes tests",
17+
"test": "vendor/bin/phpunit -c phpunit.xml.dist"
18+
},
19+
"config": {
20+
"platform": {
21+
"php": "7.4"
22+
},
23+
"platform-check": false,
24+
"allow-plugins": {
25+
"dealerdirect/phpcodesniffer-composer-installer": true
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)