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.
$quoteObj->save()
prior to runningcollectTotals
?collectTotals
:)