@@ -53,42 +53,55 @@ export class UccCartModalElement extends UccModalElement
53
53
const config = this . _context . config . get ( ) ! ;
54
54
55
55
if ( cart && cart . items . length > 0 ) {
56
- this . _host . querySelector ( '.ucc-cart-items' ) ! . innerHTML = cart . items . map ( ( item ) => `
57
- <div class="ucc-cart-item" data-id="${ item . id } ">
58
- ${ item . imageUrl ? `
59
- <figure class="ucc-cart-item__image">
60
- <img src="${ item . imageUrl } " alt="${ item . name } ">
61
- </figure>` : '' }
62
- <div class="ucc-cart-item__body">
63
- <div class="ucc-cart-item__content ucc-split">
64
- <div class="ucc-split__left">
65
- <h3 class="ucc-cart-item__title">${ item . name } </h3>
66
- ${ item . attributes ? `
67
- <div class="ucc-cart-item__attributes">
68
- ${ Object . keys ( item . attributes ) . map ( ( key ) => `
69
- <div class="ucc-cart-item__attribute">
70
- <span class="ucc-cart-item__attribute-key">${ key } </span>
71
- <span class="ucc-cart-item__attribute-value">${ item . attributes ! [ key ] } </span>
72
- </div>
73
- ` ) . join ( '' ) }
74
- </div>
75
- ` : '' }
56
+ this . _host . querySelector ( '.ucc-cart-items' ) ! . innerHTML = cart . items . map ( ( item ) => {
57
+ const propsToDisplay = Object . keys ( item . properties ?? { } ) . filter ( ( x ) => ( config . properties ?? [ ] ) . map ( y => y . toLowerCase ( ) ) . includes ( x . toLowerCase ( ) ) ) ;
58
+ return `
59
+ <div class="ucc-cart-item" data-id="${ item . id } ">
60
+ ${ item . imageUrl ? `
61
+ <figure class="ucc-cart-item__image">
62
+ <img src="${ item . imageUrl } " alt="${ item . name } ">
63
+ </figure>` : '' }
64
+ <div class="ucc-cart-item__body">
65
+ <div class="ucc-cart-item__content ucc-split">
66
+ <div class="ucc-split__left">
67
+ <h3 class="ucc-cart-item__title">${ item . name } </h3>
68
+ ${ item . attributes ? `
69
+ <div class="ucc-cart-item__attributes">
70
+ ${ Object . keys ( item . attributes ) . map ( ( key ) => `
71
+ <div class="ucc-cart-item__attribute">
72
+ <span class="ucc-cart-item__attribute-key">${ key } </span>
73
+ <span class="ucc-cart-item__attribute-value">${ item . attributes ! [ key ] } </span>
74
+ </div>
75
+ ` ) . join ( '' ) }
76
+ </div>
77
+ ` : '' }
78
+ ${ propsToDisplay . length > 0 ? `
79
+ <div class="ucc-cart-item__properties">
80
+ ${ propsToDisplay . map ( ( key ) => `
81
+ <div class="ucc-cart-item__property">
82
+ <span class="ucc-cart-item__property-key">${ config ?. locales ! [ config . lang ] [ `property_${ key . toLowerCase ( ) } ` ] ?? key } </span>
83
+ <span class="ucc-cart-item__property-value">${ item . properties ! [ key ] } </span>
84
+ </div>
85
+ ` ) . join ( '' ) }
86
+ </div>
87
+ ` : '' }
88
+ </div>
89
+ <div class="ucc-split__right">
90
+ <button class="ucc-cart-item__remove" title="${ config ?. locales ! [ config . lang ] . remove ?? 'Remove' } "><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-trash-2"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/><line x1="10" x2="10" y1="11" y2="17"/><line x1="14" x2="14" y1="11" y2="17"/></svg></button>
91
+ </div>
76
92
</div>
77
- <div class="ucc-split__right">
78
- <button class="ucc-cart-item__remove" title="${ config ?. locales ! [ config . lang ] . remove ?? 'Remove' } "><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-trash-2"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/><line x1="10" x2="10" y1="11" y2="17"/><line x1="14" x2="14" y1="11" y2="17"/></svg></button>
79
- </div>
80
- </div>
81
- <div class="ucc-cart-item__foot ucc-split ucc-split--center">
82
- <div class="ucc-split__left">
83
- <input type="number" value="${ item . quantity } " min="1" class="ucc-cart-item__quantity">
84
- </div>
85
- <div class="ucc-split__right">
86
- <span class="ucc-cart-item__price">${ item . total . withTax } </span>
93
+ <div class="ucc-cart-item__foot ucc-split ucc-split--center">
94
+ <div class="ucc-split__left">
95
+ <input type="number" value="${ item . quantity } " min="1" class="ucc-cart-item__quantity">
96
+ </div>
97
+ <div class="ucc-split__right">
98
+ <span class="ucc-cart-item__price">${ item . total . withTax } </span>
99
+ </div>
87
100
</div>
88
101
</div>
89
102
</div>
90
- </div>
91
- ` ) . join ( '' ) ;
103
+ `
104
+ } ) . join ( '' ) ;
92
105
this . _host . querySelector < HTMLElement > ( '.ucc-cart-totals' ) ! . style . display = '' ;
93
106
this . _host . querySelector < HTMLElement > ( '.ucc-cart-total--taxes .ucc-cart-total-value' ) ! . textContent = cart . subtotal . tax ;
94
107
this . _host . querySelector < HTMLElement > ( '.ucc-cart-total--total .ucc-cart-total-value' ) ! . textContent = cart . subtotal . withTax ;
0 commit comments