Is there not some way to hook into a Sale at the point where an order is complete and the credit card payment has been confirmed? I need to notify another (outside) process of the Sale status - eg. If Product X is in the order, toggle process Y; if Product A was sold, toggle process B, etc.
Is there an event raised at the point the Order Status changes? or an overload available for the code-behind?
I was looking at Order.OrderStatus.Triggers[] but that seems to be limited to email functions...
Paid Sale Trigger
Re: Paid Sale Trigger
You can do this stuff in CheckedOut method of ConLib/OnePageCheckout.ascx.cs method. Edit this file and then locate CheckedOut method and do something like below
Code: Select all
if (response.Success)
{
Order order = OrderDataSource.Load(e.OrderId);
if(order.OrderStatus.Name == "someorderstatus")
{
//do your custom notification stuff here
}
------------------------------------
------------------------------------
------------------------------------
}
Re: Paid Sale Trigger
Many thanks Mazhar. That indeed seem to be the obvious "hook". A couple of subsequent questions:
1. Would hooking in at this point also take into consideration gift certificates and coupons?
2. Would the same logic apply for subscription sales where the initial payment and/or first recurring payment has been paid?
3. Lets say I create an Order Status of "CompletelyPaid" with triggers of "Order Paid" and "Order Paid No Shipments". Are those 2 triggers a logical AND or OR condition to trigger the status of "CompletelyPaid"?
4. Does re-loading the order with OrderDataSource.Load automatically recalculate the OrderPaymentStatus? Or would it be wise to call order.RecalculatePaymentStatus() after the re-load but before the status check?
5. Is checking order.OrderStatus.Name == "someorderstatus" better than checking if order.PaymentStatusId == "paid"? Or for that matter, checking if order.GetBalance() <= 0 ?
1. Would hooking in at this point also take into consideration gift certificates and coupons?
2. Would the same logic apply for subscription sales where the initial payment and/or first recurring payment has been paid?
3. Lets say I create an Order Status of "CompletelyPaid" with triggers of "Order Paid" and "Order Paid No Shipments". Are those 2 triggers a logical AND or OR condition to trigger the status of "CompletelyPaid"?
4. Does re-loading the order with OrderDataSource.Load automatically recalculate the OrderPaymentStatus? Or would it be wise to call order.RecalculatePaymentStatus() after the re-load but before the status check?
5. Is checking order.OrderStatus.Name == "someorderstatus" better than checking if order.PaymentStatusId == "paid"? Or for that matter, checking if order.GetBalance() <= 0 ?
Re: Paid Sale Trigger
You can iterate over the order items and can access coupons or gift certificate like1. Would hooking in at this point also take into consideration gift certificates and coupons?
Code: Select all
foreach(OrderItem orderItem in order.Items)
{
if(orderItem.OrderItemType == OrderItemType.Coupon)
//Coupon processing code here
else
if(orderItem.OrderItemType == OrderItemType.GiftCertificate)
//Gift Certificate processing code here
}
Yes2. Would the same logic apply for subscription sales where the initial payment and/or first recurring payment has been paid?
You can take it like logical or.3. Lets say I create an Order Status of "CompletelyPaid" with triggers of "Order Paid" and "Order Paid No Shipments". Are those 2 triggers a logical AND or OR condition to trigger the status of "CompletelyPaid"?
No need to call recalculate on order again. Just load by using OrderDataSource.Load(orderId,false) it will order object without using cached one.4. Does re-loading the order with OrderDataSource.Load automatically recalculate the OrderPaymentStatus? Or would it be wise to call order.RecalculatePaymentStatus() after the re-load but before the status check?
Its up to you, you can check it depending upon payment status like5. Is checking order.OrderStatus.Name == "someorderstatus" better than checking if order.PaymentStatusId == "paid"? Or for that matter, checking if order.GetBalance() <= 0 ?
Code: Select all
if(order.PaymentStatus == PaymentStatus.Paid)
{
}
Re: Paid Sale Trigger
I think that should be:
Code: Select all
if(order.PaymentStatus == OrderPaymentStatus.Paid)