- Search Results
Hi,
I found on one of this forums this functions.php code for letting vendor choose a suitable category at registration.
add_action( 'end_wcfm_membership_registration_form', function() { $selected_categories = array(); $product_categories = get_terms( 'product_cat', 'orderby=name&hide_empty=0&parent=0' ); $p_category_options = array(); foreach ( $product_categories as $cat ) { $p_category_options[$cat->term_id] = array( 'name' => $cat->name, 'parent' => 0 ); } if( !empty( $p_category_options ) ) showRegistrationCategoryHierarchySelector( $p_category_options, $selected_categories ); ?> <script> jQuery(document).ready(function($) { $('.wcfm_category_hierarchy').each(function() { $(this).change(function() { $level = parseInt($(this).data('level')); $value = $(this).val(); if( $('.p_category_'+($level+1)).length > 0 ) { $('.p_category_'+($level+1)).addClass('wcfm_custom_hide'); $('.p_category_label_'+($level+1)).addClass('wcfm_custom_hide'); if( $value ) { $.each($value, function( $i, $svalue ) { if( $('.p_category_'+($level+1)).find('.cat_parent_'+$svalue).length > 0 ) { $('.p_category_'+($level+1)).removeClass('wcfm_custom_hide'); $('.p_category_label_'+($level+1)).removeClass('wcfm_custom_hide'); } }); } $level_1 = $('.p_category_'+($level+1)).val(); $('.p_category_'+($level+1)).val(''); $('.p_category_'+($level+1)).find('option').addClass('wcfm_custom_hide'); if( $value ) { $.each($value, function( $i, $svalue ) { $('.p_category_'+($level+1)).find('.cat_parent_'+$svalue).removeClass('wcfm_custom_hide'); }); } if( $level_1 ) { if( !$('.p_category_'+($level+1)).find('option[value="'+$level_1+'"]').hasClass('wcfm_custom_hide') ) { $('.p_category_'+($level+1)).val($level_1); } } $('.p_category_'+($level+1)).change(); } }).change(); }); }); </script> <?php }); function showRegistrationCategoryHierarchySelector( $p_category_options, $selected_categories, $level = 0 ) { global $WCFM, $WCFMch; $p_category_child_options = array(); $ptax_custom_arrtibutes = apply_filters( 'wcfm_taxonomy_custom_attributes', array(), 'product_cat' ); ?> <p class="wcfm_title p_category_label_<?php echo $level; ?>"> <strong> <?php echo apply_filters( 'wcfm_taxonomy_custom_label', '', 'product_cat' ); if( $level ) _e( 'Sub-', 'wcfm-category-hierarchy' ); _e( 'Categories', 'wc-frontend-manager' ); ?> </strong> </p> <label class="screen-reader-text" for="product_cats"> <?php if( $level ) echo __( 'Sub-', 'wcfm-category-hierarchy' ); echo apply_filters( 'wcfm_taxonomy_custom_label', __( 'Categories', 'wc-frontend-manager' ), 'product_cat' ); ?> </label> <select id="p_category_<?php echo $level; ?>" style="height: auto;" multiple name="reg_category[<?php echo $level; ?>][]" class="wcfm-select wcfm_category_hierarchy p_category_<?php echo $level; ?>" data-level="<?php echo $level; ?>" data-catlimit="1" <?php echo implode( ' ', $ptax_custom_arrtibutes ); ?>> <option value=""><?php _e( '-- Selecteer Categorie --', 'wcfm-category-hierarchy' ); ?></option> <?php foreach( $p_category_options as $term_id => $term_details ) { $cat_group_class = 'cat_parent_' . $term_details['parent']; echo '<option class="' . $cat_group_class . '" value="' . esc_attr( $term_id ) . '"' . selected( in_array( $term_id, $selected_categories ), true, false ) . '>' . __( esc_html( $term_details['name'] ), 'wcfm-category-hierarchy' ) . '</option>'; $product_child_taxonomies = get_terms( 'product_cat', 'orderby=name&hide_empty=0&parent=' . absint( $term_id ) ); if ( $product_child_taxonomies ) { foreach ( $product_child_taxonomies as $cat ) { $p_category_child_options[$cat->term_id] = array( 'name' => $cat->name, 'parent' => $term_id ); } } } ?> </select> <?php $level++; if( !empty( $p_category_child_options ) ) showRegistrationCategoryHierarchySelector( $p_category_child_options, $selected_categories, $level ); } add_action( 'wcfm_membership_registration', function( $member_id, $wcfm_membership_registration_form_data ) { if( isset( $wcfm_membership_registration_form_data['reg_category'] ) ) { update_user_meta( $member_id, 'wcfm_vendor_reg_category', $wcfm_membership_registration_form_data['reg_category'] ); } }, 50, 2 );This works like a charm but the only problem is that this is required. I do not want that because if there is no category for vendor to suit his store I have a custom field where vendor can add a category suggestion so I can make that category for him in WC admin.
I can not find in the code how to make it not required. Can you please point me in the right direction?Also I wish to re-order the custom fields. Like “K.v.K. Nummer” is part of the shopinfo.
And custom field for Suggested Categorie (“Categorie Suggestie”) needs to be beneath the categories so if there is no category to choose from than vendor can fill in his own.Please see attachment.
Can you help me to achieve this please?And one more question.
Is it possible to hide the custom fields from vendor profile page?
I only need this information like K.v.K. Nummer to approve vendor and category suggestion to make the right category for vendor store.Thank you.
There is a problem in the fast product installation window, no part is not working, I can not click. There is no batch product update, there is the same problem, there is no click. Also, when the order is created, I cannot click on the shipping options, please help.
Topic: Create "_price" in database
Hi! I created this function to generate a new position in the database with metakey: “_price” because when i create a new product from frontend this is empty. The code works only when I update the post, not when I create it for the first time the product.
And how i can traslate the calendar?
Can you help me? Thank you !!function wpufe_update_post_price( $post_id ) { if ( 'product' != $_POST['post_type'] ) return; $regular_price = get_post_meta( $post_id, '_regular_price', true ); $sale_price = get_post_meta( $post_id, '_price', true ); update_post_meta( $post_id, '_price', $regular_price ); if ( !empty( $sale_price ) ) { update_post_meta( $post_id, '_price', $sale_price ); } } add_action('save_post_product', 'wpufe_update_post_price', 10, 1); add_action('wp_insert_post', 'wpufe_update_post_price', 10, 1);Hi,
It will be great to release an update allowing enable or disable Linked product options from capability: Up-sell, Cross-Sell and Frequently Bought Together
Thanks
Hello
I am trying to edit the template file wcfmu-view-products.php, I’m trying to edit the attributes section of that file by adding a class and changing the title or various sections however my changes are not showing. I then found that the same options are in the file wcfm-view-products-manage-tabs.php which is a file I cannot edit as it will be overwritten when I update the plugin.
Can you help?
Hello, I have some custom fields on my checkout page.
They suddenly stopped working and I can not figure out why. I have spent all day trying to figure this out. There are no errors in the logs.
The fields are no longer saving as post_meta.add_action('woocommerce_before_checkout_form', 'add_custom_checkout_select_field2'); function add_custom_checkout_select_field2( $checkout ) { global $woocommerce, $post ; foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values) { $product = $values['data']; echo '<div id="customise_checkout_field">'; woocommerce_form_field('test_field', array( 'type' => 'text', 'class' => array( 'player-name form-row-wide' ), 'label' => __('test_field') , 'placeholder' => __('test_field') , ), $checkout->get_value('test_field')); echo '</div>'; } } add_action( 'woocommerce_checkout_update_order_meta', 'my_custom_checkout_field_update_order_meta2' ); function my_custom_checkout_field_update_order_meta2( $order_id ) { if ( !empty( $_POST['test_field'] )) { update_post_meta( $order_id, 'test_field', sanitize_text_field( $_POST['test_field'] ) ); } } add_filter( 'woocommerce_order_details_after_order_table' , 'my_custom_checkout_field_display_admin_order_meta2', 20, 1 ); // Front add_filter( 'woocommerce_email_order_details' , 'my_custom_checkout_field_display_admin_order_meta2', 20, 1 ); // Front //Admin add_action( 'woocommerce_admin_order_data_after_billing_address', 'my_custom_checkout_field_display_admin_order_meta2', 10, 1 ); function my_custom_checkout_field_display_admin_order_meta2($order){ $test_field = get_post_meta( $order->get_id(), 'test_field', true ); if ( $test_field ) { echo '<p><strong>'.__('test_field').':</strong> ' . get_post_meta( $order->get_id(), 'test_field', true ) . '</p>'; } }It seems that any vendor registered before new “Additional Registration Custom Fields” were added to the vendor registration process can’t update their passwords.
See attached screen shots of the vendor trying to change password and a newly created staff account trying to change their password and says they need to acknowledge those two fields but are not visible because they are at the password rest section not the registration form.
Can you have a look and advise?
Thanks