Bug [# 877] cannot complete checkout when final amount is null (zero, 0)
Tags:   No tags associated yet.

  Go back
 Category:  --  Severity:  --  Version:  --
 Joomla! Version:  --  Browser Version:  --  Fixed in Version:  --
Description:
When final amount is zero, the final step of checkout fails, stating "please choose payment method". I noticed that during the 4-steps checkout, the payment step is skipped (however, this makes sense, as amount is zero). I've setup a demo to show this issue: http://www.neodiffusion.com/index2.php?option=com_virtuemart&page=shop.product_details&flypage=shop.flypage&product_id=10. I'm ready to contribute to solving this issue, even if my knowledge of Joomla / VirtueMart is limited.
Details:
Submitted Comment
soeren_nb
Nov 21 2006
Just dealt with this problem today - the problem is in administrator.components/com_virtuemart/classes/ps_checkout.php in function validate_payment_method():
[{
if( !empty( $d['order_total'])) {
if( $d['order_total'] <= 0.00 ) {
return true;
}
}
]}
change it to [{
if( isset( $d['order_total'])) {
if( $d['order_total'] <= 0.00 ) {
return true;
}
}
]}

Eventhough $d['order_total'] is 0, empty() reports it to be empty.
soeren_nb
Nov 18 2006
A small correction to the previous code.
Change:
[{$total=round(strval(($this->calc_order_subtotal($d)+
round( $this->calc_order_tax($this->calc_order_taxable($d), $d), 2 ))));]}
To:
[{$total=round(strval(($this->calc_order_subtotal($d)+
round( $this->calc_order_tax($this->calc_order_taxable($d), $d), 2 ))), 2);]}

I added the second parameter to the last round function call.
soeren_nb
Oct 12 2006
This completes my ugly hack.

In line 492 of ps_checkout.php replace the CHECK_OUT_GET_FINAL_CONFIRMATION case code with the following:
[{case CHECK_OUT_GET_FINAL_CONFIRMATION:
$discountamount=$_SESSION['coupon_discount'];
$total=round(strval(($this->calc_order_subtotal($d)+ round( $this->calc_order_tax($this->calc_order_taxable($d), $d), 2 ))));
if (($total-$discountamount) <= 0) //free product
{
$this->add( $d ); //log purchase
$oid=$d["order_id"];
//update
require_once(CLASSPATH."ps_order.php");
$ps_order =& new ps_order();
$newd = array ("order_id" => $oid,
"notify_customer" => "Y",
"order_status" => "C",
"current_order_status" => "P");
$ps_order->order_status_update($newd);
//redirect user to proper page
mosredirect("index.php?option=com_virtuemart&ItemId=29&page=checkout.thankyou&order_id=$oid", "");
}
else return( $this->add( $d ) );]}

This is only a patch. I believe the free product feature must be included in virtuemart. Also, the fact that the check for a zero total is in checkout.paymentradio.php seems just wrong.
soeren_nb
Oct 12 2006
I solved the problem a patch or hack (depending on how dirty you think it is).

In the file checkout.paymentradio.php in line 58 you'll find the following code

[{
elseif( $order_total <= 0.00 ) {
// In case the order total is less than or equal zero, we don't need a payment method
mosRedirect($sess->url(SECUREURL."index.php?page=checkout.index&ship_to_info_id=$ship_to_info_id&shipping_rate_id=".urlencode($shipping_rate_id)."&checkout_this_step=99&checkout_next_step=99"),"");
}
]}

If you comment the mosRedirect then virtuemart will let you proceed with the checkout and go to the payment page.

Essentially this isn't right. If you do allow the checkout of a zero total cart then you should register the purchase in the DB as confirmed. But I have not been able to fine where the ps_checkout->process() method is called.

I posted a [http://virtuemart.net/index.php?option=com_smf&Itemid=71&topic=22419.0|question ]in the forum yesterday about this problem and it is still unanswered.
soeren_nb
Oct 06 2006
Same issue with VirtueMart 1.0.7

Am I the only one to worry about this issue??
Tried to inserts "hacks", but ended with dirty things, and still not working properly...
soeren_nb
Sep 01 2006
I tried to reproduce and can confirm that you cannot complete the process if the amount is zero.