Advanced Configuration

This section outlines the advanced configuration options related to the Cash App Afterpay WooCommerce integration and site-specific customisation.

The Cash App Afterpay Gateway for WooCommerce plugin is available for extension or customisation, without alterations to the plugin code.

This allows for a greater level of compatibility with future updates.

Advanced Configuration is divided into the following sections:

Hooks

Product Eligibility

The Cash App Afterpay plugin runs a series of checks to determine whether Cash App Afterpay should be an available payment option for each individual product. Third-party plugins can exclude Cash App Afterpay from products that would otherwise be considered supported. To fix the exclusion problem, attach the following filter hook:
afterpay_is_product_supported

Example

1/**
2 * @param bool $bool_result
3 * @param WC_Product $product
4 */
5function afterpay_ips_callback( $bool_result, $product ) {
6 # My custom products don't support Afterpay.
7 if ($product->get_type() == 'my-custom-product-type') {
8 $bool_result = false;
9 }
10 return $bool_result;
11}
12add_filter( 'afterpay_is_product_supported', 'afterpay_ips_callback', 10, 2 );

Customising Hooks & Priorities

Various WooCommerce hooks are assumed to be implemented by the active WordPress theme. Cash App Afterpay methods can be detached from their default hooks and reattached to different hooks, or to the same hooks with different priorities.

Since version 2.1.0, hooks and priorities can be customised from within the plugin settings page.

hook-1.png

Shortcodes

This section outlines the shortcodes utilised by the Cash App Afterpay WooCommerce integration.

This is provided for rendering an advanced img tag to display the Cash App Afterpay logo on individual product pages. The img tag uses the srcset attribute to include 3 different resolutions of the logo for screens with varying pixel density ratios.

1[afterpay_product_logo]

There are 3 different versions of the logo to chose from:

  • colour
  • black
  • white

The default theme is colour. This can be overridden by including a theme attribute inside the shortcode. For example, if you have a dark themed website and wish to use the white mono version of the Cash App Afterpay logo:

1[afterpay_product_logo theme="white"]

Cash App Afterpay Product Messaging

To use the shortcode on product pages, please make sure the Payment Info on Individual Product Pages has been enabled. Edit the text content as appropriate. Optionally, clear the hook name if you would like to disable the default behaviour of rendering the content when the hook is triggered. Instead, the content will then only render wherever the shortcode is added.

shortcode-1.png

Then paste [afterpay_paragraph] into the product description, or into a content area using your page builder.

shortcodes-2.png

shortcodes-3.png

To use the shortcode on custom pages, provide a product ID in the shortcode:

1[afterpay_paragraph id="99"]

shortcodes-4.png