Skip to content

Commit dba8b63

Browse files
committed
Add 10-year anniversary sale with config-driven sale price toggle
1 parent 351c597 commit dba8b63

15 files changed

Lines changed: 114 additions & 62 deletions

File tree

assets/js/androidkey.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,20 @@ class AndroidLicense {
4141
}).catch(() => {
4242
this._checkoutData.errorMessage = 'Retrieving price failed. Please try again later.';
4343
});
44-
// let discountedRequest = {
45-
// items: [{ priceId: PADDLE_ANDROID_PRICE_ID, quantity: 1}],
46-
// discountId: PADDLE_DISCOUNT_ID
47-
// };
48-
// paddle.PricePreview(discountedRequest).then(discountedResult => {
49-
// if (Number(discountedResult.data.details.lineItems[0].totals.discount) > 0) {
50-
// this._checkoutData.discountedPrice = {
51-
// amount: discountedResult.data.details.lineItems[0].totals.total,
52-
// formattedAmount: discountedResult.data.details.lineItems[0].formattedTotals.total
53-
// };
54-
// }
55-
// }).catch(error => {
56-
// this._checkoutData.errorMessage = 'Retrieving discounted price failed. Please try again later.';
57-
// });
44+
if (PADDLE_ANDROID_SALE_PRICE_ID) {
45+
let saleRequest = {
46+
items: [{ priceId: PADDLE_ANDROID_SALE_PRICE_ID, quantity: 1 }]
47+
};
48+
paddle.PricePreview(saleRequest).then(saleResult => {
49+
this._checkoutData.discountedPrice = {
50+
priceId: PADDLE_ANDROID_SALE_PRICE_ID,
51+
amount: saleResult.data.details.lineItems[0].totals.total,
52+
formattedAmount: saleResult.data.details.lineItems[0].formattedTotals.total
53+
};
54+
}).catch(() => {
55+
// sale price not available, proceed with regular price
56+
});
57+
}
5858
});
5959
}
6060

@@ -73,10 +73,11 @@ class AndroidLicense {
7373
this._checkoutData.inProgress = true;
7474
this._checkoutData.errorMessage = '';
7575
this._checkoutData.success = false;
76+
let checkoutPriceId = this._checkoutData.discountedPrice ? this._checkoutData.discountedPrice.priceId : PADDLE_ANDROID_PRICE_ID;
7677
this._paddle.then(paddle => {
7778
paddle.Checkout.open({
7879
settings: { locale: locale },
79-
items: [{ priceId: PADDLE_ANDROID_PRICE_ID, quantity: 1 }],
80+
items: [{ priceId: checkoutPriceId, quantity: 1 }],
8081
customer: { email: this._checkoutData.email }
8182
});
8283
});

assets/js/const.template.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const PADDLE_HUB_SELF_HOSTED_MONTHLY_PLAN_ID = {{ .Site.Params.paddleHubSelfHost
1111
const PADDLE_HUB_MANAGED_YEARLY_PLAN_ID = {{ .Site.Params.paddleHubManagedYearlyPlanId }};
1212
const PADDLE_HUB_MANAGED_MONTHLY_PLAN_ID = {{ .Site.Params.paddleHubManagedMonthlyPlanId }};
1313
const PADDLE_PRICES_URL = '{{ .Site.Params.paddlePricesUrl }}';
14-
const PADDLE_DISCOUNT_ID = '{{ .Site.Params.paddleDiscountId }}';
15-
const PADDLE_DISCOUNT_CODE = '{{ .Site.Params.paddleDiscountCode }}';
14+
const PADDLE_DESKTOP_SALE_PRICE_ID = '{{ .Site.Params.paddleDesktopSalePriceId }}';
15+
const PADDLE_ANDROID_SALE_PRICE_ID = '{{ .Site.Params.paddleAndroidSalePriceId }}';
1616
const LEGACY_STORE_URL = '{{ .Site.Params.legacyStoreUrl }}';
1717
const STRIPE_PK = '{{ .Site.Params.stripePk }}';

assets/js/desktopkey.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,20 @@ class DesktopLicense {
4444
}).catch(() => {
4545
this._checkoutData.errorMessage = 'Retrieving prices failed. Please try again later.';
4646
});
47-
// let discountedRequest = {
48-
// items: [{ priceId: PADDLE_DESKTOP_PRICE_IDS[0], quantity: 1 }],
49-
// discountId: PADDLE_DISCOUNT_ID
50-
// };
51-
// paddle.PricePreview(discountedRequest).then(discountedResult => {
52-
// if (Number(discountedResult.data.details.lineItems[0].totals.discount) > 0) {
53-
// this._checkoutData.discountedPrice = {
54-
// amount: discountedResult.data.details.lineItems[0].totals.total,
55-
// formattedAmount: discountedResult.data.details.lineItems[0].formattedTotals.total
56-
// };
57-
// }
58-
// }).catch(() => {
59-
// this._checkoutData.errorMessage = 'Retrieving discounted price failed. Please try again later.';
60-
// });
47+
if (PADDLE_DESKTOP_SALE_PRICE_ID) {
48+
let saleRequest = {
49+
items: [{ priceId: PADDLE_DESKTOP_SALE_PRICE_ID, quantity: 1 }]
50+
};
51+
paddle.PricePreview(saleRequest).then(saleResult => {
52+
this._checkoutData.discountedPrice = {
53+
priceId: PADDLE_DESKTOP_SALE_PRICE_ID,
54+
amount: saleResult.data.details.lineItems[0].totals.total,
55+
formattedAmount: saleResult.data.details.lineItems[0].formattedTotals.total
56+
};
57+
}).catch(() => {
58+
// sale price not available, proceed with regular price
59+
});
60+
}
6161
});
6262
}
6363

