Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

ccrz.cc_api_DeliveryDate.getDeliveryDates

Returns available delivery dates for the date picker widget on the storefront. To specify your solution's rules for available delivery dates, override this method in your subscriber code.

Compatibility

This reference applies to:

Release Managed Package Version API Version
B2B Commerce for Visualforce Winter ’21 4.13 12
B2B Commerce for Visualforce Spring ’20 4.12 11
B2B Commerce for Visualforce Summer ’19 4.11 10
B2B Commerce for Visualforce Spring ’19 4.10 9
B2B Commerce for Visualforce Summer ’18 4.9 8

Signature

global virtual Map<String, Object> getDeliveryDates(ID, String, ccrz.cc_bean_MockContactAddress)

Inputs (Required)

Map<String, Object> that can include the following keys:

ccrz.cc_api_DeliveryDate.ACCOUNT_ID
ID of the account record used for checkout.
ccrz.cc_api_DeliveryDate.CART_ID
String that specifies the ID of the cart record used for checkout.
ccrz.cc_api_DeliveryDate.SHIP_ADDRESS
ccrz.cc_bean_MockContactAddress that represents the shipping address selected for checkout.

Outputs

Map<String, Object> that can include the following keys:

In B2B Commerce for Visualforce Summer ’18 (version 4.9), the bootstrap-datepicker.js library replaced the zebra_datepicker.js library for rendering the date picker widget on the storefront. The return data keys of this method still specify delivery date options that correspond to zebra_datepicker.js configuration options. The cc_CheckoutShippingRD.component Visualforce component in the managed package translates the data that this method returns into a format that bootstrap-datepicker.js can use.

Note

ccrz.cc_api_DeliveryDate.API_ERROR
Boolean
Value Usage
true An error occurred when constructing the delivery date data. When this key is true and the Validate Delivery Date setting of the Shipping Options storefront configuration is also true, the checkout flow doesn't continue.
false (default) The method returned the delivery date data successfully.
ccrz.cc_api_DeliveryDate.DURATION
Integer that specifies the number of days, after the offset value, when dates are no longer selectable in the date picker widget. For example, a duration value of 365 specifies that the final selectable date is one year after the first selectable date.
ccrz.cc_api_DeliveryDate.EXCLUDED_DATES
List<String> of values for the disabled_dates parameter of the zebra_datepicker.js library. This list specifies dates that you want to disable in the date picker widget. Each date uses the format dd MM yyyy, such as 31 12 2020.
  • The cc_CheckoutShippingRD.component Visualforce component converts these values to the mm/dd/yyyy format, such as 12/31/2020, and sets the corresponding datesDisabled option of the bootstrap-datepicker.js library.
  • You can provide either ccrz.cc_api_DeliveryDate.EXCLUDED_DATES or ccrz.cc_api_DeliveryDate.INCLUDED_DATES, but not both.

Note

ccrz.cc_api_DeliveryDate.INCLUDED_DATES
List<String> of values for the enabled_dates parameter of the zebra_datepicker.js library. This list specifies dates that you want to enable in the date picker widget. Each date uses the format dd MM yyyy, such as 31 12 2020.
  • The cc_CheckoutShippingRD.component Visualforce component converts these values to the mm/dd/yyyy format, such as 12/31/2020. Because the bootstrap-datepicker.js library doesn't provide a corresponding option, cc_CheckoutShippingRD.component includes a workaround to set these values.
  • You can provide either ccrz.cc_api_DeliveryDate.EXCLUDED_DATES or ccrz.cc_api_DeliveryDate.INCLUDED_DATES, but not both.

Note

ccrz.cc_api_DeliveryDate.MESSAGES
List<ccrz.cc_bean_Message> of messages to show to the buyer.
ccrz.cc_api_DeliveryDate.OFFSET
Integer that specifies the number of days from today until the first selectable date in the date picker widget. For example, an offset value of 1 specifies that the first selectable date is tomorrow.

The managed package also defines the following keys, but doesn't use them for returning any data:

  • ccrz.cc_api_DeliveryDate.DAYS_FILTER
  • ccrz.cc_api_DeliveryDate.MAX_DATE
  • ccrz.cc_api_DeliveryDate.MIN_DATE

Examples

Allow a buyer to select only Monday, Wednesday, or Friday for a delivery date. The range begins tomorrow, and is available for one year.

global class cc_example_api_DeliveryDateMWF extends ccrz.cc_api_DeliveryDate{
    global override Map<String, Object> getDeliveryDates(Map<String, Object> deliveryDatesInputData) {
        return new Map<String, Object> {
            ccrz.cc_api_DeliveryDate.OFFSET => 1,
            ccrz.cc_api_DeliveryDate.DURATION => 365,
            ccrz.cc_api_DeliveryDate.INCLUDED_DATES => new List<String>{'* * * 1,3,5'}
        };
    }
}

The value '* * * 1,3,5' uses syntax for the enabled_dates parameter of the zebra_datepicker.js library. For more examples and other supported syntax, see the zebra_datepicker.js documentation.

Tip

Allow a buyer to select any weekday for a delivery date. The range begins the day after tomorrow, and is available for 90 days.

global class cc_example_api_DeliveryDateWeekdays extends ccrz.cc_apiDeliveryDate{
    global override Map<String, Object> getDeliveryDates(Map<String, Object> deliveryDatesInputData) {
        return new Map<String, Object> {
            ccrz.cc_api_DeliveryDate.OFFSET => 2,
            ccrz.cc_api_DeliveryDate.DURATION => 90,
            ccrz.cc_api_DeliveryDate.EXCLUDED_DATES => new List<String>{'* * * 0,6'}
        };
    }
}

The value '* * * 0,6' uses syntax for the disabled_dates parameter of the zebra_datepicker.js library. The cc_CheckoutShippingRD.component Visualforce component converts these values for the corresponding datesDisabled option of the bootstrap-datepicker.js library.

Tip