Skip to content

remove call to $order_total_modules->process(); #433

@proseLA

Description

@proseLA

pursuant to our conversation today, i think the following code changes will eliminate the bug associated with gift certificates.

we can change this line here:

$order_total_modules->pre_confirmation_check();

to

    $calculatedTotal = $order_total_modules->pre_confirmation_check('string');
    $total = $calculatedTotal;
    if (is_array($calculatedTotal)) {
        $total = $calculatedTotal['total'];
    }

we can then delete line 185:

$order_totals = $order_total_modules->process();

finally we need to change this section of code:

if (($_SESSION['opc_saved_order_total'] ?? '') !== $currencies->value($order->info['total'])) {
$error = true;
$checkout_one->debug_message(
"Order-total mismatch, before and after:\n" .
json_encode($_SESSION['opc_saved_order_total'] ?? '', JSON_PRETTY_PRINT) . "\n" .
json_encode($currencies->value($order->info['total']), JSON_PRETTY_PRINT)
);
$messageStack->add_session('checkout_payment', ERROR_NOJS_ORDER_CHANGED, 'error');
}

to:

if (($_SESSION['opc_saved_order_total'] ?? '') !== $currencies->value($total)) {
    $error = true;
    $checkout_one->debug_message(
        "Order-total mismatch, before and after:\n" .
        json_encode($_SESSION['opc_saved_order_total'] ?? '', JSON_PRETTY_PRINT) . "\n" .
        json_encode($currencies->value($total), JSON_PRETTY_PRINT)
    );
    $messageStack->add_session('checkout_payment', ERROR_NOJS_ORDER_CHANGED, 'error');
}

the only reason i see calling the process method is to update the $order->info['total'] amount and use it for comparison to the opc saved value.

frankly i am surprised that this bug was not exposed earlier; but then again, maybe my payment module is the only one that needs the correct amount on the confirmation page?

as we saw, this is a definite bug as the amount going to the payment module using 3 page checkout was different from the amount going from OPC. and i have tracked that bug down to line 185.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions