Spaces:
				
			
			
	
			
			
		Runtime error
		
	
	
	
			
			
	
	
	
	
		
		
		Runtime error
		
	Update templates/cart.html
Browse files- templates/cart.html +8 -5
 
    	
        templates/cart.html
    CHANGED
    
    | 
         @@ -179,22 +179,25 @@ 
     | 
|
| 179 | 
         
             
                        } else if (action === 'decrease' && quantity > 1) {
         
     | 
| 180 | 
         
             
                            quantity--;
         
     | 
| 181 | 
         
             
                        }
         
     | 
| 182 | 
         
            -
                         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 183 | 
         
             
                        fetch('/cart/update_quantity', {
         
     | 
| 184 | 
         
             
                            method: 'POST',
         
     | 
| 185 | 
         
             
                            headers: {
         
     | 
| 186 | 
         
             
                                'Content-Type': 'application/json',
         
     | 
| 187 | 
         
             
                            },
         
     | 
| 188 | 
         
             
                            body: JSON.stringify({
         
     | 
| 189 | 
         
            -
                                email: customerEmail, 
     | 
| 190 | 
         
            -
                                item_name: itemName, 
     | 
| 191 | 
         
            -
                                quantity: quantity 
     | 
| 192 | 
         
             
                            })
         
     | 
| 193 | 
         
             
                        })
         
     | 
| 194 | 
         
             
                        .then(response => response.json())
         
     | 
| 195 | 
         
             
                        .then(data => {
         
     | 
| 196 | 
         
             
                            if (data.success) {
         
     | 
| 197 | 
         
            -
                                // Update the quantity in the UI
         
     | 
| 198 | 
         
             
                                document.querySelector(`input[data-item-name="${itemName}"]`).value = quantity;
         
     | 
| 199 | 
         
             
                            } else {
         
     | 
| 200 | 
         
             
                                alert("Error updating quantity: " + data.error);
         
     | 
| 
         | 
|
| 179 | 
         
             
                        } else if (action === 'decrease' && quantity > 1) {
         
     | 
| 180 | 
         
             
                            quantity--;
         
     | 
| 181 | 
         
             
                        }
         
     | 
| 182 | 
         
            +
                        console.log({
         
     | 
| 183 | 
         
            +
                            email: customerEmail,
         
     | 
| 184 | 
         
            +
                            item_name: itemName,
         
     | 
| 185 | 
         
            +
                            quantity: quantity
         
     | 
| 186 | 
         
            +
                        });
         
     | 
| 187 | 
         
             
                        fetch('/cart/update_quantity', {
         
     | 
| 188 | 
         
             
                            method: 'POST',
         
     | 
| 189 | 
         
             
                            headers: {
         
     | 
| 190 | 
         
             
                                'Content-Type': 'application/json',
         
     | 
| 191 | 
         
             
                            },
         
     | 
| 192 | 
         
             
                            body: JSON.stringify({
         
     | 
| 193 | 
         
            +
                                email: customerEmail,  // Customer's email
         
     | 
| 194 | 
         
            +
                                item_name: itemName,   // Item name
         
     | 
| 195 | 
         
            +
                                quantity: quantity     // New quantity
         
     | 
| 196 | 
         
             
                            })
         
     | 
| 197 | 
         
             
                        })
         
     | 
| 198 | 
         
             
                        .then(response => response.json())
         
     | 
| 199 | 
         
             
                        .then(data => {
         
     | 
| 200 | 
         
             
                            if (data.success) {
         
     | 
| 
         | 
|
| 201 | 
         
             
                                document.querySelector(`input[data-item-name="${itemName}"]`).value = quantity;
         
     | 
| 202 | 
         
             
                            } else {
         
     | 
| 203 | 
         
             
                                alert("Error updating quantity: " + data.error);
         
     |