@@ -105,95 +105,6 @@ export class CartCardComponent implements OnInit {
105105 }
106106 }
107107
108- /*async addProductToCart(productOff:Product| undefined,options:boolean){
109- //this.localStorage.addCartItem(productOff as Product);
110- if(options==true){
111- console.log('termschecked:')
112- console.log(this.selected_terms)
113- if(productOff!= undefined && productOff?.productOfferingPrice != undefined){
114- let prodOptions = {
115- "id": productOff?.id,
116- "name": productOff?.name,
117- "image": this.getProductImage(),
118- "href": productOff.href,
119- "options": {
120- "characteristics": this.selected_chars,
121- "pricing": this.selected_price
122- },
123- "termsAccepted": this.selected_terms
124- }
125- this.lastAddedProd=prodOptions;
126- await this.cartService.addItemShoppingCart(prodOptions).subscribe({
127- next: data => {
128- console.log(data)
129- console.log('Update successful');
130- },
131- error: error => {
132- console.error('There was an error while updating!', error);
133- if(error.error.error){
134- console.log(error)
135- this.errorMessage='Error: '+error.error.error;
136- } else {
137- this.errorMessage='There was an error while adding item to the cart!';
138- }
139- this.showError=true;
140- setTimeout(() => {
141- this.showError = false;
142- }, 3000);
143- }
144- });
145- }
146- } else {
147- if(productOff!= undefined && productOff?.productOfferingPrice != undefined){
148- let prodOptions = {
149- "id": productOff?.id,
150- "name": productOff?.name,
151- "image": this.getProductImage(),
152- "href": productOff.href,
153- "options": {
154- "characteristics": this.selected_chars,
155- "pricing": this.selected_price
156- },
157- "termsAccepted": true
158- }
159- this.lastAddedProd=prodOptions;
160- await this.cartService.addItemShoppingCart(prodOptions).subscribe({
161- next: data => {
162- console.log(data)
163- console.log('Update successful');
164- },
165- error: error => {
166- console.error('There was an error while updating!', error);
167- if(error.error.error){
168- console.log(error)
169- this.errorMessage='Error: '+error.error.error;
170- } else {
171- this.errorMessage='There was an error while adding item to the cart!';
172- }
173- this.showError=true;
174- setTimeout(() => {
175- this.showError = false;
176- }, 3000);
177- }
178- });
179- }
180- }
181- if(productOff!== undefined){
182- this.eventMessage.emitAddedCartItem(productOff as cartProduct);
183- this.eventMessage.emitCloseCartCard(productOff as cartProduct);
184- this.check_char=false;
185- this.check_terms=false;
186- this.check_prices=false;
187- this.selected_chars=[];
188- this.selected_price={};
189- this.selected_terms=false;
190- this.cdr.detectChanges();
191- }
192-
193- this.cdr.detectChanges();
194- }
195- */
196-
197108 async addProductToCart ( productOff : Product | undefined , options : boolean ) {
198109 if ( ! productOff || ! productOff . productOfferingPrice ) return ;
199110
@@ -399,7 +310,7 @@ export class CartCardComponent implements OnInit {
399310 return str . split ( / \s + / ) . some ( word => word . length > threshold ) ;
400311 } else {
401312 return false
402- }
313+ }
403314 }
404315
405316}
0 commit comments