Table of Contents

Custom Shipping Code API

The following are functions that are available for use within the Custom Shipping Code functionality available for Foxy stores.

Notes


add(id, price, carrier, service_name)

Add an additional shipping option

Parameters:

Returns: Rates - The current rates object with the new rate included

Errors:

Examples:

Notes:


filter(selector)

Filters the current rates object using the provided selector

Parameters:

Returns: Rates - A new rates object, filtered based on the provided selector

Examples:

Notes:


hide()

Set the rates in the current object to be hidden, preventing them from returning to the customer

Returns: Rates - The current rates object

Examples:

Notes:


show()

Set the rates in the current object to be shown, ensuring they're returned to the customer

Returns: Rates - The current rates object

Examples:


exists(selector)

Checks if rates exist in the current rates object, or if a given selector is present if one is passed

Returns: Boolean - true or false depending if any matching rates are found

Parameters:

Examples:

Notes:


count()

The number of rates in the current rates object

Returns: Int - The number of rates in the current rates object

Examples:


id()

Get the current rate's ID

Returns: Int - The ID of the current rate

Examples:

Notes:


id(value)

Set the current rate's ID

Parameters:

Returns: Rates or Rate - Either the individual rate or current rates object

Errors:

Examples:

Note:


price()

Get the current rate's price

Returns: Float - The price of the current rate

Examples:

Notes:


price(modifier)

Set the current rate or rate's price

Parameters:

Returns: Rates or Rate - Either the individual rate or current rates object

Examples:

Notes:


carrier()

Get the current rate's carrier name

Returns: String - The carrier of the current rate

Examples:

Notes:


carrier(value)

Set the current rate's carrier name

Parameters:

Returns: Rates or Rate - Either the individual rate or current rates object

Errors:

Examples:


service()

Get the current rate's service name

Returns: String - The service name of the current rate

Examples:

Notes:


service(value)

Set the current rate's service name

Parameters:

Returns: Rates or Rate - Either the individual rate or current rates object

Errors:

Examples:


each(function)

Iterate over the current rates object, executing a function on each individual rate.

Parameters:

Returns: Rates - The current rates object

Examples:

Notes:


first()

Returns the first shipping rate from the current object

Returns: Rate - An individual Rate object

Examples:


last()

Returns the last shipping rate from the current object

Returns: Rate - An individual Rate object

Examples:


sort(direction)

Sorts the current rates object by price, allowing you to sort the rates into a known order when interacting with them in your custom code.

Parameters:

Returns: Rates - The current rates object

Examples:

Notes:


addHandling()

Adds the category handling fees to the current rates

Returns: Rates or Rate - Either the individual rate or current rates object

Examples:

Notes:


removeHandling()

Removes the category handling fees from the current rates

Returns: Rates or Rate - Either the individual rate or current rates object

Examples:

Notes:


addFlatRate()

Adds flat rate shipping fees if present from other categories in the cart to the current rates

Returns: Rates or Rate - Either the individual rate or current rates object

Examples:

Notes:


removeFlatRate()

Removes flat rate shipping fees if present from other categories in the cart from the current rates

Returns: Rates or Rate - Either the individual rate or current rates object

Examples:

Notes:


addHandlingAndFlatRate()

Adds the category handling and flat rate shipping fees if present from other categories in the cart to the current rates

Returns: Rates or Rate - Either the individual rate or current rates object

Examples:

Notes:


removeHandlingAndFlatRate()

Removes the category handling and flat rate shipping fees if present from other categories in the cart from the current rates

Returns: Rates or Rate - Either the individual rate or current rates object

Examples:

Notes:


removeDayTimeframes()

Removes the “1-Day”, “2-Day” etc text from service names for the current rates

Returns: Rates or Rate - Either the individual rate or current rates object

Examples:

Notes:


error()

Get the error message for the shipping rates

Returns: String or Boolean - The current error message, or false if none set

Examples:


error(message)

Set the error message for the shipping rates

Parameters:

Returns: Rates - The current rates object

Examples:

Notes:


reset()

Resets the shipping rates and error message to blank

Returns: Rates - An empty rates object

Examples:

Notes: