Skip to main content

PHP Filters

ShopWP comes with filter hooks that can be used to customize the plugin. Simply add these to your WordPress theme's functions.php file.

shopwp_products_all_args​

Allows you to customize the settings used by the default products listing (PLP) page

ParameterDescription
$settingsRepresents all available product settings. A full list can be found here.

Example

// Sort products by newest first
add_filter('shopwp_products_all_args', function($settings) {

$settings['sort_by'] = 'created_at';

return $settings;

});

shopwp_products_single_args​

Allows you to customize the settings used by the product detail (PDP) pages

ParameterDescription
$settingsRepresents all available product settings. A full list can be found here.

Example

// Link products to Shopify on the detail pages only
add_filter('shopwp_products_single_args', function($settings) {

$settings['link_to'] = 'shopify';

return $settings;

});

shopwp_products_single_reviews_args​

Allows for customizing the settings used by the reviews component on product detail pages.

ParameterDescription
$settingsRepresents all available product reviews settings. A full list can be found here.

Example

// Disable the ability for users to add new reviews
add_filter('shopwp_products_single_reviews_args', function($settings) {

$settings['show_create_new'] = false;

return $settings;

});

shopwp_register_products_args​

Allows you to customize the custom post type settings of ShopWP products.

ParameterDescription
$settingsRepresents the default custom post type settings. A full list can be found here.

Example

// Turn off the archive pages for ShopWP Products
add_filter('shopwp_register_products_args', function($settings) {

$settings['has_archive'] = false;

return $settings;

});

shopwp_products_show_sidebar​

Allows you to toggle the WordPress sidebar on the products listing page.

ParameterDescription
$show_sidebar (bool)Whether to show a WordPress sidebar on the products listing page. Default: true

Example

add_filter('shopwp_products_show_sidebar', function($use_plugin_template) {
return false;
});

shopwp_use_products_all_template​

Allows you to turn off the default products archive template. Useful if you want to use your own wordpress templates.

ParameterDescription
$use_plugin_template (bool)Represents whether to use default products archive template. Default: true

Example

add_filter('shopwp_use_products_all_template', function($use_plugin_template) {
return false;
});

shopwp_use_products_single_template​

Allows you to turn off the default products single template. Useful if you want to use your own wordpress templates.

ParameterDescription
$use_plugin_templateRepresents whether to use default products single template. Default: true

Example

add_filter('shopwp_use_products_single_template', function($use_plugin_template) {
return false;
});

shopwp_admin_rest_api_version​

Allows you to specify a custom API version for the Shopify Admin REST API

ParameterDescription
$api_versionRepresents the default API version

Example

add_filter('shopwp_admin_rest_api_version', function($api_version) {
return '2022-07';
});

shopwp_collections_all_args​

Allows you to customize the settings used by the default collections listing page.

ParameterDescription
$settingsRepresents all available collection settings. A full list can be found here.

Example

// Don't show collection images or products on listing page
add_filter('shopwp_collections_all_args', function($settings) {

$settings['excludes'] = ['images', 'products'];

return $settings;

});

shopwp_collections_single_args​

Allows you to customize the settings used by the collection detail pages.

ParameterDescription
$settingsRepresents all available collection settings. A full list can be found here.

Example

// Sort products by price
add_filter('shopwp_collections_single_args', function($settings) {

$settings['products_sort_by'] = 'price';

return $settings;

});

shopwp_register_collections_args​

Allows you to customize the custom post type settings of ShopWP collections.

ParameterDescription
$argsRepresents the default custom post type settings. A full list can be found here.

Example

// Turn off the archive pages for ShopWP Products
add_filter('shopwp_register_collections_args', function($args) {

$args['has_archive'] = false;

return $args;

});

shopwp_register_layout_builder_args​

Allows you to customize the custom post type settings of the ShopWP layout builder post type

ParameterDescription
$argsRepresents the default custom post type settings. A full list can be found here.

Example: Turn off third-party metaboxes

add_filter('shopwp_register_layout_builder_args', function($args) {

$args['publicly_queryable'] = false;

return $args;

});

shopwp_register_shopify_collections_tax​

Allows for customizing the collections taxonomy registration.

ParameterDescription
$argsRepresents the default taxonomy settings. A full list can be found here.

Example

// Turn off the archive pages for ShopWP Products
add_filter('shopwp_register_shopify_collections_tax', function($args) {

$args['description'] = 'Custom taxonomy description';

return $args;

});

shopwp_use_collections_all_template​

Allows you to turn off the default collections archive template. Useful if you want to use your own wordpress templates.

ParameterDescription
$use_plugin_templateRepresents whether to use default collections archive template. Default: true

Example

add_filter('shopwp_use_collections_all_template', function($use_plugin_template) {
return false;
});

shopwp_use_collections_single_template​

