“Woocommerce Products Wizard” Documentation by “troll_winner” for the plugin version 8.5.0

“Woocommerce Products Wizard”

By: troll_winner
Email: troll_winner@mail.ru

If you have any questions that are beyond the scope of this help file, please feel free to email troll_winner@mail.ru.

Table of Contents

  1. About
  2. Main settings
  3. Post Settings
  4. Product Settings
  5. Category Settings
  6. Call a form
  7. How to add custom products/steps fields
  8. Extra Product Options Settings
  9. Templates Customizations
  10. PHP filters
  11. PHP helpful tricks
  12. JS actions
  13. JS helpful tricks

A) About - top

The main task of this plugin is created form, which step by step helps customers to choose a kit from all products and categories, while your products have specific features. For example, if you sell bicycle details some of them from category "frame" do not combine with some details of category "wheels". So after the customer has chosen some appropriate frame you can make some products of category "wheels" unavailable to choose on the second step. In the end customer get your own kit of products, which meets some technical or other requirements.

Plugin promo

B) Main Settings - top

Main Settings

General global settings page

1. You can choose what styles should be included from the plugin.

  • Full is the self-sufficient style file. It applied all required styles to the plugin's elements.
  • Basic styles should be fine if your active theme is based on the "Bootstrap 3/4" framework, then the wizard will be styled the same as your active theme. Or if you need some basic styles applied to the wizard's elements and want to add your own extra-styles.
  • None value doesn't include any styles at all. This way you can make a complete custom style from the plugin sources and tools or use your own approach for styling.
  • Custom full styles include the file with your custom styles such as colors, font-size, and so on. To modify it go to the Custom styles sub-page.

2. If for some reasons you need to disable some of plugin's scripts, change "Scripts including type" setting to "Multiple files" and de-select them in the list lower.

3. Sometimes server's configuration might have problems with storing sessions. For example, if the wizard can't go next thought the steps or loses the cart content on the page update. In this case tick "Store session in the DB" setting which works much reliable but probably a little bit slower.

Custom styles

Custom styles settings page

This is possible to reconfigure the plugin's styles according to your needs. Don't forget to choose Custom full styles file value of the Styles including type setting.

In a case of required styles debug disable the Minify custom styles setting to get them more readable. In other cases keep this setting enabled to make the file less and save your customers traffic.

There are two modes of custom styling. The simple mode provides only a few main variables to change, while the advanced one allows to change much more variables and do this more flexible but requires SCSS knowledge. There are all plugin variables available for changing using the text editor.

Sometimes the wizard's font looks very small on specific themes. Adjust the font size setting this way. You can use any CSS units there, like "rem", "px", "pc" and so on. Separately you can change product title and price font sizes.

In a case of a style error you will see the message about it while saving and the styles will not be generated.

In a case you need to return all styles to the initial state click Reset to default button once.

C) Post Settings - top

Basic settings

Basic settings page

1. Use post content as a description of the first tab.

2. Use "Add step" button to create the required steps number. You also can sort them using drag and drop.

3. "Set default cart content from your session" option allows to define the default wizard cart content for the first launch. Open the wizard and go through it selecting products, which should be in a default kit, and stop on the last step. After click "Set default cart" button in admin part to save these products as default. To reset this selection click "Reset default cart" button.

Default wizard behavior removes products from the steps, which are after the active one. To avoid this check the "Disable products dependencies" setting of "Behavior" group.

Behavior settings

Behavior settings page

1. "Work mode" is an important setting which changes the main wizard's view and behavior. Possible values are:

  • Step by step - output the steps as tabs and doesn't allow to jump from the firsts steps to the lasts. The only way to skip steps is to use the "Skip" or "Go to results" buttons;
  • Free walk - output the steps as tabs and allows to open any step you want;
  • Single step - output all steps at once vertically;
  • Sequence - output all steps vertically but one by one according to the current state.

2. "Nav action" helps to change the event after the click on a nav button. This is possible to submit and get step, just to get step or do nothing.

3. "Final redirect url" is a url to the page, which will be opened after the wizard selection confirmation.

4. "Disable products dependencies" setting disabled possibility of filtering products, based on their dependencies.

