Forums / Built-in Shipping and Payment Modules / Allowing a customer to complete checkout process with zero total order.

Allowing a customer to complete checkout process with zero total order.

Locked

Views: 3,868

Results 1 to 10 of 10
This thread is locked. New replies are disabled.
24 Mar 2009, 10:12 PM
#1
sonjamichelle avatar

sonjamichelle

New Zenner

Join Date:
Mar 2009
Posts:
21
Plugin Contributions:
0

Allowing a customer to complete checkout process with zero total order.

I've run into an issue when using gift certificate, coupons, store credit, reward points and any combination thereof when I customer has applied these gimmicks to their order resulting in a $0.00 amount. The customer can no longer complete the checkout process because the payment options will not allow a $0.00 order. The freecharger module will not work because the base item is not free. The order total is the result of using the above gimmicks to get a free item.

I would like to add a payment option in the list for a zero amount order so the customer can complete the order process.

The only solution I've come up with so far is instructing the customer to choose check or money order.

25 Mar 2009, 2:48 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Allowing a customer to complete checkout process with zero total order.

Just for giggles and grins ... can you add this fix to your code ...
http://www.zen-cart.com/forum/showthread.php?p=705333#post705333

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

25 Mar 2009, 5:24 PM
#3
sonjamichelle avatar

sonjamichelle

New Zenner

Join Date:
Mar 2009
Posts:
21
Plugin Contributions:
0

Re: Allowing a customer to complete checkout process with zero total order.

Ok, I made that change, but I don't see where it had any bearing on my issue.

Everything is working as it should. I just don't have an option available for someone who has a zero total order.

My payment options are check/money order, paypal express, and paypal IPN. If I use check/money order I can check out and the order gets sent to the queue for processing. Of course if I choose paypal, paypal rejects it because it's a zero total. If I don't choose anything I get the "payment method not selected error".

Soooo, I either need to replicate the check/money order module and rename/re-function it to process the zero amount. Or I need to add an update button to the order total page that will take into account the gift certs, coupons, store credit, reward points, etc so that the freecharger module can come into play.

25 Mar 2009, 6:54 PM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Allowing a customer to complete checkout process with zero total order.

This is a totally experimental thought ...