Allows you to turn off the default collections single template. Useful if you want to use your own wordpress templates.

ParameterDescription
$use_plugin_templateRepresents whether to use default collections single template. Default: true

Example

add_filter('shopwp_use_collections_single_template', function($use_plugin_template) {
return false;
});

shopwp_cart_default_settings​

Allows you to customize the default settings for the ShopWP cart.

ParameterDescriptionDefaultType
iconSpecified the cart icon.falsestring
show_counterWhether to show the cart icon counter.truebool
icon_colorThe color of the default cart icon.#000string
background_colorThe background color of the fixed cart icon tab.#000string
counter_background_colorThe background color of the cart counter.#6ae06astring
counter_text_colorThe text color of the cart counter.#FFFstring
show_inventory_levelsWhether to show the inventory levels of each cart line item.truebool
left_in_stock_thresholdIf showing inventory levels, determines the threshold before a "low stock" notice shows.10int
cart_titleThe shopping cart title.Shopping cartstring
checkout_textThe text of the checkout button.Begin checkoutstring
updating_textThe text shown during cart updates.Updating...string
checkout_failed_messageThe text shown when the checkout fails.Unable to checkout. Please reload the page and try again.string
lineitem_remove_textThe text shown for removing a lineitem.Removestring
lineitem_sale_label_textThe sale text shown for lineitems.Salestring
lineitems_disable_linkWhether to disable linking line items to their PDP pages.falsebool
lineitems_link_targetDetermines how line item links should open._selfstring
lineitems_max_quantityThe maximum number of items you can purchase per line item.falseint
lineitems_min_quantityThe minimum number of items you can purchase per line item.falsebool
lineitems_quantity_stepThe number by which the quantity changes in increments.falseint
notes_labelThe label above the cart notes field.Checkout notesstring
notes_placeholderThe placeholder text shown within the cart notes field.Enter note for checkoutstring
notes_update_frequencyHow quickly the cart should update when entering a note450int
empty_cart_textThe text to show when the cart is emptyYour cart is emptystring
subtotal_label_textThe text to show next to the cart subtotal amount.Subtotal:string
show_cart_close_iconWhether to show the close icon within the ShopWP carttruebool
show_cart_titleWhether to show the cart title within the ShopWP carttruebool
max_quantityControls the total max quantity that users can addfalsebool
languageThe language of the cartENbool
countryThe country of the cartUSbool
currencyThe currency of the cartUSDbool

Example: Customize the shopping cart title

add_filter('shopwp_cart_default_settings', function($settings) {

$settings['show_cart_title'] = 'Custom cart title';

return $settings;

});

shopwp_collections_default_settings​

Allows you to customize the default collections settings.

For a full list of available settings, reference the attributes of the [wps_collections] shortcode.

This filter will be applied "globally" to every instance of a collection, whether single or in a list.

ParameterDescription
settings (array)Represents all available settings for collections

Example

// Exclude the collection descriptions from the layout
add_filter('shopwp_collections_default_settings', function($settings) {

$settings['excludes'] = ['description'];

return $settings;

});

shopwp_products_default_settings​

Allows you to customize default product settings.

For a full list of available settings, reference the attributes of the [wps_products] shortcode.

This filter will be applied "globally" to every instance of a product whether single or in a list.

ParameterDescription
settings (array)Represents all available settings for products

Example

// Set the product title to "green"
add_filter('shopwp_products_default_settings', function($settings) {

$settings['title_color'] = 'green';

return $settings;

});

shopwp_search_default_settings​

Allows you to customize default search settings.

For a full list of available settings, reference the attributes of the [wps_search] shortcode.

ParameterDescription
settings (array)Represents all available search settings

Example

// Set the product title to "green"
add_filter('shopwp_search_default_settings', function($settings) {

$settings['title_color'] = 'green';

return $settings;
});

shopwp_storefront_default_settings​

Allows you to customize the default storefront options.

ParameterDescription
$settingsRepresents the default storefront options

Example

add_filter('shopwp_storefront_default_settings', function($settings) {

$settings['collections_heading'] = 'New collections heading';
$settings['price_heading'] = 'New price heading';
$settings['tags_heading'] = 'New tags heading';
$settings['types_heading'] = 'New type heading';
$settings['vendors_heading'] = 'New vendors heading';

return $settings;
});

shopwp_translator_default_settings​

Allows you to customize the default translator settings

ParameterDescription
$settingsRepresents the default translator settings

Example

add_filter('shopwp_translator_default_settings', function($settings) {
return $settings;
});

shopwp_reviews_default_settings​

Allows for customizing the default reviews settings.

ParameterDescription
$settings (array)The default Yotpo reviews settings

Example

// Change the language to German
add_filter('shopwp_reviews_default_settings', function($settings) {

$settings['reviews_shown'] = 60;

return $settings;

}, 10, 2);

