delivery cost

This commit is contained in:
Martin Quarda 2024-10-14 14:50:31 +02:00
parent 8d8539ed46
commit b2d3c7c658
2 changed files with 9 additions and 5 deletions

View File

@ -397,14 +397,14 @@ def cart_buy(request):
invoice = Invoice(
user=user,
address=cart.address if cart.adress else user.profile.address,
address=cart.address,
invoice_id=Invoice.next_invoice_id(),
total_price=0,
)
total_price = 0
invoice.save()
for cp in cart_products:
for cp in cart_products + [Product.objects.get(id=2)]:
ip = InvoiceProduct(
invoice=invoice,
price=cp.product.price,

View File

@ -10,6 +10,7 @@ import axios from 'axios';
const addr_prefix = "" //"http://localhost:8000"
const delivery_cost = 79
class Main extends Component {
@ -32,6 +33,7 @@ class Main extends Component {
uploadProgress: 0.0,
login_status: {},
cart: [],
delivery: undefined,
};
fetch(addr_prefix + "/api/results").then(resp => resp.json()).then(json => {
this.setState({results: json})
@ -203,6 +205,8 @@ class Main extends Component {
})
}else{
this.setState({
cart: [...this.state.cart, {"name": "Doprava na " + point.name, "id": 2, "price": delivery_cost, "locked": true}],
delivery: point.name,
status_text: json.reason,
status: "success",
})
@ -344,12 +348,12 @@ class Main extends Component {
<tr>
<td>{product.name}</td>
<td>
<button type="button" class="btn btn-light" onClick={(e) => {this.addToCart(product)}}>+</button>
{!product.locked && <button type="button" class="btn btn-light" onClick={(e) => {this.addToCart(product)}}>+</button>}
{product.quantity}
<button type="button" class="btn btn-light" onClick={(e) => {this.decreaseInCart(product)}}>-</button>
{!product.locked && <button type="button" class="btn btn-light" onClick={(e) => {this.decreaseInCart(product)}}>-</button>}
</td>
<td>{product.price} </td>
<td><button type="button" class="btn btn-light" onClick={(e) => {this.deleteProduct(product)}}>Smazat</button></td>
<td>{!product.locked && <button type="button" class="btn btn-light" onClick={(e) => {this.deleteProduct(product)}}>Smazat</button>}</td>
</tr>)}
<tr>
<td>Celkem</td>