Our customer just asked if its possible to get an input field on an order where they could reduce the whole order price.
The scenario is that they want to give a discount on the whole order. They will ofc go in manually to reduce the price in their payment provider on the order. So if they could "add an orderline" with a -xxx value or something like it. So that they can resend an order confirmation with a line saying "Discount".
Well I think you need to make it this way then. Add the required UI in the AdminOrder.xslt. Now create a /base method that will add the discount order line. In this base method you need to check that the user is logged into the umbraco (security). You can do this with SessionController.HasAdminAccess. Now add the order line to the order in the C# code. Make some javascript in your xslt that calls the /base method and updates the UI. Should be it :)
In the current version of Tea Commerce - you need an umbraco node as TC works with nodeId and the umbraco content. So create a discount node with a price of 0. Then add that orderline using the method you specified. Now you can change the quantity and price of that orderline.
Ive created some simple func that adds the discount as a unique orderline and then sets the UnitPrice(all other values seems to be read only) to the discount price. But its like that the unitprice is saved correctly.
public static void AddDiscount(long OrderId, decimal Discount, int DiscountNodeId)
{
//CHECK IF WE HAVE ACCESS RIGHTS
if (SessionController.HasAdminAccess)
{
Order o = Order.GetOrder(OrderId);
OrderLine ol = o.CreateUniqueOrderLine(DiscountNodeId, 1);
ol.UnitPrice = -(Discount);
}
All the values come into the base func just right the values are(not that it matters : )
orderid : 170
discount: 100
dicountNodeId :1303
And if i look in my stacktrace the "unitprice" is set to "-100"
And the wierd part is that i have seen it working(the above screenshot)
What am i missing ?
(i have ofc made a func to remove all discount lines :) )
Is it possible to reduce the whole order price?
hey :)
Our customer just asked if its possible to get an input field on an order where they could reduce the whole order price.
The scenario is that they want to give a discount on the whole order. They will ofc go in manually to reduce the price in their payment provider on the order. So if they could "add an orderline" with a -xxx value or something like it. So that they can resend an order confirmation with a line saying "Discount".
Is this possible ?
Hi Rasmus
So this is in the admin part of Tea Commerce? Has the customer "paid" with credit card?
Kind regards
Anders
Hey Anders : )
Yeah its in the Teacommerce order view (teaCommerceAdminOrder). Yea its after the order is finialized and payed for.
But the payment is not a problem because our customer can always login to their creditcard dealer and lower the payment.
Its only meant to add a line inside the teacommerce order and make a reduction on the total order.
Its not a function that will be used often i know, but if you want to give some discount for a client it should be there.
Well I think you need to make it this way then. Add the required UI in the AdminOrder.xslt. Now create a /base method that will add the discount order line. In this base method you need to check that the user is logged into the umbraco (security). You can do this with SessionController.HasAdminAccess. Now add the order line to the order in the C# code. Make some javascript in your xslt that calls the /base method and updates the UI. Should be it :)
Kind regards
Anders
awesome ill give it a shot.
im building the /Base func atm and its my first time touching Teacommerce.Data. But my question is about how to add the "discount".
Im gussing I should use Order.CreateOrderLine(int nodeId, decimal quantity);
But do I have to add a node named "discount" with a price of "1" and then use that NodeId and set the quantity to the "discount" ?
or is their any other ways to achive this ?
In the current version of Tea Commerce - you need an umbraco node as TC works with nodeId and the umbraco content. So create a discount node with a price of 0. Then add that orderline using the method you specified. Now you can change the quantity and price of that orderline.
Kind regards
Anders
Arh okay :)
Then i was on the right track :)
Thx.
someone should hand you and your team a bottle of whiskey next time I see ya for making a topnotch product heh :)
Uhh sounds nice - its almost christmas - and we do accept gifts at the office address :p
But its really nice done!
Hmm but something is a bit off for me.
It works like 20% of them time.
Ive created some simple func that adds the discount as a unique orderline and then sets the UnitPrice(all other values seems to be read only) to the discount price. But its like that the unitprice is saved correctly.
All the values come into the base func just right the values are(not that it matters : )
orderid : 170
discount: 100
dicountNodeId :1303
And if i look in my stacktrace the "unitprice" is set to "-100"
And the wierd part is that i have seen it working(the above screenshot)
What am i missing ?
(i have ofc made a func to remove all discount lines :) )
Im gussing that i have to put it back into the order obj and save it or ? :)
If you change the order - you will have to save it :)
is working on a reply...