Skip to content

Commit 58e4d3d

Browse files
authored
Merge pull request #384 from Secreto31126/product-carousel
Product carousel support
2 parents bf78987 + dce26e6 commit 58e4d3d

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

EXAMPLES/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,6 @@ the most basic methods or features.
5353
- [Complex template with Single-Product Message](template.md#complex-template-with-single-product-message)
5454
- [Complex template with Multi-Product Message](template.md#complex-template-with-multi-product-message)
5555
- [Complex template with Carousel](template.md#complex-template-with-carousel)
56+
- [Complex template with Product Carousel](template.md#complex-template-with-product-carousel)
5657
- [Complex template with Limited-Time Offer](template.md#complex-template-with-limited-time-offer)
5758
- [OTP prefab template](template.md#otp-prefab-template)

EXAMPLES/template.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,39 @@ const template_carousel_message = new Template(
206206
new BodyComponent(new BodyParameter("PROMO10")),
207207
new CarouselComponent(
208208
new CarouselCard(
209-
new Image(image),
209+
new Image("image_url"),
210210
new URLComponent("?code=PROMO10&product=1")
211211
),
212212
new CarouselCard(
213-
new Image(image),
213+
new Image("image_url"),
214+
new URLComponent("?code=PROMO10&product=2")
215+
)
216+
)
217+
);
218+
```
219+
220+
## Complex template with Product Carousel
221+
222+
```ts
223+
import {
224+
Template,
225+
BodyComponent,
226+
CarouselComponent,
227+
CarouselCard,
228+
CatalogProduct
229+
} from "whatsapp-api-js/messages";
230+
231+
const template_product_carousel_message = new Template(
232+
"template_name",
233+
"en",
234+
new BodyComponent(new BodyParameter("PROMO10")),
235+
new CarouselComponent(
236+
new CarouselCard(
237+
new CatalogProduct("product_id_1", "catalog_id"),
238+
new URLComponent("?code=PROMO10&product=1")
239+
),
240+
new CarouselCard(
241+
new CatalogProduct("product_id_2", "catalog_id"),
214242
new URLComponent("?code=PROMO10&product=2")
215243
)
216244
)

src/messages/template.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ export class CarouselCard implements ClientBuildableMessageComponent {
910910
* @param components - The other components for the card
911911
*/
912912
constructor(
913-
header: Image | Video,
913+
header: Image | Video | CatalogProduct,
914914
...components: (BodyComponent | ButtonComponent)[]
915915
) {
916916
const tmp = new Template(

0 commit comments

Comments
 (0)