Add price from value for external product inquiries (#49)
This commit is contained in:
+14
-5
@@ -526,8 +526,7 @@ def inquiry_poster(inquiry):
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
def inquiry_external_product(inquiry):
|
def inquiry_external_product(inquiry, external_id):
|
||||||
external_id = request.args.get("external_product_id", type=str)
|
|
||||||
data = {
|
data = {
|
||||||
"id": inquiry.id,
|
"id": inquiry.id,
|
||||||
"retouch_price": inquiry.local_price_retouch(rounded=False, inc_vat=True),
|
"retouch_price": inquiry.local_price_retouch(rounded=False, inc_vat=True),
|
||||||
@@ -591,10 +590,20 @@ def inquiry_framed_print(inquiry):
|
|||||||
@mod.route("/inquiry/<int:inquiry_id>", methods=["GET"])
|
@mod.route("/inquiry/<int:inquiry_id>", methods=["GET"])
|
||||||
def inquiry(inquiry_id):
|
def inquiry(inquiry_id):
|
||||||
inquiry = Inquiry.query.get_or_404(inquiry_id)
|
inquiry = Inquiry.query.get_or_404(inquiry_id)
|
||||||
external_id = request.args.get("external_product_id")
|
external_product_id = request.args.get("external_product_id")
|
||||||
sku = request.args.get("sku", type=str)
|
sku = request.args.get("sku", type=str)
|
||||||
if external_id:
|
listprice = request.args.get("listprice")
|
||||||
data = inquiry_external_product(inquiry)
|
|
||||||
|
if (listprice):
|
||||||
|
if (listprice == 'canvas'):
|
||||||
|
external_product_id = get_cheapest_canvas_product()
|
||||||
|
elif (listprice == 'poster'):
|
||||||
|
external_product_id = get_cheapest_poster_product()
|
||||||
|
else:
|
||||||
|
raise ValueError("Invalid listprice group {}".format(listprice))
|
||||||
|
|
||||||
|
if external_product_id:
|
||||||
|
data = inquiry_external_product(inquiry, external_product_id)
|
||||||
elif inquiry.product_group == "photo-wallpaper":
|
elif inquiry.product_group == "photo-wallpaper":
|
||||||
data = inquiry_wallpaper(inquiry)
|
data = inquiry_wallpaper(inquiry)
|
||||||
elif inquiry.product_group == "canvas":
|
elif inquiry.product_group == "canvas":
|
||||||
|
|||||||
+16
-38
@@ -238,14 +238,28 @@ Sample response
|
|||||||
|
|
||||||
## Calculate inquiry price
|
## Calculate inquiry price
|
||||||
|
|
||||||
Calculates the price of an inquiry. For wallpapers inquiries the response will contain price information for all available materials and for canvas it will contain the price for both the framed and the not-framed canvas. External print products uses the `external_product_id` attribute. The `group` attribute tells which kind of product you are dealing with.
|
Calculates the price of an inquiry.
|
||||||
The width and height stored on the inquiry will be used in the calculations by default. If you want to override these values you can send in your own width/height parameters in the request.
|
|
||||||
|
For wallpapers inquiries the response will contain price information for all available materials. The width and height stored on the inquiry will be used in the calculations by default. If you want to override these values you can send in your own width/height parameters in the request.
|
||||||
|
|
||||||
|
External print products (canvas, posters, framed prints) uses the `external_product_id` attribute.
|
||||||
|
|
||||||
|
The `group` attribute tells which kind of product you are dealing with.
|
||||||
|
|
||||||
|
Parameters wallpapers
|
||||||
|
|
||||||
| Parameter | Description |
|
| Parameter | Description |
|
||||||
| --------- | ------------|
|
| --------- | ------------|
|
||||||
| `width` | Width in cm e.g `100`. Defaults to the inquiry stored width |
|
| `width` | Width in cm e.g `100`. Defaults to the inquiry stored width |
|
||||||
| `height` | Height in cm e.g `50`. Defaults to the inquiry stored height |
|
| `height` | Height in cm e.g `50`. Defaults to the inquiry stored height |
|
||||||
|
|
||||||
|
Parameters external print products
|
||||||
|
|
||||||
|
| Parameter | Description |
|
||||||
|
| --------- | ------------|
|
||||||
| `external_product_id` | e.g. `canvas_400x600-mm-16x24-inch_canvas_wood-fsc-slim_4-0_ver` |
|
| `external_product_id` | e.g. `canvas_400x600-mm-16x24-inch_canvas_wood-fsc-slim_4-0_ver` |
|
||||||
|
| `listprice` | Optional, one of `canvas` or `poster`. Will return the price for the cheapest product in group. Used for "Price from x kr" value |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Wallpaper inquiry - sample request
|
Wallpaper inquiry - sample request
|
||||||
@@ -285,42 +299,6 @@ Sample response
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Canvas inquiry - sample request
|
|
||||||
|
|
||||||
`curl -X GET 'https://api.photowall.com/prices/inquiry/310999?width=500&height=150`
|
|
||||||
|
|
||||||
Sample response
|
|
||||||
```
|
|
||||||
{
|
|
||||||
"group": "canvas",
|
|
||||||
"id": 310999,
|
|
||||||
"prices": [
|
|
||||||
{
|
|
||||||
"framed": true,
|
|
||||||
"height": 150,
|
|
||||||
"inquiry_price": 355.71481084,
|
|
||||||
"inquiry_price_excl_retouch": 355.71481084,
|
|
||||||
"inquiry_price_excl_vat": 284.571848672,
|
|
||||||
"m2_price": 112.887,
|
|
||||||
"m2_price_excl_vat": 90.3096,
|
|
||||||
"width": 150
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"framed": false,
|
|
||||||
"height": 150,
|
|
||||||
"inquiry_price": 846.6525,
|
|
||||||
"inquiry_price_excl_retouch": 846.6525,
|
|
||||||
"inquiry_price_excl_vat": 677.322,
|
|
||||||
"m2_price": 112.887,
|
|
||||||
"m2_price_excl_vat": 90.3096,
|
|
||||||
"width": 500
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"retouch_price": 0
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Calculate wallpaper kit price
|
## Calculate wallpaper kit price
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user