shopwp_show_breadcrumbs​

Allows you to hide / show the ShopWP breadcrumbs.

ParameterDescription
$show_breadcrumbs (bool)Whether to show breadcrumbs. Default: false

Example:

add_filter('shopwp_show_breadcrumbs', function($show_breadcrumbs) {
return false;
});

Determines whether to flush permalinks after syncing.

ParameterDescription
$should_flush (bool)Represents whether to skip compatibility mode. Default: false

Example

add_filter('shopwp_flush_permalinks_after_sync', function($should_flush) {
return false;
});

shopwp_skip_compatibility​

Allows you to turn off compatibility mode. Useful if you're running into errors.

ParameterDescription
should_skipRepresents whether to skip compatibility mode. Default: false

Example

add_filter('shopwp_skip_compatibility', function($should_skip) {
return true;
});

shopwp_keep_active_whitelist​

Allows for customizing which plugins are kept active during the ShopWP syncing process. Useful for fixing any plugin conflicts that result from the ShopWP sync.

ParameterDescription
$plugins (array)Represents an array of plugin basenames

Example


// Allows the plugin "ocm-site-framework" to remain activated during the ShopWP sync
add_filter('shopwp_keep_active_whitelist', function($plugins) {

$plugins[] = 'ocm-site-framework/ocm-site-framework.php';

return $plugins;

});

shopwp_keep_active_theme​

Allows for keeping your theme activate during a ShopWP sync. Normally ShopWP will switch to am "empty theme" during sync to prevent any conflicts. Returning true will tell ShopWP not to switch themes.

Note: this switch only occurs for requests made to the server so your theme will remain active on the front-end.

ParameterDescription
$keep_theme_active (boolean)Whether ShopWP will switch to an empty theme during sync

Example

function keep_theme_active($keep_theme_active) {
return false;
}

add_filter('shopwp_keep_active_theme', 'keep_theme_active');

shopwp_get_collections_query_params​

Allows for customizing the query params used when fetching collections for the Storefront component

ParameterDescription
$settingsRepresents the query params

Example

add_filter('shopwp_get_collections_query_params', function($settings) {

$settings['first'] = 40;

return $settings;

});

shopwp_show_dashboard​

Allows for customizing whether the ShopWP admin settings are visible or not

ParameterDescription
$should_show (bool)Whether to show the ShopWP dashboard
$user (object)The current WordPress user

Example

// Hides the ShopWP dashboard
add_filter('shopwp_show_dashboard', function($should_show, $user) {
return false;
}, 10, 2);

shopwp_settings​

Allows for customizing the main ShopWP settings object, programmatically.

ParameterDescription
$settings (array)The default ShopWP settings

Example

// Change the ShopWP cache length
add_filter('shopwp_settings', function($settings) {

$settings['general']['data_cache_length'] = 1000;

return $settings;

}, 10, 2);

shopwp_skip_bulk_webhook_ver​

Allows for overriding the syncing verification process. Useful if you're experiencing this syncing error.

ParameterDescription
$default_val (boolean)Defaults to false

Example

add_filter('shopwp_skip_bulk_webhook_ver', function($default_val) {
return true;
});

shopwp_buyer_identity_language​

Allows for customizing the language used for ShopWP content. Very useful for translating content on the fly with other translation plugins like G Translate.

ParameterDescription
$default_lang (string)Defaults to your WP site language

Example Use the language set by G Translate for ShopWP content

function customize_lang_for_shopwp($default_lang) {
return isset($_SERVER['HTTP_X_GT_LANG']) ? $_SERVER['HTTP_X_GT_LANG'] : 'en';
}

add_filter('shopwp_buyer_identity_language', 'customize_lang_for_shopwp');

Example Use the language set by Polylang for ShopWP content, else use default WP language

function customize_lang_for_shopwp($default_lang) {

if (!function_exists('pll_current_language')) {
return \get_bloginfo("language");
}

return \pll_current_language();
}

add_filter('shopwp_buyer_identity_language', 'customize_lang_for_shopwp');

Example Use the language set by WPML

function customize_lang_for_shopwp($default_lang) {

$my_current_lang = apply_filters('wpml_current_language', NULL);

if ($my_current_lang) {
return $my_current_lang;
}

return $default_lang;
}

add_filter('shopwp_buyer_identity_language', 'customize_lang_for_shopwp');
// If the translation plugin also modifies the URL, we need to update the ShopWP URLs to reflect this
wp.hooks.addFilter(
'misc.linkHref',
'shopwp',
function (linkHref, linkTo, payload) {
if (shopwp.misc.siteLang !== 'en') {
linkHref = linkHref.replace(
'/products/',
'/' + shopwp.misc.siteLang + '/products/'
)
}

return linkHref
}
)