Skip to main content

Advanced Settings

Templates

One of the Expivi plugin's powerful features is overriding a template. The plugin uses templates to render a page or section, like the product page or the product details of a cart item.

Certain parts of the plugin will help you automatically generate/prepare a template, but below, you will find a list of all templates that can be overridden:

Catalogue

TemplateDescription
/catalogue/product_item_details.phtmlTemplate for rendering the 'Configure product' button shown in Shop/Catalogue.

Viewer

TemplateDescription
/viewer/viewer.phtmlTemplate for rendering the Product Title, Viewer container, and Price container (only if price position is set to Top).
/viewer/configurator.phtmlTemplate for rendering Options panel container, PDF Generation button, Price container (only if price position is set to Bottom), and container for error messages.

Cart

TemplateDescription
/cart/cart.phtmlAltered WooCommerce Template for rendering product details on generated (bundled) products in the cart.
/cart/cart_sub_product_item.phtmlAltered WooCommerce Template for rendering Sub-Products of generated (bundled) products in the cart.
/cart/product_item_details.phtmlTemplate for rendering product details in the cart.

Checkout

TemplateDescription
/checkout/review-order.phtmlAltered WooCommerce Template for rendering product details on generated (bundled) products during checkout.

Save Design

TemplateDescription
/save-design/expivi_save_design_follow_up.phtmlTemplate for rendering the follow-up modal.
/save-design/expivi_save_design_connect_rep.phtmlTemplate for rendering the follow-up button to forward the design to the representative.
/save-design/expivi_save_design_form_fields.phtmlTemplate for rendering the Save My Design form fields.
/save-design/expivi_save_design_share_link.phtmlTemplate for rendering the share link copy button.
/save-design/expivi_save_design_success_message.phtmlTemplate for rendering success message (+ follow-up) after Save Design modal.

PDF

TemplateDescription
/pdf/pdf-configuration-details.phtmlTemplate for rendering the PDF Generation.

Emails

TemplateDescription
/emails/email_order_item_details.phtmlTemplate for rendering Order Item details of a product in email.
/emails/email_order_item_image.phtmlTemplate for rendering Order Item image of a product in email.
/emails/save-design/email_save_design_content.phtmlTemplate for rendering the "Save Design" form in the email.
/emails/base-email/email_layout.phtmlTemplate to render a base email ("head", "header", "content", "footer", "foot").
/emails/base-email/email_head.phtmlTemplate to render head in email (Currently only used by "Save Design" / "Connect to Representative" feature).
/emails/base-email/email_header.phtmlTemplate to render header in the email (Currently only used by "Save Design" / "Connect to Representative" feature).
/emails/base-email/email_footer.phtmlTemplate to render footer in email (Currently only used by "Save Design" / "Connect to Representative" feature).
/emails/base-email/email_foot.phtmlTemplate to render footer in email (Currently only used by "Save Design" / "Connect to Representative" feature).
/connect-rep/email_connect_rep_content.phtmlTemplate for rendering the "Connect to Representative" form in the email.

It is recommended to copy the template from the Expivi plugin folder (/expivi/templates/) as it will contain documentation of the available variables. The template should be copied to the active theme and placed in an /expivi folder. The template file should also follow the same folder structure described in the list. If the templates are not being overridden, the path may be incorrect.

Example: /wp-content/themes/{active-theme}/expivi/viewer/viewer.phtml

warning

Only override the templates that you want to change. Currently, no theme manager or version control exists, meaning the Expivi plugin will not notify you when it requires template changes. Always check the Expivi plugin release notes to verify if any template changes are required to keep your template up-to-date.

Hooks

The Expivi plugin provides a list of hooks that will help developers override/alter specific data.

List of filters

expivi_plugin_initialized

Ability to do something once the Expivi plugin is initialized.

functions.php - expivi_plugin_initialized
/**
* @param bool $initialized
*/
add_filter('expivi_plugin_initialized', function( bool $initialized ) {
// Apply your logic here.
return $initialized;
});

xpv_get_locale

Ability to override the locale, which is needed to select the correct translation defined in Backoffice. (Example: en-US)

functions.php - xpv_get_locale
/**
* @param string $locale Locale used by the Expivi plugin's internal workings. Default = `en-US`.
*/
add_filter('xpv_get_locale', function( string $locale ) {
// Change $locale here.
return $locale;
});

xpv_get_country

Ability to override the country, which is needed to select the correct price defined in Backoffice. (Example: us)

functions.php - xpv_get_country
/**
* @param string $country Country used by Expivi plugin internal workings. Default = `us`.
*/
add_filter('xpv_get_country', function( string $country ) {
// Change $country here.
return $country;
});

expivi_viewer_before_loading

