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}
-
+
{.if @useCustom && @customButton}{@customButton|htmltag}{.or}{.if @isSubscribable}{.if @subscribeText}{@subscribeText|htmltag}{.or}Subscribe{.end}{.or}{.if @addToCartText}{@addToCartText|htmltag}{.or}Add To Cart{.end}{.end}{.end}
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 +
+
+
SUBSCRIBE
+
+
+ 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 +
+
+
SUBSCRIBE
+
+
+ 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 +
+
+
Add To Cart
+
+
+ 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 @@ + + +
Add To Cart