Default wizard behavior removes products from the steps, which are after the active one. To avoid this check this option.

5. "Scrolling to top on the form update" will scroll the page to the top on going next through the wizard.

6. "The gap on scrolling up (px)" is a top gap after scrolling the page to the top.

7. "Hide prices" setting can hide the product prices for the plugin's views and output. But keep in mind the prices and Woocommerce cart will stay.

8. For the products bought using a wizard the "Price discount" setting makes a discount in percentage. Might be overwritten with a product category discount setting or individual product setting for a specific product.

Cart settings

Cart settings page

1. "Clear WooCommerce cart on the wizard confirms" will always truncate the cart of WooCommerce on any wizard confirmation.

2. "Reflect products in the main cart immediately" will add and remove products in WooCommerce cart as in the opened wizard.

3. "Minimum/Maximum products selected" settings defines the limits of the selected products to complete the wizard order.

4. "Minimum/Maximum total products quantity" settings defines the limits of total quantities of selected products to complete the wizard order.

5. "Minimum/Maximum products price" settings defines the limits of the selected products total price to complete the wizard order.

Kits settings

Kits settings page

1. "Group products into kits after adding to the main cart" makes products bonded to each other in WooCommerce cart.

2. "Kits type" change the final view of a kit. With value "Separated lines" It might be separated products, but still bonded. Alternatively, "Combined products" creates only one cart item with the title and featured image of the wizard post and kit's products will be shown as sub-lines of this item. You can use the wizard's thumbnail as a product thumbnail instead of the first product's one.

3. You can select a "Kit base product" to use it as a root product of kits. Otherwise, the first product of the wizard's cart will be taken as a root.

4. You can define a "Base kit price" which will be included to the kit's price by default and have no way to avoid it.

5. You can define a static "Kit price" value for the combined kit type. This setting overwrites the base kit price and all products prices in the wizard.

Layout settings

Layout settings page

1. With the "Nav template" setting you can choose how the tabbed views navigation should look like.

2. "Show sidebar" setting rule the appearance of wizard sidebar.

3. "Sticky sidebar offset top" tunes the gap between the top of the screen and stuck sidebar.

4. "Sticky controls offset top" tunes the gap between the top of the screen and stuck controls.

5. "Table layout strings" defines captions of the "layout" form view.

Tabs settings

Tabs settings page

1. "Enable description tab" enables/disables the first tab with description text.

2. "Description tab title" setting sets the description tabs nav item text.

3. "Enable results tab" enables/disables the last tab with selection results.

4. "Results tab title" setting sets the results tab nav item text.

5. "Results tab description" setting sets the results tab description before the table.

6. "Show results tab table" setting on/off the cart table on the result step. For example, might be disabled to use the widget instead.

7. "Results tab contact form" setting sets what ContactForm7 form will be output on the results tab lower the products selection table. Using this form you can send emails with the cart content PDF.

To attach the cart PDF file to the email add the [wcpw-result-pdf] shortcode in the File attachments field.

8. Use "Results strings" to change result page captions on the result tab and PDF.

Strings settings

Strings settings page

Strings settings allows changing output strings thought the workflow.

Controls settings

Controls settings page

Controls settings allows to choose which buttons are used in the wizard and their labels.

Moreover, all controls might have different classes for their styling and behavior. As the main plugin styles are based on the Bootstrap 4 framework you can use any from the available styling classes of buttons.

Also, there are a few classes to control buttons text and icons appearing:

  • hide-text - hides text of the button but keeps it for screen readers;
  • hide-text-on-mobile - hides text of the button on small screens but keeps it for screen readers;
  • icon-left - define on which side of the button the icon should appear;
  • icon-right - define on which side of the button the icon should appear;
  • show-icon - always shows a pre-defined button icon. Requires icon-left/right class for work;
  • show-icon-on-mobile - shows a pre-defined button icon on small screens. Requires icon-left/right class for work;

Result PDF settings

Result PDF settings page
To modify the PDF template make a copy of views/result-pdf.php
to your active theme directory to woocommerce-products-wizard/result-pdf.php.

1. Result PDF header height in cm allows to define the top header size for each page.

