Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Beaver Themer: WooCommeece Module:
- * Single category archive page template for WooCommerce
- *
- * You get a checkbox saying autoselect parent,
- * when it's set to true, the parent_id field gets hidden
- * and the parent_id will be automatically set, when it's false the user can enter a parent_id
- */
- add_filter('fl_builder_before_render_module', function($module) {
- if ('woocommerce' === $module->slug && 'categories' === $module->settings->layout && 'true' === $module->settings->autoparent) {
- $term_id = get_queried_object_id();
- $module->settings->parent_cat_id = $term_id;
- }
- }, 10, 2);
- add_filter('fl_builder_register_settings_form', function($form, $slug) {
- if ( 'woocommerce' === $slug ) {
- $form['general']['sections']['general']['fields']['autoparent'] = [
- 'type' => 'select',
- 'label' => __('Autoselect Parent', 'wpd'),
- 'default' => 'true',
- 'options' => array(
- 'true' => __('true', 'wpd'),
- 'false' => __('false', 'wpd')
- ),
- 'toggle' => [
- 'false' => [
- 'fields' => ['parent_cat_id']
- ]
- ]
- ];
- $form['general']['sections']['general']['fields']['layout']['toggle']['categories']['fields'] = array( 'parent_cat_id', 'cat_columns', 'autoparent' );
- }
- return $form;
- }, 10, 2);
Add Comment
Please, Sign In to add comment