Booking form Trigger another function
-
Hello, I would like to trigger another function to insert the data into another post type like Woocommerce Orders (shop_orders).
I’m not familiar with vue.js, I see the booking form is html, php, js and vue.js. I was wondering how to map the inputs with the sql/wp insert post?
<el-input v-model="appointment_step_form_data[customer_form_fields_data['v_model_value']]" class="bpa-front-form-control" :placeholder="customer_form_fields_data.placeholder" v-if="customer_form_fields_data.field_name != 'email_address'"></el-input> <el-input type="email" v-model="appointment_step_form_data[customer_form_fields_data['v_model_value']]" class="bpa-front-form-control" :placeholder="customer_form_fields_data.placeholder" v-else></el-input> </el-form-item> <el-form-item prop="customer_phone" ref="customer_phone" v-if="customer_form_fields_data.field_name == 'phone_number' && customer_form_fields_data.is_hide != '1'"> <el-input type="textarea" v-model="appointment_step_form_data[customer_form_fields_data['v_model_value']]" class="bpa-front-form-control" :placeholder="customer_form_fields_data.placeholder"></el-input> <el-button class="bpa-front-btn bpa-front-btn--primary" :class="(isLoadBookingLoader == '1') ? 'bpa-front-btn--is-loader' : ''" @click="book_appointment" :disabled="isBookingDisabled">
found here: bookingpress-appointment-booking/core/views/frontend/appointment_booking_form.php
Here’s my insert save code:
add_action( 'wp_ajax_add_woocommerce', 'add_woocommerce' ); add_action( 'wp_ajax_nopriv_add_woocommerce', 'add_woocommerce'); add_action('wp_head','add_woocommmerce'); function add_woocommmerce(){ global $post, $woocommerce, $wpdb; if( has_shortcode( $post->post_content, 'bookingpress_form') ) { $bookingpress_uniq_id = uniqid(); /* First need address */ $orderAddress = array( 'first_name' => $_POST['firstname'], //add first name to order address 'last_name' => $_POST['lastname'], //add first name to order address 'company' => 'test', //add company name to order address 'email' => $_POST['email_address'], //add email to order address 'phone' => $_POST['phone_number'], //add phone to order address 'address_1' => 'test', //add address to order address 'address_2' => '', 'city' => 'test', //add city to order address 'state' => 'test', //add state to order address 'postcode' => 'test', //add postcode to order address 'country' => 'US' //add country to order address ); $cutomOrder = wc_create_order(); // create new object for order $productId = 1; // set product id $quantity = 1; // set product quantity $cutomOrder->add_product( get_product( $productId ), $quantity ); // add product and quantity to order $cutomOrder->set_address( $orderAddress, 'billing' ); // set billing address // $cutomOrder->set_address( $orderAddress, 'shipping' ); // set shipping address $cutomOrder->calculate_totals(); // calculate total update_post_meta( $cutomOrder->id, '_payment_method', 'cod' ); //set payment method update_post_meta( $cutomOrder->id, '_payment_method_title', 'cod' ); //set payment title ?> <script type="text/javascript" > $('.bpa-front-btn.bpa-front-btn--primary').click(function() { var app = new Vue({ el: '#bookingpress_booking_form_<?php echo $bookingpress_uniq_id; ?>', data: { ... } )}; )}; </script> <?php } } ?>
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Booking form Trigger another function’ is closed to new replies.