2. Result PDF header content will be used as the header for each page. Its color and inner padding might be configured right there using CSS. This is possible to use special shortcodes to output the current page number and total pages number.

3. Result PDF top description content will be placed before the results table.

4. Result PDF footer height in cm allows to define the top header size for each page.

5. Result PDF footer content will be used as the footer for each page. Its color and inner padding might be configured right there using CSS. This is possible to use special shortcodes to output the current page number and total pages number.

6. Result PDF bottom description content will be placed after the results table.

Filter settings

Filter settings page

Filter settings allows change strings of the steps filters.

Step settings modal

Captions
Step captions settings

1. "Title" option allows changing the title of the tab.

2. "Description" setting helps to add the text on the current tab.

You can add custom fields in the description to collect extra data from the customers while they walking through the wizard.

Use
[wcpw-step-input name="%SOME-NAME-HERE%"]
shortcode for this. It outputs only an input or textarea HTML tag, so you can add the label and other tags manually.

"File" type isn't supported currently. Use Extra Product Options plugin for this. Also, unsupported types are: "button", "image", "reset", "submit".

"Name" attribute is required for saving the data. All other required input attributes might be passed the same inline way.

Keep in mind you can get these custom fields data from the customers only through the PDF order file or combined kit type because they will not be saved among the ordinary products in the WooCommerce cart.

3. "Description position" setting change description text position.

4. You can Handle description with auto tags around and between lines as it is for the page content field.

5. "Item description source" changes the source of content for the item description. You can output long or short product description or output nothing.

Query
Step query settings

1. Select the products categories for using in this step. Products of selected categories will appear on the step.

2. "Included products" allows output only selected products for this step. This settings overwrites the "categories" setting. So this isn't necessary to set both these settings.

You also can keep these settings empty just to output a blank step with description and custom fields. This also will work.

3. "Excluded products" allow for removal of the output selected products for this step.

4. "Exclude already added products of steps" setting might contain steps IDs separated with a comma. If some products of these steps are already in the cart then they will not be shown on the current step.

5. "Required added products" make the tab visible only then one of the rules is met.
Each row could have one or a few products for checking. If there are several products all of them should be added to the cart to make the tab visible.
Many rows are means many rules for checking.

6. "Excluded added products" hide the tab then one of the rules is met.
Each row could have one or a few products for checking. If there are several products all of them should be added to the cart to hide the tab.
Many rows are means many rules for checking.

7. "Order" and "Order by" settings allows changing the sorting of products on the output.

8. "Enable 'Order by' dropdown" setting outputs the usual WooCommerce dropdown to change the products order.

9. "Products per page" setting changes the products per page quantity.

10. "Products per page items" setting allows to output a dropdown to change products per page number. Place a numeric value in each line.

Cart
Step cart settings

1. "Individual controls" settings enables/disables add-to-cart/remove buttons on each product block.

2. «Add to cart» button behavior setting changes what action should be fired after individual add-to-cart action.

3. "Hide choose element" settings allow hide the radio/checkbox input of each product. The only way to choose a product will be the use of individual controls.

4. There is a possibility to add to cart by quantity which is more than zero, so this way the "choose" element might be hidden to simplify the interface and use the products quantity input only. "Sold individually" setting shouldn't be enabled this way.

5. This is possible to don't add products of this step to the cart using special options. You can skip all products of a step or only specific ones. They will be visible in the wizard's workflow but skipped on the passing to the main cart.

6. "Can select several products" setting allows users to add more than one product of single step and replaced radio buttons by checkboxes.

7. "Sold individually" setting enables/disable product quantity input.

8. "Selected items by default" change the default selected products for the step. You can select specific products to output them checked and specific product variations to make them selected by default.

9. Also, you can set "All items are selected by default" for a step.

10. "No selected items by default" overwrites the previous two settings at all.

11. "Default product quantity" settings changes products quantity input default value.

12. "Minimum products selected" setting indicates how many products should be selected to move to the next step.

13. "Maximum products selected" setting limits how many products might be selected to move to the next step.

14. "Minimum product quantity" settings change the minimum product quantity input value.

15. "Maximum product quantity" settings change the maximum product quantity input value.

