Forum Replies Created
- AuthorPosts
- hello4Participant
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 6, 2019 at 8:10 pm in reply to: Mobile Number verification during Vendor Registration #42468hello4ParticipantHello,
Is this feature only available in pro version?
Thanks and regards,
hello4ParticipantHello 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;
}hello4ParticipantHello 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!
hello4ParticipantHello,
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,
hello4ParticipantHello again,
Any updates on this?
Thanks and regards,
hello4ParticipantIt works… Many thanks for the quick and great support.
hello4ParticipantHello,
It could be either ‘Complete’ or ‘Delivered’ (it’s a custom booking status).
Thanks and in advance.
- AuthorPosts