Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Peter 27 posts 192 karma points
    Oct 27, 2016 @ 13:33
    Peter
    0

    Triggering custom task in OrderPreparationOrderCreate taskchain

    Hello,

    Similar to Jakob and Tyler in this thread I want to decrement my product quantities when the order has been placed, rather than as the order is shipped.

    My custom task does not seem to get triggered correctly, though. I expect my task to get triggered once I authorize the payment (CheckoutManager.Payment.AuthorizePayment(paymentMethodKey)), however it is only triggered when I authorize AND capture (CheckoutManager.Payment.AuthorizeCapturePayment(paymentMethodKey))

    In my setup I have done the following:

    1. removed RemoveShipmentOrderItemsFromInventoryAndPersistShipmentTask from the OrderPreparationShipmentCreate task chain
    2. Added my custom task to the end of the OrderPreparationOrderCreate task chain
    3. Implemented my custom task inheriting from OrderCreationAttemptChainTaskBase
    4. Making sure AlwaysApproveOrderCreation has been set to true

    Does anyone have any advice as to what I could be missing?

    BR Peter

  • Jesus 7 posts 75 karma points
    Sep 20, 2017 @ 18:15
    Jesus
    0

    Hi, this issue is because only the order are generated when the invoice is paid.

    i have in my merchello.config

    <setting alias="AlwaysApproveOrderCreation" value="false" />

    and my tasks in here

    <taskChain alias="OrderPreparationOrderCreate">
        <tasks>
            <task type="Merchello.Core.Chains.OrderCreation.ConvertInvoiceItemsToOrderItemsTask, Merchello.Core" />
            **<task type="CustomDirectory.Chains.RemoveOrderItemsFromInventoryTask, App_Code" />** this task
        </tasks>
    </taskChain>
    

    trigger when i do in my payment provider controller

     **var order = attempt.Invoice.PrepareOrder();** right here
    order.OrderStatus = MerchelloContext.Current.Services.OrderService.GetOrderStatusByKey(Merchello.Core.Constants.DefaultKeys.OrderStatus.NotFulfilled);
      MerchelloContext.Current.Services.OrderService.Save(order);
    

    I successfully trigger my task even tho only the invoice is authorize the payment.

    Part of my code in my CustomPaymentProviderController

     // Realizamos el autorizaciĆ³n del pago
    
                var attempt = this.CheckoutManager.Payment.AuthorizePayment(paymentMethod.Key, args);
    
                //Verificamos success unicamente para que se reste la cantidad en el material comprado 
                if (attempt.Payment.Success)
                {
                    var order = attempt.Invoice.PrepareOrder();
                    order.OrderStatus = MerchelloContext.Current.Services.OrderService.GetOrderStatusByKey(Merchello.Core.Constants.DefaultKeys.OrderStatus.NotFulfilled);
                    MerchelloContext.Current.Services.OrderService.Save(order);
                }
    

    PD. Sorry if my english is not the best. Hopefully this info can be usefull. regards

Please Sign in or register to post replies

Write your reply to:

Draft