If these two settings have equal values then the quantity input might be hidden at all.

16. "Minimum total products quantity" settings indicates how many products quantity must be selected to move to the next step, i.e. the sum of selected product quantities.

17. "Maximum total products quantity" settings indicates how many products quantity can be selected to move to the next step, i.e. the sum of selected product quantities.

These six min/max options might have one of five possible types:

  • Simple count - a static count value;
  • Count of selected products of step - count of selected products from the other steps;
  • Least product quantity of step - the smallest quantity input value from the other steps products;
  • Greatest product quantity of step - the greatest quantity input value from the other steps products;
  • Sum of products quantities of step - the sum of quantity input values from the other steps products.

To use other steps types set steps IDs separated by a comma as an option's value. You can find these IDs before the titles of steps list in the "Basic" group.

View
Step view settings

1. "Template" setting change layout of products in the current tab. The list is formed of the php-files in the
"plugin directory/views/form/layouts" and
"theme directory/woocommerce-products-wizard/form/layouts" folders.

2. "Grid column" setting changes "grid" template settings for different screen size. It based on 12 columns system and four sizes and each value is the part of these 12 columns. For example, for three columns value should be 4 (is 12/3).

3. "Grid column then the sidebar is showed" is the same as "Grid column" but then the sidebar is apparent.

4. "Item template" setting change view of products in the current tab. The list is formed of the php-files in the
"plugin directory/views/form/item" and
"theme directory/woocommerce-products-wizard/form/item" folders.

5. Merge thumbnail with gallery setting removes the galleries from item views and shows gallery images within thumbnail using carousel.

6. "Gallery column" setting is the same as "Grid column" but for item's gallery grid.

7. "Variation template" setting change the layout of the variable products options list.

8. "Enable title link" setting wraps product titles by their links to single pages.

9. "Show product tags" setting output the float product tag labels above the thumbnail.

Filters
Step filters settings

1. "Filters" setting allows adding different product filters to the step. You can add any number of filters to the step. Select one of prepared sources at first and then one of the suggested views.
There is a possibility to select "range" view for a product attribute, but keep in mind it will work well only with numeric attribute values.

2. "Filter position" might be right before the products or in the sidebar. But keep in mind sidebar filter will work only for the tabs mode.

3. "Expand filter by default" output the filter opened then the step is shown.

4. For the image viewed filters set the thumbnail size setting. It might be one of the registered named sizes or a pair of integers separated by a comma, like "50,50".

D) Product Settings - top

Product settings

1. By dependencies form you can set the product dependencies from the other products or product variations. Each new line of the form is mean "OR" dependency.

Two or more dependencies on the one line are meant "AND" dependency. This is means the product will be available if all of these products have been chosen earlier.

You can also set dependencies of the each variation of a variable product.

2. "Exclusions" setting hides product when one of the other defined product is in the cart.

3. "Variation view" setting change layout of the variable product options list above category settings.

4. You can add a Discount to the product bought using a wizard. Possible values are:

E) Category Settings - top

Category settings

1. You can add a Discount to category products bought using a wizard. Possible values are:

2. If you have some specific product what can't work fine on a wizard's tab then you can use a special feature which allows to intercept the added product and continue the workflow in a wizard immediately.

First of all tick the Redirect to the wizard on product add option to make it possible.

3. Secondly, define a Redirect link which will be opened after the adding of a product from this category.

4. Select a Wizard for using which is used on the page you defined upper.

5. Set a Wizard's step ID in which the product should be added. If you want the product will be out of any step then set it to any out of steps IDs value.

F) Call a form - top

To call the wizard use [woocommerce-products-wizard id="%POST_ID%"] shortcode with the id attribute in the page content. You can find it on the wizard edit page on the string "Using".

Also you can use the "WCProductsWizard\Template::html('app', ['id' => %POST_ID%])" string in the php-file.

You can send the attributes as string in the shortcode or as an associative array in the method arguments.

G) How to add custom products/steps fields - top

Sometimes you might need to get some custom data passed by the customers, e.g. custom text, number, file, and so on. There are a couple of different ways to achieve this.

