Closed ramundomario closed 3 years ago
Hi @ramundomario,
There is two ways of handling what you need :
OrderItem
At the moment we are already using the second way as it's done in this Sylius package since also in CoreShop there is only an OrderItem
which matches to a line_item
.
Maybe I didn't explain myself well, I try to do it with an example:
Order
with one OrderItem
of 10€line_item
of 10€ and the discount amount is loss because the discount is applied to the Order
and not directly to the OrderItem
.
I took a quick look at the sylius documentation and it looks like you also have coupons discount too, but I'm not sure if they work the same way (not associated with an OrderItem
)The first way could be a valid workaround (since you have a single line_item
of the order total amount) with the con you don't see OrderItems
in checkout page.
Thanks a lot for your feedback and hope I was clear 😉
Sylius is using adjustments on OrderItemUnits, OrderItem or on the Order. But by default only on OrtemItemUnits is used. This allow each OrderItemUnit to be aware of every promotions, adjustments, shipping adjustments and taxes adjustments, so when we ask for a total on an OrderItem all adjustments have already been distributed over each sub OrderItemUnits and we get the exact total we need for each item.
Thanks a lot @Prometee for the quick overview of Sylius I would be interested, if possibile, in @dpfaffenbauer thoughts :wink:
CoreShop uses a similar approach to Sylius, but a bit different. CoreShop has Adjustments on Order and OrderItem. Order Adjustment are directly reflected in the total price, whereas OrderItem Adjustment are not always. Due to how CoreShop handles discounts -> they get calculated per item, but are not directly reflected in the item price. You could just do $item->getTotal() -> $item->getAdjustmentsTotal()
to get the real order-item price.
I don't exactly understand what the real problem here is? Does Stripe calculate the Total Payment based on line_items?
@dpfaffenbauer yes it does calculate the total based on line_items
Thanks a lot for your support @Prometee, we will continue in our repo
This may be a bit late, but on a non-Sylius project I had a similar problem, and was advised by Stripe support that the best way to handle discounts was using Stripe coupons. We manage all the discount codes ourselves on the website, so when a customer uses one of our discount codes, when we create the order on Stripe, we first create a Stripe coupon object with max_redemptions set to 1, for the value of the total discount we want to apply. We then add the order to Stripe, adding that Stripe coupon code. It's a bit fiddly, but works well. and provides a very good user experience - the Stripe hosted payment page and confirmation email list all the order items at the correct value, and shows the correct amount of discount and correct total order value.
@Prometee Is there any way to apply the discounts? when we using coupons it seems to apply the discounts just fine but with Gift cards it's not working.
@Manasmd on my own project I made a Promotion action for this : The screenshot is showing the custom promotion action needed to link the promotion to a Stripe coupon, it will be different for each currencies you have, in my case I have 2 currencies each attached on 2 channels.
@Prometee thanks for your swift response! So the only was is to add a "stripe coupon" in the stripe dashboard for each "GiftCard" we create in sylius?
Since we have limited access to stripe dashboard, would it be possible to amend the total in sylius.order.pre_payment event?
@Manasmd It's up to you, I choose to sync promo with Stripe coupon but you can also change the total amount (via decorating the Providers
available in this plugin for example).
Hi @Prometee, maybe this isn't an issue for Sylius because maybe it works differently, sorry! I opened this issue to discuss this issue (coreshop/PayumStripeBundle#6) we came across with Stripe Checkout. In our case, in CoreShop, we have cart price rules (for example vouchers) which reduce the price of the order (but not of a product). This use case is currently not managed and it doesn't seem possible currently with Stripe Checkout (unless workaround), do you also have this problem?
Thanks for a feedback Regards