1. Documentation /
  2. WooCommerce Square: Startup Guide /
  3. Customizing WooCommerce Square Extension

Customizing WooCommerce Square Extension

We ensure that the WooCommerce Square Extension is user-friendly, while also providing you with the necessary tools to tailor the extension to fit the specific requirements of your WooCommerce store and its customers.

For those interested in customizing the WooCommerce Square Extension, we have gathered a list of frequently requested modifications at the developer level here.

NOTE: We are unable to provide support for customizations under our Support Policy. If you need assistance with custom code, we highly recommend Codeable or a Certified WooExpert.

Translating Credit card fields

↑ Back to top

To translate Square we need to take the .pot language files from wp-content/plugins/woocommerce-square/i18n/languages and use this to generate 2 new language files. Following that you should end up with language files like the following, replacing the {locale} placeholder with the appropriate one.

  • woocommerce-square-{locale}.mo
  • woocommerce-square-{locale}.po

Place the two translation files under /wp-content/languages/plugins/

Import HTML in Product Descriptions

↑ Back to top

By default, item descriptions are stripped from all HTML tags to plain text during import. To allow HTML in the imported descriptions, you can use the woocommerce_square_create_product_data filter:

/**
 * Enable HTML descriptions during Square import
 *
 * @param array $data Product data.
 * @param SquareConnectModelCatalogObject $catalog_object The catalog object from the Square API.
 * @param WooCommerceSquareSyncProduct_Import $product_import Import class instance.
 *
 * @return array
 */
function my_square_enable_html_description( $data, $catalog_object, $product_import ) {
    $data['enable_html_description'] = true;
    return $data;
}
add_filter( 'woocommerce_square_create_product_data', 'my_square_enable_html_description', 10, 3 );

Change Automatic Sync Interval

↑ Back to top

You can modify the frequency of automatic synchronization by adjusting the wc_square_sync_interval filter. This interval is measured in seconds, with the default setting being one hour. This default frequency is advised for the majority of sites, particularly those hosting extensive product catalogs. You can change the Sync Interval time from predefined values under WooCommerce > Settings > Square.

Here’s a sample of how you can change the sync interval using code:

// sync every 15 minutes instead of every hour

add_filter('wc_square_sync_interval', function () {
    return MINUTE_IN_SECONDS * 15;
} );

Remove Apple Pay and Google Pay buttons from either the Single Product, Cart, or Checkout page

↑ Back to top

By default, digital wallets (Apple Pay and Google Pay) will be displayed on all Single Product pages, the Cart page, and the Checkout page.

To remove them from one or more of these pages, you can use the snippet below. The below snippet removes the digital wallets from the product page.

add_filter( 'wc_square_display_digital_wallet_on_pages', function( $pages ) {
	return array(
		/* 'product', // Don't show Apple Pay and Google Pay on product pages */
		'cart',
		'checkout',
	);
}, 10, 1 );