TM WooCommerce Compare & Wishlist
WooCommerce Compare
WooCompare allows you to compare products based on product properties. Add the desired products to the product comparison page by clicking "Add to compare" button on the product or product catalog pages. WooCompare also includes a widget that lets you output the products added to the comparison list. Using this widget you can also delete the products, empty the comparison list, or go to the product comparison page.
The TM Compare settings page offers the following options:
-
- Enable compare
- Enable/disable compare functionality.
-
- Select compare page
- Choose the page to display the compare page.
-
- Show in catalog
- Display the "Add to compare" button in the products list.
-
- Show in products page
- Display the "Add to compare" button on the product page.
-
- Compare button text
- Specify the compare button text.
-
- Remove button text
- Specify the Remove button text.
-
- Empty compare list text
- Text displayed on the Compare page or in the widget of products added to the compare list if the compare list is empty.
-
- Page Template
- Choose a proper page template.
-
- Widget template
- Choose a proper widget template.
You can also use the widget that allows to display the products added to the compare list, remove them, clear the list and navigate to the compare page.
Data will be dynamically updated in all sections and the product added in the listing will be automatically added to the widget and to the compare page.
Customize functionality with hooks
-
- add_action( 'woocommerce_after_shop_loop_item', 'tm_woocompare_add_button', 12 )
- The hook adds the Add to Compare or Remove button in the product list.
-
- add_action( 'woocommerce_single_product_summary', 'tm_woocompare_add_button', 35 );
- The hook adds the Add to Compare or Remove button on the product page.
-
- apply_filters( 'tm_woocompare_preloader', '' )
- The hook allows to add a custom preloader to the Add Product or Remove button.
-
- apply_filters( 'tm_woocompare_list_loader', $loader )
- The hook allows to change the compare tables and widgets preloader.
-
- apply_filters( 'tm_woocompare_button', $html, $classes, $id, $nonce, $text, $preloader )
- "Add to compare" button display filter
-
- apply_filters( 'tm_woocompare_page_button', $html, $classes, $link, $text )
- "View compare" button display filter
-
- apply_filters( 'tm_woocompare_dismiss_icon', '<span class="dashicons dashicons-dismiss">' )
- Delete button display filter
-
- apply_filters( 'tm_woocompare_empty_message', $html, $empty_text )
- Message display filter if compare list is empty
-
- apply_filters( 'tm_woocommerce_list_product_title', $html, $link, $title, $product )
- Product title display filter
-
- apply_filters( 'tm_woocommerce_list_product_image', $html, $link, $image )
- Product image display filter
Shortcode Options
The templates are are gathered in templates\shortcodes\tm-woocompare\ folder. You can rewrite the templates by copying them to the uploads\templates\shortcodes\tm-woocompare\ folder or to the woocommerce\shortcodes\tm-woocompare\ folder inside the theme. You can also change the names of the templates.
Compare page templates
The default table template on the compare page - page.tmpl. The template supports the following macros:
-
- %%TITLE%%
- Display product title.
-
- %%IMAGE%%
- Display the product picture. Supports the following attributes:
-
- size
- Image size. Supports names of image size presets. For example %%IMAGE size="shop_thumbnail"%%. shop_thumbnail by default.
-
- placeholder
- Defines whether to display a cover picture if the product doesn’t have one. Takes true|false. true by default.
-
- %%ADDTOCART%%
- Display “Add to Cart” button.
-
- %%PRICE%%
- Display product price.
-
- %%ATTRIBUTES%%
- Display product attributes. Supports the following attributes:
-
- atts
- The list of comma separated attributes. For instance %%ATTRIBUTES atts="color, size"%% All attributes are displayed by default.
Widget template
Default table template on a compare page - widget.tmpl
The template supports the following macros:
-
- %%TITLE%%
- Display product title.
-
- %%IMAGE%%
- Display the product picture. Supports the following attributes:
-
- size
- Image size. Supports names of image size presets. For example %%IMAGE size="shop_thumbnail"%%. shop_thumbnail by default.
-
- placeholder
- Defines whether to display a cover picture if the product doesn’t have one. Takes true|false. true by default.
-
- %%ADDTOCART%%
- Display “Add to Cart” button.
-
- %%PRICE%%
- Display product price.
[tm_woo_compare_table] shortcode is added to the "Compare" page (if the page is absent in database it will be created automatically). This page is added to the Select compare page plugin option.
If the page exists, [tm_woo_compare_table] shortcode will be added to the page content. If the shortcode is already inserted, no changes will be made.