The first one is using the Extra Product Options plugin which is compatible with the wizard. It allows to add custom fields to any product. This is necessary to check a couple of settings to make it work. See the Extra Product Options Settings section.

The second way is to add custom fields to a step using the wizard’s possibilities. Take a look at the Description setting section. For usual WooCommerce order workflow this is necessary to combine the products to kits to save this custom data in orders. Otherwise, if you get your orders using a contact form with the PDF you don't need to use kits, because custom data will be disclosed in the PDF.

H) Extra Product Options Settings - top

To make the wizard work with Extra Product Options plugin be sure its settings are:

I) Templates Customization - top

If you want to customize some views of the plugin and don't lose these changes while updating the plugin create "woocommerce-products-wizard" folder in your active theme directory and copy into it files from the plugin's "views" directory saving the sub-directory hierarchy.

The plugin trying to get a view from the theme at first, and if it doesn't find this view, it gets the view from itself directory.

J) PHP actions and filters - top

Actions

do_action('wcpw_step_settings_form', $this, $args) Before step settings form HTML in the admin part
do_action('wcpw_get_cart', $postId, $args) Before cart get
do_action('wcpw_before_add_to_cart', $postId, $cartItemKey, $cartItem) Before item is added to cart
do_action('wcpw_after_add_to_cart', $postId, $cartItemKey, $cartItem) After item is added to cart
do_action('wcpw_before_remove_by_product_id', $postId, $productId, $stepId) Before removing a product from cart by ID
do_action('wcpw_after_remove_by_product_id', $postId, $productId, $stepId) After removing a product from cart by ID
do_action('wcpw_before_remove_by_variation', $postId, $variationId, $variation, $stepId) Before removing product from cart by variation
do_action('wcpw_after_remove_by_variation', $postId, $variationId, $variation, $stepId) After removing product from cart by variation
do_action('wcpw_before_remove_by_product_key', $postId, $key) Before removing a product from cart by key
do_action('wcpw_after_remove_by_product_key', $postId, $key) After removing a product from cart by key
do_action('wcpw_before_remove_by_step_id', $postId, $stepId) Before removing an item from cart by step ID
do_action('wcpw_after_remove_by_step_id', $postId, $stepId) After removing an item from cart by step ID
do_action('wcpw_before_truncate', $postId) Before truncating of the cart
do_action('wcpw_after_truncate', $postId) After truncating of the cart
do_action('wcpw_before_output', ['id' => $id]) Before wizard's output via shortcode, views or PDF
do_action('wcpw_dom_pdfoptions', $options, $id) DomPDF options instance
do_action('wcpw_dom_pdfinstance', $dompdf, $id) DomPDF instance
do_action('wcpw_after_output', ['id' => $id]) After wizard's output via shortcode, views or PDF
do_action('wcpw_before_submit_form', $args) Before main form submit
do_action('wcpw_after_submit_form', $args) After main form submit
do_action('wcpw_before_get_form', $args) Before main form get
do_action('wcpw_after_get_form', $args) After main form get
do_action('wcpw_before_skip_form', $args) Before main form skip
do_action('wcpw_after_skip_form', $args) After main form skip
do_action('wcpw_before_skip_all', $args) Before main form "skip all"
do_action('wcpw_after_skip_all', $args) After main form "skip all"
do_action('wcpw_before_reset_form', $args) Before main form reset
do_action('wcpw_after_reset_form', $args) After main form reset
do_action('wcpw_before_add_cart_product', $args) Before add product to cart
do_action('wcpw_before_remove_cart_product', $args) Before removing a product from cart
do_action('wcpw_before_update_cart_product', $args) Before update product in cart
do_action('wcpw_before_add_all_to_main_cart', $postId, $cart) Before passing the products to Woocommerce cart
do_action('wcpw_after_add_all_to_main_cart', $postId, $cart, $productsAdded) After passing the products to Woocommerce cart
do_action('wcpw_before_add_to_main_cart', $args) Before passing the product to Woocommerce cart

Filters

