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_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
$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_collections_args', function($settings) {

$settings['has_archive'] = false;

return $settings;

});

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
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

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_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_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);