0

I am trying to process a transaction through code, in some ways it goes fine, but when i actually interact with it from a frontend controller something strange happens:

    var_dump($quoteObj->getSubtotal(), false);

    $ccInfo = array();
    // assign payment method
    if ($payment_method == "authorizenet") 
    {
        $quotePaymentObj = $quoteObj->getPayment();
        $quotePaymentObj->setMethod('authorizenet');
        $quoteObj->setPayment($quotePaymentObj);
        $quoteObj->getPayment()->setCcNumber($cc_number);
        $quoteObj->getPayment()->setCcType($this->returnCardType($cc_number));
        $quoteObj->getPayment()->setCcExpMonth($details['expiry-month']);
        $quoteObj->getPayment()->setCcExpYear($details['expiry-year']);
        $quoteObj->getPayment()->setCcLast4(substr($cc_number,-4));
        $quoteObj->getPayment()->setCcCid($details['cvv']);
    } 
    else {
        $quotePaymentObj = $quoteObj->getPayment();
        $quotePaymentObj->setMethod($payment_method);
        $quoteObj->setPayment($quotePaymentObj);
    }
    //$quoteObj->collectTotals()->save();
    $quoteObj->save();

    var_dump($quoteObj->getSubtotal());

    $quoteObj->collectTotals()->save();

    var_dump($quoteObj->getSubtotal());exit;

    The results of the var_dumps are as followed:
    string '660.0000' (length=8)
    string '660.0000' (length=8)
    float 0

Any one any idea how collectTotals resets it to 0? I have looked in the method, but cannot get a clear answer.

I also followed some advice and started disabling all modules that touch the sales_quote_collect_after, when that didn't work, i also tried to remove the event configs from their xmls, which resulted in the same (meanwhile flushing my caches).

So the result of this problem is that i cannot capture, there is a 0 amount. And even when i don't manually trigger the collectTotals, it is done somewhere else and results in 0.

Any insights, or pointers in the right direction will be appreciated.

3
  • Firing from the hip here, but what if you exclude the $quoteObj->save() prior to running collectTotals?
    – travisw
    Commented Aug 14, 2015 at 16:25
  • I tried that before the current scenario, but i just confirmed again, and yeah same issue. Commented Aug 14, 2015 at 16:38
  • classyllama.com/blog/… May give you some more insight into the wormhole that is collectTotals :)
    – B00MER
    Commented Aug 16, 2015 at 8:16

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.