apply_filters('wcpw_post_type_args', $args); Wizard post type arguments
apply_filters('wcpw_custom_styles_variables', $customVariables); Style custom variables array for overwriting and compiling
apply_filters('wcpw_default_cart_content', $defaultCartContent, $postId, $args); Getting default cart content
apply_filters('wcpw_cart', $cart, $postId, $args); Getting cart content
apply_filters('wcpw_cart_products_and_variations_ids', $output, $postId, $args); Getting products and variations IDs from the cart
apply_filters('wcpw_cart_by_step_id', $output, $postId, $stepId); Getting cart content by step ID
apply_filters('wcpw_cart_item_by_key', $output, $postId, $key); Getting cart item by key
apply_filters('wcpw_cart_product_by_id', $output, $postId, $productId, $stepId); Getting a product from cart by ID and optionally by step ID
apply_filters('wcpw_add_to_cart_item', $cartItem, $postId, self::$sessionKey); Product data for adding to cart
apply_filters('wcpw_cart_total', $output, $postId); Getting cart total amount
apply_filters('wcpw_cart_item_price', $price, $item); Getting cart item price
apply_filters('wcpw_cart_kit_child_value_parts', $output, $itemData, $cartItem); Combined kit child value string parts
apply_filters('wcpw_cart_kit_child_display', $output, $itemData, $cartItem); Combined kit child displayed value string parts
apply_filters('wcpw_kit_child_data', $array); Combined kit child meta data
apply_filters('wcpw_sub_terms', $output, $termId, $taxonomy); Child terms of a term array
apply_filters('wcpw_price_limits', $output, $postId, $stepId); Min/max prices of products for a step
apply_filters('wcpw_send_jsondata', $data); Sending JSON response data
apply_filters('wcpw_result_pdfinstance', $dompdf, $id); DomPDF instance of wizard
apply_filters('wcpw_result_pdfile_name', $output); DomPDF file name
apply_filters('wcpw_result_pdfile', $array, $id); DomPDf file data array
apply_filters('wcpw_form_ajax_actions', $ajaxActions); Pairs of JS action and PHP handles for AJAX
apply_filters('wcpw_step_quantities_rule', (int) $output, $postId, $rule); Some of step's products quantity rules
apply_filters('wcpw_submit_form_item_data', $data, $args); Add item to cart data from the main form submit event
apply_filters('wcpw_prevent_final_redirect', false, $postData); Prevents the final redirect
apply_filters('wcpw_steps_ids', $stepsIds, $postId); Prepared form steps IDs array
apply_filters('wcpw_steps', $steps, $postId); Prepared form steps array
apply_filters('wcpw_step', $output, $postId, $stepId); Step data array
apply_filters('wcpw_active_step_id', $output, $postId); Active step ID
apply_filters('wcpw_active_step', $activeStep, $postId); Active step array
apply_filters('wcpw_pagination_args', $paginationArgs, $args); Step pagination arguments
apply_filters('wcpw_pagination_items', $output, $args); Step pagination items array
apply_filters('wcpw_nav_items', $navItemsCache[$postId], $postId); Steps navigation items array
apply_filters('wcpw_filter_fields', $output, $postId, $stepId, $appliedFilters); Step filters array
apply_filters('wcpw_integration_ajax_actions_list', $ajaxActions); Pairs of JS action and PHP handles for AJAX
apply_filters('wcpw_redirect_to_wizard_product_terms', $terms, $cartItemKey); Product terms array before redirect to a wizard after add to cart action
apply_filters('wcpw_redirect_to_wizard_link', $link, $wizardId, $cartItemKey, $productData); Redirect link to a wizard after add to cart action
apply_filters('wcpw_redirect_to_wizard_product_data', $productData, $wizardId, $cartItemKey); Product data of a wizard after add to cart action (before redirect)
apply_filters('wcpw_variation_arguments', $output, $arguments); Product variations data
apply_filters('wcpw_products_request_args', $output, $productsIds, $filter); Products request args of a step
apply_filters('wcpw_add_all_to_main_cart_items', $cart, $postId); Items on a passing to Woocommerce cart
apply_filters('wcpw_kit_id', date('d-m-Y H:i:s'), $postId, $cart); ID of the kit on a passing to Woocommerce cart
apply_filters('wcpw_kit_title', get_the_title($postId), $postId, $cart); Title of the kit on a passing to Woocommerce cart
apply_filters('wcpw_kit_base_product_data', $productData, $postId, $cart); Data of the admin defined base kit product
apply_filters('wcpw_main_cart_product_data', $productData, $postId, $cartItem); Add products to main cart loop item data
apply_filters('wcpw_merge_cart_quantity', false, $args)); Is necessary to merge the same product quantity in Woocommerce cart
apply_filters('wcpw_step_products_query_args', $queryArgs, $postId, $stepId, $filter); Step products request query array
apply_filters('wcpw_step_products_ids', $productsIds, $postId, $stepId, $args); Array of products IDs of a step
apply_filters('wcpw_settings_models', $modelCache); Get all settings models array
apply_filters('wcpw_global_settings_model', $global); Array of the plugin global settings model
apply_filters('wcpw_post_settings_model', $post); Array of a wizard post settings model
apply_filters('wcpw_step_settings_model', $step); Array of a wizard step settings model
apply_filters('wcpw_product_settings_model', $product); Array of a product settings model
apply_filters('wcpw_product_variation_settings_model', $productVariation); Array of a product variation settings model
apply_filters('wcpw_product_category_settings_model', $productCategory); Array of a product category settings model
apply_filters('wcpw_product_attribute_settings_model', $productAttribute); Array of a product atribute settings model
apply_filters('wcpw_global_setting', $value $setting); Get one global setting value
apply_filters('wcpw_post_setting', $value, $id, $setting, $modelSource); Get one wizard's setting value
apply_filters('wcpw_post_settings', $output, $id, $args); Get all wizard's settings values
apply_filters('wcpw_steps_ids_setting', $stepsIdsCache[$id], $id); Wizard's steps IDs array from DB
apply_filters('wcpw_step_settings', $stepsSettingsCache[$id], $id); Get all step setting values
apply_filters('wcpw_step_setting', $value, $id, $stepId, $setting); Get one step setting value
apply_filters('wcpw_step_settings', $output, $id, $args); Get one step settings array
apply_filters('wcpw_product_category_setting', $value, $id, $setting); Get one product category setting value
apply_filters('wcpw_is_sidebar_showed', $show, $id); Is sidebar showed state
apply_filters('wcpw_final_redirect_url', $url, $id); Getting the final redirect URL
apply_filters('wcpw_filter_sources_list', $output); Step filter sources array
apply_filters('wcpw_minimum_products_selected_message', $message, $id, $limit, $value); Minimum products selected error message
apply_filters('wcpw_maximum_products_selected_message', $message, $id, $limit, $value); Maximum products selected error message
apply_filters('wcpw_minimum_products_price_message', $message, $id, $limit, $value); Minimum products price error message
apply_filters('wcpw_maximum_products_price_message', $message, $id, $limit, $value); Maximum products price error message
apply_filters('wcpw_form_template_name', $template, $postId, $stepId); Form step current template name
apply_filters('wcpw_form_templates', $templates); Available form step templates
apply_filters('wcpw_form_item_templates', $templates); Available form item templates
apply_filters('wcpw_variations_type_templates', $templates); Available form item variation templates
apply_filters('wcpw_form_item_template_name', $template, $postId, $stepId); Form item current template name
apply_filters('wcpw_nav_list_templates', $templates); Available steps navigation templates
apply_filters('wcpw_step_input_short_code_unsupported_types', $unsupportedTypes); List of unsupported step input types using the short-code
apply_filters('wcpw_filter_args_to_query', $output, $filter); WP_Query ready filter arguments

