Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM › Hiding product manage tabs and calculating rates
- This topic has 11 replies, 2 voices, and was last updated 5 years, 11 months ago by WCFM Forum.
- AuthorPosts
- January 3, 2019 at 3:44 pm #42133hello4Participant
Hello again,
I have a requirement where I want my vendors to enter only a few pieces of information while the others are to be submitted automatically when they submit products for review. I managed to get most of them done thanks to this solution you’ve provided before: https://wclovers.com/forums/topic/how-can-i-hide-unnecessary-fields-in-product-publishing-page-and-preset-values/#post-35600
Now I have a couple of tabs which I would like to hide using the same methods so on load, the focus will be on the visible tab. https://goo.gl/vXbGmA In this case I want only Costs tab to be visible. I can hide the other two using CSS but it doesn’t give the focus to visible tab. Could you kindly help me with this?
Further, I like to calculate the base cost of the item using the block cost that vendor enters. For example if they enter the block cost as 400, I want to divide it by 10, add 50 to it. Is there a filter/action hook that I can use to achieve it? I know how to do it using default WooCommerce backend but no clue how to do it using the WCFM.
Just so you know, I just left a review for WCFM on WordPress.org. Hope you like it.
Many thanks in advance!
- January 3, 2019 at 4:48 pm #42148WCFM ForumMember
HI,
First of all, thanks for the review and have a great new year ahead 🙂
*** Now I have a couple of tabs which I would like to hide using the same methods so on load, the focus will be on the visible tab. https://goo.gl/vXbGmA In this case I want only Costs tab to be visible. I can hide the other two using CSS but it doesn’t give the focus to visible tab. Could you kindly help me with this?
– What do you mean by focus on tab? On select “Bookable Product” cost tab will be open!
*** Further, I like to calculate the base cost of the item using the block cost that vendor enters. For example if they enter the block cost as 400, I want to divide it by 10, add 50 to it. Is there a filter/action hook that I can use to achieve it? I know how to do it using default WooCommerce backend but no clue how to do it using the WCFM.
– Check this code. So, you may use “wcfm_booking_data_factory” filter to implement your “Base Cost” calculation –
$errors = $product->set_props( apply_filters( 'wcfm_booking_data_factory', array( 'apply_adjacent_buffer' => isset( $wcfm_products_manage_form_data['_wc_booking_apply_adjacent_buffer'] ), 'base_cost' => wc_clean( $wcfm_products_manage_form_data['_wc_booking_base_cost'] ), 'buffer_period' => wc_clean( $wcfm_products_manage_form_data['_wc_booking_buffer_period'] ), 'calendar_display_mode' => wc_clean( $wcfm_products_manage_form_data['_wc_booking_calendar_display_mode'] ), 'cancel_limit_unit' => wc_clean( $wcfm_products_manage_form_data['_wc_booking_cancel_limit_unit'] ), 'cancel_limit' => wc_clean( $wcfm_products_manage_form_data['_wc_booking_cancel_limit'] ), 'cost' => wc_clean( $wcfm_products_manage_form_data['_wc_booking_cost'] ), 'default_date_availability' => wc_clean( $wcfm_products_manage_form_data['_wc_booking_default_date_availability'] ), 'display_cost' => wc_clean( $wcfm_products_manage_form_data['_wc_display_cost'] ), 'duration_type' => wc_clean( $wcfm_products_manage_form_data['_wc_booking_duration_type'] ), 'duration_unit' => wc_clean( $wcfm_products_manage_form_data['_wc_booking_duration_unit'] ), 'duration' => wc_clean( $wcfm_products_manage_form_data['_wc_booking_duration'] ), 'enable_range_picker' => isset( $wcfm_products_manage_form_data['_wc_booking_enable_range_picker'] ), 'max_date_unit' => wc_clean( $wcfm_products_manage_form_data['_wc_booking_max_date_unit'] ), 'max_date_value' => wc_clean( $wcfm_products_manage_form_data['_wc_booking_max_date'] ), 'max_duration' => wc_clean( $wcfm_products_manage_form_data['_wc_booking_max_duration'] ), 'min_date_unit' => wc_clean( $wcfm_products_manage_form_data['_wc_booking_min_date_unit'] ), 'min_date_value' => wc_clean( $wcfm_products_manage_form_data['_wc_booking_min_date'] ), 'min_duration' => wc_clean( $wcfm_products_manage_form_data['_wc_booking_min_duration'] ), 'qty' => wc_clean( $wcfm_products_manage_form_data['_wc_booking_qty'] ), 'requires_confirmation' => isset( $wcfm_products_manage_form_data['_wc_booking_requires_confirmation'] ), 'user_can_cancel' => isset( $wcfm_products_manage_form_data['_wc_booking_user_can_cancel'] ), ), $new_product_id, $product, $wcfm_products_manage_form_data ) );
Well, your one code is pending. I will give yo that soon.
Thank You
- January 3, 2019 at 8:39 pm #42176hello4Participant
Hello,
Thanks for the quick reply.
Regarding the tabs, when I hide the Booking Options and Availability tabs using CSS, it hides those tabs but the page doesn’t load with the focus to Costs tab (https://goo.gl/zc62Ve). Here’s my CSS code:
#wcfm_products_manage_form_availability_head, #wcfm_products_manage_form_booking_options_head {
display: none;
}Unfortunately I couldn’t figure out how to calculate the base cost using the entered block cost either so any help on that also highly appreciated.
Thanks and regards,
- January 5, 2019 at 9:22 am #42288WCFM ForumMember
Hi,
Please use this code to focus at “Cost” tab –
add_filter( 'wcfm_product_type_default_tab', function( $default_tabs ) { if( isset( $default_tabs['booking'] ) ) { $default_tabs['booking'] = 'wcfm_products_manage_form_costs_head'; } return $default_tabs; });
Base cost calculation code –
add_filter( 'wcfm_booking_data_factory', function( $booking_data, $new_product_id, $product, $wcfm_products_manage_form_data ) { $block_cost = $booking_data['cost']; // Calculation $booking_data['base_cost'] = ((float) $block_cost/10) + 50; return $booking_data; }, 50, 4 );
Thank you
- January 5, 2019 at 2:57 pm #42355hello4Participant
Hello there,
First code worked without any issues. I had to make a couple of changes for the second to get work. Actually it is relate to something that I wanted to mention before. Have you noticed that on product manage screen that you are using ‘base cost’ and ‘block costs’ the other way around? Please see the screenshot. https://goo.gl/ya4Q72 Hopefully you can fix this in a future release.
Many thanks for the help!
- January 5, 2019 at 3:39 pm #42364WCFM ForumMember
Thanks, we will definitely take care of this in next update.
- January 6, 2019 at 4:47 pm #42466hello4Participant
Hello again,
One last question relate to this. Is there a way to add a pricing range when vendors submit their details? Your customised plugin extension has this which I thought would work to add a range but I couldn’t get that to work:
if( isset( $cost_fields[‘_wc_booking_cost_rules’] ) ) {
$cost_fields_rules = array ( 0 => array ( ‘type’ => ‘days’, ‘from_custom’ => ”, ‘to_custom’ => ”, ‘from_months’ => ”, ‘to_months’ => ”, ‘from_weeks’ => ”, ‘to_weeks’ => ”, ‘from_days’ => ‘1’, ‘to_days’ => ‘7’, ‘from_time’ => ”, ‘to_time’ => ”, ‘from_count’ => ”, ‘to_count’ => ”, ‘base_modifier’ => ”, ‘base_cost’ => 3000, ‘block_modifier’ => ”, ‘block_cost’ => 5000 ) );
$cost_fields[‘_wc_booking_cost_rules’][‘value’] = $cost_fields_rules;
} - January 7, 2019 at 10:00 am #42501WCFM ForumMember
Hi,
Do you want set default cost rules ?
Thank You
- January 7, 2019 at 10:21 am #42504hello4Participant
Please see the attached screenshot. I am trying to set that up but so far I’ve had no luck. I use this to update it from the admin dashboard which works fine, but for this to work the product needs to be approved/published from admin dashboard:
//Calculate and set base and block costs
add_action( ‘woocommerce_process_product_meta_booking’, ‘modify_bookable_product_costs’, 100, 1 );function modify_bookable_product_costs( $product_id ){
// Get an instance of the WC_Product object
$product = wc_get_product( $product_id );// We check that we have a block cost before
if ( $product->get_block_cost() > 0 ){
// Calculation
$new_booking_cost = ( $product->get_block_cost() * 0.05 ) + 100;$product->set_cost( $new_booking_cost ); // Set the new calculated cost in the product
$product->save(); // Save the product data//Adjusting cost for 8 days
$pricing = array(
array(
‘type’ => ‘blocks’,
‘cost’ => 0.875,
‘modifier’ => ‘times’,
‘base_cost’ => $new_booking_cost,
‘base_modifier’ => ‘equals’,
‘from’ => 2,
‘to’ => 2
)
);update_post_meta( $product_id, ‘_wc_booking_pricing’, $pricing );
}
}Basically, all I want is to save the data that I pass to $pricing array, when vendors submits their products for approval.
Thanks and regards,
Attachments:
You must be logged in to view attached files. - January 8, 2019 at 8:07 am #42620WCFM ForumMember
Hi,
OK, write same code on WCFM this hook – do_action( ‘after_wcfm_products_manage_meta_save’, $new_product_id, $wcfm_products_manage_form_data );
Write code on higher priority.
Thank You
- January 8, 2019 at 4:04 pm #42695hello4Participant
Many thanks! It works great.
- January 8, 2019 at 4:10 pm #42696WCFM ForumMember
You are welcome 🙂
- AuthorPosts
- The topic ‘Hiding product manage tabs and calculating rates’ is closed to new replies.