The WooCommerce plugin offers various hooks and filters to customize its behavior. To override the functionality, add code to your theme's functions.php file.

Filters

  • partially_gateway_offer string the offer ID to use when creating a payment plan for gateway checkout
  • partially_widget_config array PHP array of options for the partially-widget
  • partially_widget_container_html string raw HTML to use as the container for the widget
  • partially_button_cart_offer string the offer ID to use when creating a checkout button on the cart page
  • partially_button_cart_config array PHP array of options for the checkout button on the cart page
  • partially_button_product_offer string offer ID to use when creating a checkout button on the product landing page
  • partially_button_product_config array PHP array of options for the checkout button on the product page
  • partially_button_product_container_html string HTML to use as the container for checkout button on the product page

Examples

Following are a few examples of common scenarios, which you can add to your theme's functions.php file.

Change offer based on order total

The following example shows how you might change the offer used during checkout if the cart total is over $500. You may want to offer different terms depending on the order amount, which you can use different offers for. Be sure to change the value and offer IDs to match your needs.

function custom_partially_gateway_offer($default_offer) {
    if ( WC()->cart->total > 500) {
        return '<custom offer ID>';
    }
    else return $default_offer;
}
add_filter('partially_gateway_offer', 'custom_partially_gateway_offer');

Enable widget based on product tag

Perhaps you only want the Partial.ly widget to only display on product pages tagged with the tag partially-widget. Adding the following code would cause the widget to only display on product pages with that tag.

function custom_partially_widget_settings($settings) {
    $settings['render'] = false;
    $tags = get_the_terms( get_the_ID(), 'product_tag' );
    if ($tags) {
        foreach ($tags as $tag) {
            if ($tag->name == 'partially-widget') $settings['render'] = true;
        }
    }
    return $settings;
}
add_filter('partially_widget_config', 'custom_partially_widget_settings');