K) PHP helpful tricks - top

1. Add custom product filters to a step

If you want to allow the products filtering by custom fields then this is necessary to use two hooks for this. The first one is used to add filter instances for the further work. They are arrays with keys within, namely:

  • label - Filter's name for output on the front part;
  • key - Inner key for using;
  • view - A filter view name supported by a wizard by default or custom one;
  • value - Current value of the only field (like text input) or null;
  • values - Array of possible values of the filter.

The second hook is for handling the passed values to use for WP_Query arguments.

Here is an example of using YITH brands taxonomy as a product filter within the #123 wizard for the 1 and 2 steps:

<?php
// add custom filters to output on the front part
add_filter('wcProductsWizardFilterFields', function ($output, $postId, $stepId, $appliedFilters) {
    // add only for specific wizard ID and steps IDs
    if ($postId == 123 && in_array($stepId, [1, 2])) {
        $label = 'Brands'; // filter name
        $view = 'checkbox'; // required view
        $key = 'yith_product_brand'; // taxonomy to use
        $values = [];

        // collect terms as values
        $terms = get_terms(['taxonomy' => $key]);

        foreach ($terms as $term) {
            $values[] = [
                'id' => $term->term_id,
                'name' => $term->name,
                'isActive' => isset($appliedFilters[$key]) && in_array($term->term_id, $appliedFilters[$key])
            ];
        }

        $output[] = [
            'label' => $label,
            'key' => $key,
            'view' => $view,
            'value' => isset($appliedFilters[$key]) ? $appliedFilters[$key] : null,
            'values' => $values
        ];
    }

    if ($postId == 321 && in_array($stepId, [4, 5])) {
        // other filters here...
    }

    return $output;
}, 10, 4);

