-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Catalog price resolver #288
Conversation
@Mikearaya I thought a lot about this PR and what we want to achieve. Dumping the price tables doesn't feel right to me. Currently we have SimpleProducts which can have 1 valid catalog price and 1 simulated price based on the current context. That's fine and correct. But let's assume we have 5 Simple Products that are behind a Proxy (Configurable Product) like this:
If you have a ConfigurableProduct that could end up in one of the above SimpleProducts, the range we want to show is: The simulated price range for a ConfigurableProduct is different though because the query accepts a quantity: So maybe ConfigurableProduct should be extended like this:
|
c5cd3b3
to
3cf92a4
Compare
Yes dumping the product catalogue price was used based on the conversation on the issue I.e. to let the frontend extract the min and max value of the product. |
Absolutely, we should expose a function to query for these quantity levels and the maxQuantity in ProductPrice could do it but it's not really a good API for a frontend developer. The reason I have used Query.productCatalogPrices before is to kind of split the "private" pricing data which is only editable and querable by admins from the public data, (same like translatedProductTexts). In the db, pricing is stored in this way:
Currently the
It's kind of a mix of different attributes + the price and it does not really make sense to reuse it for catalogPrice and simulatedPrice on the product level because that's interpreted data. Currently the SimpleProduct.catalogPrice looks like this: simulatedPrice does more and uses the dynamic pricing logic but at the moment it's inconsistent with catalogPrice as it also lets you manually "choose" an alternate currency (which is nice and we needed it for Weng): So I suggest maybe we have to change the API like this: Simple Product:
Then we should also audit the whole API and propably replace all occurences of "Money" with Price as the Money type kind of sucks when using the API. |
So basically I'm not happy with the current state of the GraphQL schema as a whole when it comes to price display. But maybe it's not the right time to refactor this? |
I agree it's a big change and a lot of breaking changes but at the same time if I complete the work queue filter PR there is probably one ticket for me to take (create repo adding forget password flow) so I have time to engage in this change until the print ends and ready for release, we defiantly will need a few back and forth to stay on the same track but it's doable. |
what is the purpose of |
also, should we add another field |
@pozylon I've added the initial fields we discussed ( |
When you proposed dumping the catalog price table it would have exposed the price levels (different maxQuantity), which was not in my mind but I certainly see that for some customers we might render that to the customer in a UI like:
So in order to do that you would use leveledCatalogPrices + catalogPrice |
See my comment about the type PriceLevel, I'd still only store maxQuantity but in the GraphQL API show the complete ranges with min & max quantity. price maxQuantity |
SimpleProduct catalogPrice/simulatedPrice -> Still only return exactly 1 price depending on parameters and context SimpleProduct leveledCatalogPrices -> can return multiple prices because there are multiple records for same currency / country with different maxQuantities ConfigurableProduct catalogPriceRange/simulatedPriceRange -> can return multiple prices because it's a configurable product having more than 1 simple products to choose from depending on variants. It will iterate over the simple products and call catalogPrice/simulatedPrice |
So catalogPriceRange,simulatedPriceRange,catalogPrice,simulatedPrice all take a quantity argument and the quantity level is basically "locked" but leveledCatalogPrices will not take the quantity |
4d1a295
to
79659ab
Compare
@pozylon the price range resolvers are added including |
e791cc9
to
142ebe6
Compare
@pozylon What we have discussed so far has been implemented now my next step is replacing all traces of Money type but since now prices apply differently based on the quantity of order (that's what we are displaying with leveled catalog price) we should also add this to the logic order pricing and it would be helpful and faster for me if you could share your thoughts on how I should approach it rather than trying to decipher the whole process of order pricing. |
DeliveryFee.price: Money
can be replaced with price if it didn't have
OrderDelivery.fee:Money
will be
this has been affected by the change to DeliveryProvider type already but changes to this alone will affect
`OrderDiscountable.total
this change in turn will trickle down to
OrderDiscount.total
and trickle down to affect types
This in turn will affect
will become
this will affect
will be
this will affect
will become
inherit down to
|
Mhm, I don’t get what exactly you want to change regarding the order pricing. I was not really thinking to tamper the order pricing. Can you try to explain by showing me some pseudo schema or concept? |
Oh okay wow just missed each other, |
after auditing the whole schema for |
i mean since now the price applied to the order will differ based on the quantity a person orders i was thinking there should be some update there too to handle that logic let say a product default price is $100 but in bulk order say 5 items that will drop to $90. so when calculating the order total price the quantity of the item in question should be considered |
Order Pricing uses pretty much the same price logic like price simulation so it will automatically gain that new feature I guess nothing to change there. |
Order Pricing will go through all items, take the quantity of the items, let it run through product pricing, sum it all up then add delivery and payment fees. |
Product pricing takes the correct price level through the normal catalog price plugin |
I don‘t know why country is there, does not make sense to me, so I think that is a great idea to change |
@pozylon Noted. I was thinking the same too, left them out until we are happy with the actual changes. I'll add the tests. |
@Mikearaya In a new branch, else brain is going to 💨 |
… maxQuantity = infinity
5abc14d
to
fa05b94
Compare
@pozylon 😆 i agree. ok do the honor and merge this one🎀 |
I've added the field on the top level product object so all products (simple, bundle configurable) return the same price list. this will remove the need for
query.productCatalogPrices