From 5acef3b4cfac8e01b3a3b74cb43787762f655055 Mon Sep 17 00:00:00 2001
From: Sisheng Zhang <88727960+sizhang12@users.noreply.github.com>
Date: Thu, 4 Apr 2024 15:51:38 -0400
Subject: [PATCH] [COM-33946]: Data subscription option id attribute (#55)
* add data subscription option id attribute to Subscribe button
* add data-subscription-option-id attribute
---
.../plugins/platform/add-to-cart-btn.html | 5 ++-
.../platform/f-add-to-cart-btn-10.html | 27 +++++++++++++
.../plugins/platform/f-add-to-cart-btn-8.html | 38 +++++++++++++++++++
.../plugins/platform/f-add-to-cart-btn-9.html | 35 +++++++++++++++++
.../platform/f-product-checkout-1.html | 3 ++
5 files changed, 107 insertions(+), 1 deletion(-)
create mode 100644 core/src/test/resources/com/squarespace/template/plugins/platform/f-add-to-cart-btn-10.html
create mode 100644 core/src/test/resources/com/squarespace/template/plugins/platform/f-add-to-cart-btn-8.html
create mode 100644 core/src/test/resources/com/squarespace/template/plugins/platform/f-add-to-cart-btn-9.html
diff --git a/core/src/main/resources/com/squarespace/template/plugins/platform/add-to-cart-btn.html b/core/src/main/resources/com/squarespace/template/plugins/platform/add-to-cart-btn.html
index 05771273..de01fb77 100644
--- a/core/src/main/resources/com/squarespace/template/plugins/platform/add-to-cart-btn.html
+++ b/core/src/main/resources/com/squarespace/template/plugins/platform/add-to-cart-btn.html
@@ -7,9 +7,12 @@
{.var @addToCartText localizedStrings.productAddToCartText}
{.var @subscribeText localizedStrings.productSubscribeText}
{.var @isSubscribable @content.isSubscribable}
+{.var @productSubscriptionOptions structuredContent.productSubscriptionOptions}
+{.var @subsOTPOptionsCount structuredContent.productSubscriptionOptions|count}
+{.eval @hasProductSubsOptionAndIsSubscribable = @subsOTPOptionsCount && @isSubscribable}
-
diff --git a/core/src/test/resources/com/squarespace/template/plugins/platform/f-add-to-cart-btn-10.html b/core/src/test/resources/com/squarespace/template/plugins/platform/f-add-to-cart-btn-10.html
new file mode 100644
index 00000000..ce375a31
--- /dev/null
+++ b/core/src/test/resources/com/squarespace/template/plugins/platform/f-add-to-cart-btn-10.html
@@ -0,0 +1,27 @@
+:JSON
+{
+ "item": {
+ "id": "560c37c1a7c8465c4a71d99a",
+ "collectionId": "560c37c1a7c8465c4a71d99b",
+ "structuredContent": {
+ "productType": "2",
+ "useCustomAddButtonText": false,
+ "isSubscribable": true,
+ "productSubscriptionOptions" : []
+ }
+ },
+ "localizedStrings": {
+ "productSubscribeText": "SUBSCRIBE"
+ }
+}
+
+:TEMPLATE
+{item|add-to-cart-btn}
+
+:OUTPUT
+
+
diff --git a/core/src/test/resources/com/squarespace/template/plugins/platform/f-add-to-cart-btn-8.html b/core/src/test/resources/com/squarespace/template/plugins/platform/f-add-to-cart-btn-8.html
new file mode 100644
index 00000000..09b15b27
--- /dev/null
+++ b/core/src/test/resources/com/squarespace/template/plugins/platform/f-add-to-cart-btn-8.html
@@ -0,0 +1,38 @@
+:JSON
+{
+ "item": {
+ "id": "560c37c1a7c8465c4a71d99a",
+ "collectionId": "560c37c1a7c8465c4a71d99b",
+ "structuredContent": {
+ "productType": "2",
+ "useCustomAddButtonText": false,
+ "isSubscribable": true,
+ "productSubscriptionOptions" : [{
+ "id" : "2e0c2fbe-bc48-4a5e-9e0f-bb939576a0aa",
+ "percentageDiscount" : 0,
+ "subscriptionPlan" : {
+ "billingPeriod" : {
+ "value" : 1,
+ "unit" : "WEEK"
+ },
+ "planVersionId" : "d6803d89-82b8-49a3-ab6d-d9a16c93b5a8",
+ "numBillingCycles" : 0
+ }
+ }]
+ }
+ },
+ "localizedStrings": {
+ "productSubscribeText": "SUBSCRIBE"
+ }
+}
+
+:TEMPLATE
+{item|add-to-cart-btn}
+
+:OUTPUT
+
+
diff --git a/core/src/test/resources/com/squarespace/template/plugins/platform/f-add-to-cart-btn-9.html b/core/src/test/resources/com/squarespace/template/plugins/platform/f-add-to-cart-btn-9.html
new file mode 100644
index 00000000..3dcb6350
--- /dev/null
+++ b/core/src/test/resources/com/squarespace/template/plugins/platform/f-add-to-cart-btn-9.html
@@ -0,0 +1,35 @@
+:JSON
+{
+ "item": {
+ "id": "560c37c1a7c8465c4a71d99a",
+ "collectionId": "560c37c1a7c8465c4a71d99b",
+ "structuredContent": {
+ "productType": "2",
+ "useCustomAddButtonText": false,
+ "isSubscribable": false,
+ "productSubscriptionOptions" : [{
+ "id" : "2e0c2fbe-bc48-4a5e-9e0f-bb939576a0aa",
+ "percentageDiscount" : 0,
+ "subscriptionPlan" : {
+ "billingPeriod" : {
+ "value" : 1,
+ "unit" : "WEEK"
+ },
+ "planVersionId" : "d6803d89-82b8-49a3-ab6d-d9a16c93b5a8",
+ "numBillingCycles" : 0
+ }
+ }]
+ }
+ }
+}
+
+:TEMPLATE
+{item|add-to-cart-btn}
+
+:OUTPUT
+
+
diff --git a/core/src/test/resources/com/squarespace/template/plugins/platform/f-product-checkout-1.html b/core/src/test/resources/com/squarespace/template/plugins/platform/f-product-checkout-1.html
index 2b3663ae..939c3a57 100644
--- a/core/src/test/resources/com/squarespace/template/plugins/platform/f-product-checkout-1.html
+++ b/core/src/test/resources/com/squarespace/template/plugins/platform/f-product-checkout-1.html
@@ -58,6 +58,9 @@
+
+
+