// handle passed filters to query args
add_filter('wcProductsWizardFilterArgsToQuery', function ($output, $filter) {
    foreach ($filter as $key => $value) {
        // add query arg by the custom taxonomy
        if ($key == 'yith_product_brand' && !empty($value)) {
            $output['tax_query'][] = [
                'taxonomy' => $key,
                'field' => 'id',
                'terms' => $value,
                'operator' => 'IN'
            ];
        }

        // other filters here...
    }

    return $output;
}, 10, 2);
?>

L) JS actions - top

this.$document.trigger('launched.wcProductsWizard', [this]); On wizard init
this.$document.trigger('ajaxRequest.wcProductsWizard', [this, formData]); Before wizard AJAX query
this.$document.trigger('ajaxCompleted.wcProductsWizard', [this, response]); On wizard AJAX success query
this.$document.trigger('addToMainCart.wcProductsWizard', [this, data, result]); On add to main cart
this.$document.trigger('addToMainCart.error.wcProductsWizard', [this, data, response]); Add to main cart error
this.$document.trigger('addToMainCartRedirect.wcProductsWizard', [this, data, response]); On doing the final redirect
this.$document.trigger('submit.wcProductsWizard', [this, data]); On form submit
this.$document.trigger('submit.error.wcProductsWizard', [this, data]); Form submit error

M) JS helpful tricks - top

Here is the list of some Javascript codes to change the wizard's behavior. There are many ways to add them to your site. You can use some plugins to add extra scripts, for example Simple Custom CSS and JS. Also, some themes provides text fields for custom codes for using. Or you can add extra scripts right in theme's javascript files, but it's better to do only for the child themes because you can loose the changes you made while theme update.

// submit wizard on any product variation change
jQuery(document).on('change', '[data-component~="wcpw-product-variations-item-input"]', function () {
    jQuery(this).closest('[data-component~="wcpw"]').data('wcpw').submit();
});

// add/remove product in cart once it is chosen
jQuery(document).on('change', '[data-component~="wcpw-product-choose"]', function () {
    var $input = jQuery(this);
    var $wcpw = $input.closest('[data-component~="wcpw"]');

    if ($input.attr('type') === 'checkbox') {
        if ($input.prop('checked')) {
            $wcpw.data('wcpw').addCartProduct({productToAddKey: $input.data('step-id') + '-' + $input.val()});
        } else {
            $wcpw.data('wcpw').removeCartProduct({
                productCartKey: $input.closest('[data-component~="wcpw-product"]').data('cart-key')
            });
        }
    } else {
        $wcpw.data('wcpw').addCartProduct({productToAddKey: $input.data('step-id') + '-' + $input.val()});
    }
});

// submit filter on change immediately
jQuery(document).on('change', '[data-component~="wcpw-filter"]', function () {jQuery(this).submit()});

// don't open the image page on thumbnail click
jQuery(document).on('click', '[data-component="wcpw-product-thumbnail-link"]', function (event) {event.preventDefault()});

troll_winner

Go To Table of Contents