On some commerce sites, it is possible for the total cost of an order to be zero. For example, the customer may have a coupon for a free item, or the site may offer free samples, such as color swatches on a fabric site or a chapter of an electronic book on a bookstore site.

To support these situations, Commerce Cloud makes it possible for a shopper to bypass providing payment information when placing a zero-cost order. By default, if the total cost of an order is zero, the shopper does not need to provide payment information to place the order. This behavior is controlled by the isPaymentsDisabled function in the OrderViewModel:

OrderViewModel.prototype.isPaymentsDisabled = function(){
    var self = this;
    var disableRules = self.cart().total() == 0;
    if(disableRules){
       $.Topic(pubsub.topicNames.PAYMENTS_DISABLED).publish();
    }
    return disableRules;
}

This function returns true if its disableRules variable is true. As you can see in the code above, disableRules is set to true if the total cost of the shopping cart is zero. If you want to require shoppers to provide payment information even when the order cost is zero, you can extend the view model to remove this condition. You can also add other conditions for determining whether to disable payments.

Note that gift card and credit card payment widgets have a triggerValidations flag that determines whether to validate the required payment information, such as the card number and CVV. You can change the setting of this flag depending on the behavior your sites require.

See the Developing Widgets guide for information about extending widgets and view models.


Copyright © 1997, 2017 Oracle and/or its affiliates. All rights reserved. Legal Notices