The adjustment_totals from the Order response from...
# general
v
The adjustment_totals from the Order response from the API lists all adjustments, including shipping promotions. But the adjustment object itself does only list the Spree::PromotionAction kind. Is this on purpose?
I guess it is consider the adjustments belong to the object itself, and not all adjustments related to it 🙂
k
Hey @victor, can you please post an example, I’m not sure to fully understand the question
v
The adjustment total for the order is the sum of all adjustments. While the adjustment object is only the Spree::Order adjustments
Basically, I wanted to calculate the
ship_total
after adjustments.
k
are there other
something_adjustments
on that json response?
v
So each individual shipment has its adjustments
k
ah got it, I can’t recall why it’s like that, probably to avoid duplicate subobjects
💯 1
v
I suppose
c
IIRC
order.adjustments
contains only order level adjustments. If you want the line item adjustments you will want to get
order.line_item_adjustments
or to get all you will want to serialize and send
order.all_adjustments
- https://github.com/solidusio/solidus/blob/master/core/app/models/spree/order.rb#L87-L94. I imagine the API does not serialize all these associations by default to avoid duplication like @kennyadsl suggested.
You can override this partial to add the additional associations at the root if you didn’t want to traverse the line_items / shipments etc. to collect all of them https://github.com/solidusio/solidus/blob/e878076f2ed670d07654ab6293a16588743f2fa6/api/app/views/spree/api/orders/_big.json.jbuilder#L49-L51
v
Hi Chris, I did indeed end up adding some fields to the response
👍🏼 1