Wojtek Naruniec

How to handle zero dollar checkout

Zero Dollar Checkout is a core Magento payment method available to handle checkouts with a zero total. Of course it’s not really desired to have too many  zero dollar checkouts in e-commerce, but it can occur in some cases. It could be an order completely paid with reward points, an order with a 100% discount code or an order containing only a free item.

If method is enabled and the order total is zero, it becomes visible and the customer can choose to finish checkout without using other payment methods. However, if other payment methods are still enabled and displayed, it can confuse the customer. I saw use cases in which the customer tried to pay $0 using credit card payment method. It failed as payment gate throws error in such case.

A good way to handle that is setting Minimum Order Total configuration value to $0.01 for all methods other than Zero Dollar Checkout. Then all other methods will be automatically hidden if total is $0.

Unfortunately not all methods implement Minimum Order Total field.

Luckily, it’s very easily to fix that. It’s only about adding a new configuration field for the payment method.

I’ve added a new field for my payment method in system.xml file under XML path “config -> sections -> payment -> groups -> your_payment_method_key -> fields”:

<min_order_total translate="label">
        <label>Minimum Order Total</label>
        <frontend_type>text</frontend_type>
        <sort_order>157</sort_order>
        <show_in_default>1</show_in_default>
        <show_in_website>1</show_in_website>
        <show_in_store>0</show_in_store>
</min_order_total>

And then added default value in config.xml file under XML path “config -> default -> payment -> your_payment_method_key”:

    <min_order_total>0</min_order_total>

That’s it, the rest should be automatically done thanks to Magento core Mage_Payment_Block_Form_Container::_canUseMethod() method.

I see that as good practice to implement Minimum Order Total field in each method and use that properly. Don’t try to process $0 with payment gates.

Photo: it’s Common Raven, my favourite bird, which we spotted in way to Detiffoss waterfall in Iceland.

Welcome

A few years ago, in  2006 I started a PHP and Zend Framework blog under naruniec.info domain. The intention was to share my Zend Framework knowledge and experience with Polish developers while the framework grows. I stopped writing in 2009 as it was really hard to find time for blogging . It was even harder to start blogging again because a lot of important things started happening in my life – a serious job, family, children and a lot of hobbies.

Now I’m going to start blogging again. However, my areas of expertise have evolved a bit. Now the main focus is Magento. I’m going to share my Magento knowledge as well as general e-commerce and work experience.

My previous blog was naruniec.INFO and contained mostly information. This one is naruniec.ME and will also include few things about me.