Try editing /includes/classes/payment.php. Around line 40 you'll see this:if (zen_get_configuration_key_value('MODULE_PAYMENT_FREECHARGER_STATUS') and ($_SESSION['cart']->show_total()==0 and $_SESSION['shipping']['cost']== 0)) {Change it to:```
[B] global $order;[/B]
if (zen_get_configuration_key_value('MODULE_PAYMENT_FREECHARGER_STATUS') and ([B]($_SESSION['cart']->show_total()==0 || ($order->info['currency'] != '' && $order->info['total'] == 0)) [/B]and $_SESSION['shipping']['cost']== 0)) {

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

25 Mar 2009, 8:01 PM
#5
sonjamichelle avatar

sonjamichelle

New Zenner

Join Date:
Mar 2009
Posts:
21
Plugin Contributions:
0

Re: Allowing a customer to complete checkout process with zero total order.

That edit resulted in the payment page rendering blank.

Lines 39-58 in my file:

       // Free Payment Only shows
        if (zen_get_configuration_key_value('MODULE_PAYMENT_FREECHARGER_STATUS') and ($_SESSION['cart']->show_total()==0 and $_SESSION['shipping']['cost']== 0)) {
//global $order;
//        if (zen_get_configuration_key_value('MODULE_PAYMENT_FREECHARGER_STATUS') and (($_SESSION['cart']->show_total()==0 || ($order->info['currency'] != '' && $order->info['total'] == 0) and $_SESSION['shipping']['cost']== 0)) { 
          $this->selected_module = $module;
          if (file_exists(DIR_FS_CATALOG . DIR_WS_MODULES . '/payment/' . 'freecharger.php')) {
            $include_modules[] = array('class'=> 'freecharger', 'file' => 'freecharger.php');
          }
        } else {
          // All Other Payment Modules show
          while (list(, $value) = each($this->modules)) {
            // double check that the module really exists before adding to the array
            if (file_exists(DIR_FS_CATALOG . DIR_WS_MODULES . '/payment/' . $value)) {
              $class = substr($value, 0, strrpos($value, '.'));
              // Don't show Free Payment Module
              if ($class !='freecharger') {
                $include_modules[] = array('class' => $class, 'file' => $value);
              }
            }
          }

You can see where I commented out the edit that rendered the page blank.

25 Mar 2009, 8:23 PM
#6
wilt avatar

wilt

Oji-san

Join Date:
Jun 2003
Location:
Newcastle UK
Posts:
1,927
Plugin Contributions:
3

Re: Allowing a customer to complete checkout process with zero total order.

Hi,

Generally when using stock code and modules Zen Cart has no problems handling orders with zero value, even if you are using Paypal.

There is logic to test the order total and skip even going to paypal if it is.

I therefore suspect an incompatibility with some of the extra contributions you are using.

That said, something similar has been noted before regarding contributed order total modules, and a fix was provided.

The fix relates to the includes/classes/order_total.php file.

You will need to replace this block of code

  function pre_confirmation_check() {
    global $order, $credit_covers;
    if (MODULE_ORDER_TOTAL_INSTALLED) {
      $total_deductions  = 0;
      reset($this->modules);
      while (list(, $value) = each($this->modules)) {
        $class = substr($value, 0, strrpos($value, '.'));
        if ( $GLOBALS[$class]->credit_class ) {
          $order_total = $GLOBALS[$class]->get_order_total();
          if (is_array($order_total)) $order_total = $order_total['total'];
          $total_deductions = $total_deductions + $GLOBALS[$class]->pre_confirmation_check($order_total);
        }
      }
      $difference = $order->info['total'] - $total_deductions;
      if ( $difference <= 0.009 ) {
        $credit_covers = true;
      }
    }
  }

with

  function pre_confirmation_check() {
    global $order, $credit_covers;
    if (MODULE_ORDER_TOTAL_INSTALLED) {
      $total_deductions  = 0;
      reset($this->modules);
      $orderInfoSaved = $order->info;
      while (list(, $value) = each($this->modules)) {
        $class = substr($value, 0, strrpos($value, '.'));
        if ( $GLOBALS[$class]->credit_class ) {
          $order_total = $GLOBALS[$class]->get_order_total();
          if (is_array($order_total)) $order_total = $order_total['total'];
          $total_deductions = $total_deductions + $GLOBALS[$class]->pre_confirmation_check($order_total);
        }
        else 
        {
          $GLOBALS[$class]->process();
          $GLOBALS[$class]->output = array();
        }
      }
      $difference = $order->info['total'] - $total_deductions;
      if ( $difference <= 0.009 ) {
        $credit_covers = true;
      }
      $order->info = $orderInfoSaved;
    }
  }    

As with any code change, always make sure you backup any files being changed first.

25 Mar 2009, 8:34 PM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Allowing a customer to complete checkout process with zero total order.

sonjamichelle:

That edit resulted in the payment page rendering blank.
Ya, that's why I edited the post earlier to include the missing parenthesis.

I recommend exploring wilt's input though. :cool:

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

5 Jun 2009, 3:03 PM
#8
3_14 avatar

3_14

New Zenner

Join Date:
Jun 2009
Location:
Australia
Posts:
2
Plugin Contributions:
0

Re: Allowing a customer to complete checkout process with zero total order.

I have experienced the inability to accept payment from any zone when processing a cart with $0.00 total value.

My particular store is set up using a shipping module called - Static Shipping -

The payment module is an add-on called - Offsite Payment -

All other shipping and payment modules are defeated.

When arriving at the checkout......

A dialog comes up saying that "Sorry, we are not accepting payments from your region at this time" (Also seen at the thread http://www.zen-cart.com/forum/showthread.php?t=127765&highlight=accepting+payments )

Further, the confirmation email then insists on showing Gift Voucher/Coupon as the payment method.

This payment method is consequently displayed when viewing any previous orders.

My solution! ( ...based on only the two shipping and payment modules mentioned)

............in the file includes/classes/payment.php

I commented out the following section of code.

if (zen_get_configuration_key_value('MODULE_PAYMENT_FREECHARGER_STATUS') and ($_SESSION['cart']->show_total()==0 and $_SESSION['shipping']['cost']== 0)) {
$this->selected_module = $module;
if (file_exists(DIR_FS_CATALOG . DIR_WS_MODULES . '/payment/' . 'freecharger.php')) {
$include_modules[] = array('class'=> 'freecharger', 'file' => 'freecharger.php');
}
} else

Now this is done I am able to run $0.00 sales with the correct payment method.

The code I commented out was preceeded by an existing comment which says ...

// Free Payment Only shows

I guess I may have achieved what I want but it could break the use of the freecharger module shown in the defeated code.

5 Jun 2009, 3:12 PM
#9
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Allowing a customer to complete checkout process with zero total order.

Normal behavior is that the freecharger module must be enabled if you ever want to checkout when the balance is 0.00.
So, simply undoing the changes you mention, and enabling the freecharger module should suffice.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

5 Jun 2009, 4:22 PM
#10
3_14 avatar

3_14

New Zenner

Join Date:
Jun 2009
Location:
Australia
Posts:
2
Plugin Contributions:
0

Re: Allowing a customer to complete checkout process with zero total order.

Thankyou Dr Byte,

I've done as you said.