@@ -76,10 +76,11 @@ class DesktopLicense {
7676
this._checkoutData.inProgress = true;
7777
this._checkoutData.errorMessage = '';
7878
this._checkoutData.success = false;
79+
let checkoutPriceId = (priceId === PADDLE_DESKTOP_PRICE_IDS[0] && this._checkoutData.discountedPrice) ? this._checkoutData.discountedPrice.priceId : priceId;
7980
this._paddle.then(paddle => {
8081
paddle.Checkout.open({
8182
settings: { locale: locale },
82-
items: [{ priceId: priceId, quantity: Number.parseInt(this._checkoutData.quantity) }],
83+
items: [{ priceId: checkoutPriceId, quantity: Number.parseInt(this._checkoutData.quantity) }],
8384
customer: { email: this._checkoutData.email }
8485
});
8586
});

config/development/params.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ paddleHubSelfHostedMonthlyPlanId: 82378
1919
paddleHubManagedYearlyPlanId: 42235
2020
paddleHubManagedMonthlyPlanId: 82379
2121
paddlePricesUrl: https://sandbox-checkout.paddle.com/api/2.0/prices
22-
paddleDiscountId: dsc_01kba2drz2yg4v6h3d5f2687tw
23-
paddleDiscountCode: WINTER2025
22+
paddleDesktopSalePriceId: pri_01kk1z8f8cb5f6fnf9x7bv4xg9
23+
paddleAndroidSalePriceId: pri_01kk243hedea8mbabs8q22ygdn
2424

2525
# STRIPE
2626
stripePk: pk_test_51RCM24IBZmkR4F9UiLBiSmsAnJvWqmHcDLxXR8ABKK1MNsZk3zCk2VJW7ZfaBlD81zpQxCX243sS3LEp9dABwiG800kJnGykDF

config/production/params.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ paddleHubSelfHostedMonthlyPlanId: 914172
1919
paddleHubManagedYearlyPlanId: 807339
2020
paddleHubManagedMonthlyPlanId: 914173
2121
paddlePricesUrl: https://checkout.paddle.com/api/2.0/prices
22-
paddleDiscountId: dsc_01kba2vjmspm92sx2jhq4s2082
23-
paddleDiscountCode: WINTER2025
22+
paddleDesktopSalePriceId: pri_01kk4gejs06jg0m0n9tghk0ktr
23+
paddleAndroidSalePriceId: pri_01kk4gg6c3pj0tq0vvpf4x4vw2
2424

2525
# STRIPE
2626
stripePk: pk_live_eSasX216vGvC26GdbVwA011V

config/staging/params.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ paddleHubSelfHostedMonthlyPlanId: 82378
1919
paddleHubManagedYearlyPlanId: 42235
2020
paddleHubManagedMonthlyPlanId: 82379
2121
paddlePricesUrl: https://sandbox-checkout.paddle.com/api/2.0/prices
22-
paddleDiscountId: dsc_01kba2drz2yg4v6h3d5f2687tw
23-
paddleDiscountCode: WINTER2025
22+
paddleDesktopSalePriceId: pri_01kk1z8f8cb5f6fnf9x7bv4xg9
23+
paddleAndroidSalePriceId: pri_01kk243hedea8mbabs8q22ygdn
2424

2525
# STRIPE
2626
stripePk: pk_test_51RCM24IBZmkR4F9UiLBiSmsAnJvWqmHcDLxXR8ABKK1MNsZk3zCk2VJW7ZfaBlD81zpQxCX243sS3LEp9dABwiG800kJnGykDF

content/downloads/android.de.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ <h3 class="font-h3 text-lg">Google Play</h3>
2222
<a href="https://play.google.com/store/apps/details?id=org.cryptomator&hl=de" role="button" data-umami-event="downloads-android-googleplay">
2323
<img class="h-10 mx-auto lazyload" data-src="/de/img/downloads/googleplay-badge.png">
2424
</a>
25+
<p class="text-sm md:text-base leading-relaxed text-gray-700 rounded bg-primary-l2 p-2 mt-4">🎂 Jubiläums-Sale: Einmalpreis reduziert!</p>
2526
</div>
2627
</div>
28+
<p class="prose prose-sm max-w-none">*Hinweis: Die Höhe des Rabatts kann je nach Region variieren.</p>
2729

2830
<div class="white-box my-4">
2931
<div class="px-4 py-2 border-b border-primary">

content/downloads/android.en.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ <h3 class="font-h3 text-lg">Google Play</h3>
2424
<a href="https://play.google.com/store/apps/details?id=org.cryptomator&hl=en" role="button" data-umami-event="downloads-android-googleplay">
2525
<img class="h-10 mx-auto lazyload" data-src="/img/downloads/googleplay-badge.png">
2626
</a>
27+
<p class="text-sm md:text-base leading-relaxed text-gray-700 rounded bg-primary-l2 p-2 mt-4">🎂 Anniversary Sale: One-time price reduced!</p>
2728
</div>
2829
</div>
30+
<p class="prose prose-sm max-w-none">*Note: The discount amount may vary by region.</p>
2931

3032
<div class="white-box my-4">
3133
<div class="px-4 py-2 border-b border-primary">

content/downloads/ios.de.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ <h3 class="font-h3 text-lg">App Store</h3>
2323
<img class="h-10 mx-auto mb-4 lazyload" data-src="/de/img/downloads/appstore-badge.svg">
2424
</a>
2525
<p class="font-p text-sm">Eine Vollversion ohne In-App-Käufe für Apple School/Business Manager ist <a class="text-link" href="https://apps.apple.com/de/app/cryptomator-full-version/id1665616242">im App Store</a> erhältlich.</p>
26+
<p class="text-sm md:text-base leading-relaxed text-gray-700 rounded bg-primary-l2 p-2 mt-4">🎂 Jubiläums-Sale: Lebenslange Lizenz reduziert!</p>
2627
</div>
2728
</div>
29+
<p class="prose prose-sm max-w-none">*Hinweis: Die Höhe des Rabatts kann je nach Region variieren.</p>
2830
</div>

content/downloads/ios.en.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ <h3 class="font-h3 text-lg">App Store</h3>
2323
<img class="h-10 mx-auto mb-4 lazyload" data-src="/img/downloads/appstore-badge.svg">
2424
</a>
2525
<p class="font-p text-sm">A full version without in-app purchases for Apple School/Business Manager is available <a class="text-link" href="https://apps.apple.com/us/app/cryptomator-full-version/id1665616242">on the App Store</a>.</p>
26+
<p class="text-sm md:text-base leading-relaxed text-gray-700 rounded bg-primary-l2 p-2 mt-4">🎂 Anniversary Sale: Lifetime license reduced!</p>
2627
</div>
2728
</div>
29+
<p class="prose prose-sm max-w-none">*Note: The discount amount may vary by region.</p>
2830
</div>

0 commit comments

Comments
 (0)