Skip to content

Commit

Permalink
Merge pull request #384 from Secreto31126/product-carousel
Browse files Browse the repository at this point in the history
Product carousel support
  • Loading branch information
Secreto31126 authored Oct 21, 2024
2 parents bf78987 + dce26e6 commit 58e4d3d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
1 change: 1 addition & 0 deletions EXAMPLES/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
32 changes: 30 additions & 2 deletions EXAMPLES/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,39 @@ 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")
)
)
);
```

## 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")
)
)
Expand Down
2 changes: 1 addition & 1 deletion src/messages/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 58e4d3d

Please sign in to comment.