From d1d9b52c33f385796596078b0ba4d33476e0872d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Raiti?= <46955459+Secreto31126@users.noreply.github.com> Date: Mon, 21 Oct 2024 20:27:10 -0300 Subject: [PATCH 1/4] Added Product Carousel support Super easy :smile: --- src/messages/template.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/messages/template.ts b/src/messages/template.ts index f1d5c13c..4c947af9 100644 --- a/src/messages/template.ts +++ b/src/messages/template.ts @@ -910,7 +910,7 @@ export class CarouselCard implements ClientBuildableMessageComponent { * @param components - The other components for the card */ constructor( - header: Image | Video, + header: Image | Video | CatalogProduct, ...components: (BodyComponent | ButtonComponent)[] ) { const tmp = new Template( From eaf93a36bc7b120afa718d214ab4db03cf620858 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Raiti?= <46955459+Secreto31126@users.noreply.github.com> Date: Mon, 21 Oct 2024 20:27:34 -0300 Subject: [PATCH 2/4] Updated examples --- EXAMPLES/template.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/EXAMPLES/template.md b/EXAMPLES/template.md index 5716bf8c..d53d7490 100644 --- a/EXAMPLES/template.md +++ b/EXAMPLES/template.md @@ -217,6 +217,34 @@ const template_carousel_message = new Template( ); ``` +## Complex template with Product Carousel + +```ts +import { + Template, + BodyComponent, + CarouselComponent, + CarouselCard, + CatalogProduct +} from "whatsapp-api-js/messages"; + +const template_product_carousel_message = new Template( + "template_name", + "en", + new BodyComponent(new BodyParameter("PROMO10")), + new CarouselComponent( + new CarouselCard( + new CatalogProduct("product_id_1", "catalog_id"), + new URLComponent("?code=PROMO10&product=1") + ), + new CarouselCard( + new CatalogProduct("product_id_2", "catalog_id"), + new URLComponent("?code=PROMO10&product=2") + ) + ) +); +``` + ## Complex template with Limited-Time Offer ```ts From 0337b9dd77056df05b59acfbe4d0b6ab36bcfcea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Raiti?= <46955459+Secreto31126@users.noreply.github.com> Date: Mon, 21 Oct 2024 20:29:15 -0300 Subject: [PATCH 3/4] Small example change --- EXAMPLES/template.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EXAMPLES/template.md b/EXAMPLES/template.md index d53d7490..dd7eb42c 100644 --- a/EXAMPLES/template.md +++ b/EXAMPLES/template.md @@ -206,11 +206,11 @@ const template_carousel_message = new Template( new BodyComponent(new BodyParameter("PROMO10")), new CarouselComponent( new CarouselCard( - new Image(image), + new Image("image_url"), new URLComponent("?code=PROMO10&product=1") ), new CarouselCard( - new Image(image), + new Image("image_url"), new URLComponent("?code=PROMO10&product=2") ) ) From dce26e6bc373fc6c1dbe9a1ebc025012da01965d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Raiti?= <46955459+Secreto31126@users.noreply.github.com> Date: Mon, 21 Oct 2024 20:33:52 -0300 Subject: [PATCH 4/4] Almost forgot you --- EXAMPLES/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/EXAMPLES/README.md b/EXAMPLES/README.md index 0d13bc52..cf649359 100644 --- a/EXAMPLES/README.md +++ b/EXAMPLES/README.md @@ -53,5 +53,6 @@ the most basic methods or features. - [Complex template with Single-Product Message](template.md#complex-template-with-single-product-message) - [Complex template with Multi-Product Message](template.md#complex-template-with-multi-product-message) - [Complex template with Carousel](template.md#complex-template-with-carousel) + - [Complex template with Product Carousel](template.md#complex-template-with-product-carousel) - [Complex template with Limited-Time Offer](template.md#complex-template-with-limited-time-offer) - [OTP prefab template](template.md#otp-prefab-template)