Ability to alter the options provided to the /viewer/viewer.phtml template.

functions.php - expivi_viewer_before_loading
/**
* @param array $options {
* @var string $token API key (from settings).
* @var string $upload_url Upload url (from settings).
* @var string $price_selector Price selector (from settings).
* @var int $catalogue_id Identifier of product from Backoffice.
* @var string $locale String of locale (Example: 'en-US').
* @var string $country String of country (Example: 'us').
* @var string $currency Get base currency code (`get_woocommerce_currency()`).
* @var int $currency_decimals Returns the number of decimals after the decimal point (`wc_get_price_decimals()`).
* @var string $bundle_uuid UUID of the bundle.
* @var ?array $pre_configuration JSON pre-configuration of the product. This is used for Social Sharing, Save Design, (cart) session, or pre-configured from product.
* @var bool $show_3d_hover_icon Show 3d hover icon (from settings).
* @var bool $auto_rotate_product Option whether the product should rotate automatically on startup (from settings).
* @var bool $show_progress Show progress bar (from settings).
* @var bool $show_options Show options panel (from settings).
* @var bool $hide_price Hide price (from settings).
* @var bool $hide_price_when_zero Only show price when the amount exceeds zero (from settings).
* @var bool $auto_scroll_stepper Automatically scroll to the next step upon closing the stepper (from settings).
* @var string $ajax_url Ajax url used for JS scripts. @deprecated.
* }
*/
add_filter('expivi_viewer_before_loading', function( array $options ) {
// Change $options here.
return $options;
});

expivi_product_validation

Ability to validate (Expivi) products before they are added to the cart. This hook allows you to block products from being added to the cart.

functions.php - expivi_product_validation
/**
* @param bool $is_valid
* @param WC_Product $product WooCommerce product.
* @param array $configured_product Configured Expivi product.
*/
add_filter('expivi_product_validation', function( bool $is_valid, WC_Product $product, array $configured_product ) {
// Apply validation here.
// Change `$is_valid` to false to block products being added to the cart.
return $is_valid;
});

List of filters (global)

The plugin also provides valuable filters that can be seen as global functions. The hooks can be called upon at any time and will help parse/extract data without the need to implement this functionality yourself.

expivi_wc_get_configurations_from_order

A helpful way to extract multiple configured Expivi products (configurations) from an order.

functions.php - expivi_wc_get_configurations_from_order
/**
* @param WC_Order $order
* @returns array|false List of configured products, or false when something failed.
*/
$configurations = apply_filters( 'expivi_wc_get_configurations_from_order', $order );

expivi_wc_get_configuration_from_order_item

A helpful way to extract the configured Expivi product (configuration) from a single order.

functions.php - expivi_wc_get_configuration_from_order_item
/**
* @param WC_Order_Item $order_item
* @returns array|false Configured product, or false when something failed.
*/
$configuration = apply_filters( 'expivi_wc_get_configuration_from_order_item', $order_item );

expivi_wc_save_configured_product_bundle_in_order_item

Ability to save the configuration of an order item

functions.php - expivi_wc_save_configured_product_bundle_in_order_item
/**
* @param WC_Order_Item $order_item
* @param bool $force Force to create new identifier.
* @returns int|false Configured product bundle identifier, or false when something failed.
*/
$configuration = apply_filters( 'save_configured_product_bundle_in_order_item', $order_item, $force );

List of actions

expivi_scripts_loaded

Ability to do something after Expivi scripts and data have been initialized on the Product page.

functions.php - expivi_scripts_loaded
/**
* @param WC_Product $product
*/
add_action('expivi_scripts_loaded', function( $product ) {
// Do something here after scripts are initialized but before the viewer template is rendered.
});

expivi_title

Ability to add HTML next to the Product Title of Expivi product. This action is linked to woocommerce_template_single_title. You also have the ability to remove the original action and override it with your own implementation.

functions.php - expivi_title
/**
* Remove original hook.
*/
remove_action( 'expivi_title', 'woocommerce_template_single_title', 5 );

/**
* Implement Title for Product.
*/
add_action('expivi_title', function() {
wc_get_template( 'single-product/title.php' );
});

expivi_price

Ability to add HTML nex to the price container. This action is linked to woocommerce_template_single_price. You also have the ability to remove the original action and override it with your own implementation.

functions.php - expivi_price
/**
* Remove original hook.
*/
remove_action( 'expivi_price', 'woocommerce_template_single_price', 10 );

/**
* Implement Price for Product.
*/
add_action('expivi_price', function() {
wc_get_template( 'single-product/price.php' );
});
note

We generally do not recommend using the hooks that start with xpv_ as they are used mainly for internal components. Misusing the internal hooks might result in the plugin not working correctly.