pervasiveconcierge
Forum Replies Created
-
Thank you so much!!! I haven’t worked with Woocommerce in a little while so I was unaware of the changes. I fixed the issue by adjusting the Woocommerce settings to “WordPress posts storage (legacy)” and after the ACF fields the appeared. If I choose “High-performance order storage (recommended) ” and “Synchronization” as the Woocommerce settings then the ACF fields don’t appear.
Forum: Plugins
In reply to: [WP Directory Kit] Date field values are not included in search resultsThank you for your quick response the basic DATE field feature is what I’m using. I’ll contact you through the link as well.
Sorry I didn’t realize that I could change the status. Thank you for your help. I just couldn’t figure how to save the forms appointment date, ‘appointment_note’, etc. Unfortunately when I tried
add_action( ‘wp_ajax_bookingpress_front_save_appointment_booking’, ‘add_woocommerce’, 9 ); add_action( ‘wp_ajax_nopriv_bookingpress_front_save_appointment_booking’, ‘add_woocommerce’, 9 );it didn’t execute.
I did get the values for the first name, etc. but not the ‘appointment_note’ with the following function:
add_action('wp_head', 'add_woocommerce'); function add_woocommerce($postdata){ global $post, $woocommerce, $wpdb, $BookingPress, $tbl_bookingpress_customers, $tbl_bookingpress_form_fields, $bookingpress_front_vue_data_fields; $page_id = get_queried_object_id(); $page_object = get_post( $page_id ); // $tbl_bookingpress_form_fields = $wpdb->prefix . 'bookingpress_form_fields'; if ( has_shortcode ($page_object->post_content, 'bookingpress_form') && ! empty( $_REQUEST )){ if ( is_user_logged_in() ) { $current_user_id = get_current_user_id(); $bookingpress_current_user_obj = new WP_User($current_user_id); $bookingpress_check_customer = $wpdb->get_var( "SELECT COUNT(bookingpress_customer_id) as total_cnt FROM {$tbl_bookingpress_customers} WHERE bookingpress_wpuser_id = {$current_user_id} AND bookingpress_user_type = 2" ); if ( $bookingpress_check_customer ) { $get_current_user_data = $wpdb->get_row( "SELECT * FROM {$tbl_bookingpress_customers} WHERE bookingpress_wpuser_id = {$current_user_id} AND bookingpress_user_type = 2", ARRAY_A ); if ( ! empty( $get_current_user_data ) ) { $bookingpress_front_vue_data_fields['appointment_step_form_data']['customer_name'] = $get_current_user_data['bookingpress_user_login']; $bookingpress_front_vue_data_fields['appointment_step_form_data']['customer_phone'] = $get_current_user_data['bookingpress_user_phone']; $bookingpress_front_vue_data_fields['appointment_step_form_data']['customer_email'] = $get_current_user_data['bookingpress_user_email']; $bookingpress_front_vue_data_fields['appointment_step_form_data']['customer_firstname'] = $get_current_user_data['bookingpress_user_firstname']; $bookingpress_front_vue_data_fields['appointment_step_form_data']['customer_lastname'] = $get_current_user_data['bookingpress_user_lastname']; $note = isset($_REQUEST['appointment_note']); } }else if(!empty($current_user_id) && !empty($bookingpress_current_user_obj)){ $bookingpress_customer_name = !empty($bookingpress_current_user_obj->data->user_login) ? $bookingpress_current_user_obj->data->user_login : ''; $bookingpress_customer_email = !empty($bookingpress_current_user_obj->data->user_email) ? $bookingpress_current_user_obj->data->user_email : ''; $bookingpress_firstname = get_user_meta($current_user_id, 'first_name', true); $bookingpress_lastname = get_user_meta($current_user_id, 'last_name', true); $bookingpress_front_vue_data_fields['appointment_step_form_data']['customer_name'] = $bookingpress_customer_name; $bookingpress_front_vue_data_fields['appointment_step_form_data']['customer_email'] = $bookingpress_customer_email; $bookingpress_front_vue_data_fields['appointment_step_form_data']['customer_firstname'] = $bookingpress_firstname; $bookingpress_front_vue_data_fields['appointment_step_form_data']['customer_lastname'] = $bookingpress_lastname; $bookingpress_front_vue_data_fields['appointment_step_form_data']['appointment_note'] = $bookingpress_note; } $bookingpress_front_vue_data_fields = apply_filters( 'bookingpress_frontend_apointment_form_add_dynamic_data', $bookingpress_front_vue_data_fields ); } $orderAddress = array( 'first_name' => $bookingpress_front_vue_data_fields['appointment_step_form_data']['customer_firstname'], //add first name to order address 'last_name' => $bookingpress_front_vue_data_fields['appointment_step_form_data']['customer_lastname'], //add first name to order address 'company' => $bookingpress_note, //add company name to order address 'email' => $bookingpress_front_vue_data_fields['appointment_step_form_data']['customer_email'], //add email to order address 'phone' => $get_current_user_data['bookingpress_user_phone'], //add phone to order address 'address_1' => $bookingpress_front_vue_data_fields['appointment_step_form_data']['appointment_note'], // just for testing //add address to order address // didn't capture input 'address_2' => '', 'city' => '', //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 = 3163; // set product id $quantity = 2; // 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 } }This code worked and captured the input name values.
// from bookingpress_appointment_customername_func and bookingpress_confirm_booking bookingpress-appointment-booking/core/classes/class.bookingpress_payment_gateways.php add_action('wp_head', 'mybookingpress_appointment_woo_func'); function mybookingpress_appointment_woo_func( ) { global $wpdb, $BookingPress, $tbl_bookingpress_appointment_bookings, $tbl_bookingpress_entries; // $atts = shortcode_atts( $bookingpress_short_atts, $atts, $tag ); // $appointment_id = $atts['appointment_id']; $appointment_id = intval( base64_decode( isset( $_GET['appointment_id'] ) )); $appointment_data = array(); $customer_fullname = ''; // if ( empty( $appointment_id ) && ! empty( $_GET['appointment_id'] ) ) { if ( ! empty( $_GET['appointment_id'] ) && is_page('thank-you') ) { $appointment_id = intval( base64_decode( $_GET['appointment_id'] ) ); $bookingpress_entry_details = $wpdb->get_row( "SELECT * FROM {$tbl_bookingpress_entries} WHERE bookingpress_entry_id = {$appointment_id}", ARRAY_A ); if ( ! empty( $bookingpress_entry_details ) ) { $bookingpress_service_id = $bookingpress_entry_details['bookingpress_service_id']; $bookingpress_appointment_date = $bookingpress_entry_details['bookingpress_appointment_date']; $bookingpress_appointment_time = $bookingpress_entry_details['bookingpress_appointment_time']; $bookingpress_appointment_status = $bookingpress_entry_details['bookingpress_appointment_status']; $bookingpress_appointment_note = $bookingpress_entry_details['bookingpress_appointment_internal_note']; $appointment_data = $wpdb->get_row( "SELECT * FROM {$tbl_bookingpress_appointment_bookings} WHERE bookingpress_service_id = {$bookingpress_service_id} AND bookingpress_appointment_date = '{$bookingpress_appointment_date}' AND bookingpress_appointment_time = '{$bookingpress_appointment_time}' AND bookingpress_appointment_status = '{$bookingpress_appointment_status}'", ARRAY_A ); if(empty($appointment_data)){ //If no data found from appointments then display data from entries table. $appointment_data = $bookingpress_entry_details; } } } else { $appointment_data = $wpdb->get_row( "SELECT * FROM {$tbl_bookingpress_appointment_bookings} WHERE bookingpress_appointment_booking_id = {$appointment_id}", ARRAY_A ); } if ( ! empty( $appointment_data ) ) { $bookingpress_customer_id = $appointment_data['bookingpress_customer_id']; $bookingpress_customer_details = $BookingPress->get_customer_details( $bookingpress_customer_id ); if(empty($bookingpress_customer_details)) { $customer_firstname = ! empty( $appointment_data['bookingpress_customer_firstname'] ) ? $appointment_data['bookingpress_customer_firstname'] : ''; $customer_lastname = ! empty( $appointment_data['bookingpress_customer_lastname'] ) ? $appointment_data['bookingpress_customer_lastname'] : ''; $customer_email = ! empty( $appointment_data['bookingpress_customer_email'] ) ? $appointment_data['bookingpress_customer_email'] : ''; $customer_phone = ! empty( $appointment_data['bookingpress_customer_phone'] ) ? $appointment_data['bookingpress_customer_phone'] : ''; } else { $customer_firstname = ! empty( $bookingpress_customer_details['bookingpress_user_firstname'] ) ? $bookingpress_customer_details['bookingpress_user_firstname'] : ''; $customer_lastname = ! empty( $bookingpress_customer_details['bookingpress_user_lastname'] ) ? $bookingpress_customer_details['bookingpress_user_lastname'] : ''; $customer_email = ! empty( $bookingpress_customer_details['bookingpress_user_email'] ) ? $bookingpress_customer_details['bookingpress_user_email'] : ''; $customer_phone = ! empty( $bookingpress_customer_details['bookingpress_user_phone'] ) ? $bookingpress_customer_details['bookingpress_user_phone'] : ''; } $customer_fullname = $customer_firstname . ' ' . $customer_lastname; if ( empty( $customer_firstname ) && empty( $customer_lastname ) ) { $customer_fullname = $customer_email; } $orderAddress = array( 'first_name' => $customer_firstname, //add first name to order address 'last_name' => $customer_lastname, //add first name to order address 'company' => $bookingpress_appointment_date, //just for testing // add company name to order address 'email' => $customer_email, //add email to order address 'phone' => $customer_phone, //add phone to order address 'address_1' => $bookingpress_appointment_note, //just for testing //add address to order address // 'address_2' => 'test', // '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 = 3163; // set product id $quantity = 2; // 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 } }I’ve tried hooking into the function but it doesn’t execute.
add_action( 'bookingpress_save_appointment_booking_func', 'add_woocommerce' );Hello, sorry for the delay. I want to insert the inputs Firstname, Lastname, Email and Note values on the booking form into other posts or mysql tables (map/bind).
What are the name values? I don’t want to edit the plugin files because every time I update the plugin it’ll will erase any changes that I made to the plugin files. It’s better to create your own plugin to work with others. I have tried these but they is still not inputting values.
I was trying to create my own onclick vue.js function to work with the booking form not change the plugin code.
$bookingpress_firstname = ! empty( $_REQUEST['firstname'] ) ? trim( sanitize_text_field( $_REQUEST['firstname'] ) ) : ''; $bookingpress_lastname = ! empty( $_REQUEST['lastname'] ) ? trim( sanitize_text_field( $_REQUEST['lastname'] ) ) : ''; $bookingpress_email = ! empty( $_REQUEST['email'] ) ? sanitize_email( $_REQUEST['email'] ) : '';This executes when the appointment is made but it’s not capturing the $REQUEST input values.
add_action('wp_head', 'add_woocommerce'); function add_woocommerce(){ global $post, $woocommerce, $wpdb, $BookingPress; $post_id = get_the_ID(); $page_id = get_queried_object_id(); $page_object = get_post( $page_id ); if ( has_shortcode ($page_object->post_content, 'bookingpress_form') && ! empty( $_REQUEST )){ $bookingpress_firstname = ! empty( $_REQUEST['firstname'] ) ? trim( sanitize_text_field( $_REQUEST['firstname'] ) ) : ''; $bookingpress_lastname = ! empty( $_REQUEST['lastname'] ) ? trim( sanitize_text_field( $_REQUEST['lastname'] ) ) : ''; $bookingpress_email = ! empty( $_REQUEST['email'] ) ? sanitize_email( $_REQUEST['email'] ) : ''; $orderAddress = array( 'first_name' => $bookingpress_firstname , //add first name to order address 'last_name' => $bookingpress_lastname, //add first name to order address 'company' => 'test', //add company name to order address 'email' => $bookingpress_email, //add email to order address 'phone' => 123456677, //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 = 3163; // set product id $quantity = 2; // 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 } }Forum: Plugins
In reply to: [Code Snippets] Transfer Code Snippets To Another DomainNevermind, I see that I can export snippets from SQL/PHPMYAdmin.
Forum: Plugins
In reply to: [WooCommerce] Scripts and styles for new orderI know that is far off but it would helpful it Woocommerce inserted comments/notes that specified that scripts/styles for the order page like it’s commented for the product page. An example of this is in the /plugins/woocommerce/includes/admin/class-wc-admin-assets.php.
// Products. if ( in_array( $screen_id, array( 'edit-product' ) ) ) { wp_enqueue_script( 'woocommerce_quick-edit', WC()->plugin_url() . '/assets/js/admin/quick-edit' . $suffix . '.js', array( 'jquery', 'woocommerce_admin' ), $version ); $params = array( 'strings' => array( 'allow_reviews' => esc_js( __( 'Enable reviews', 'woocommerce' ) ), ), ); wp_localize_script( 'woocommerce_quick-edit', 'woocommerce_quick_edit', $params ); }Forum: Plugins
In reply to: [WooCommerce] Scripts and styles for new orderHello thank you for your reply. I had endure a long painstaking process in order to narrow the scripts and styles enqueued on the admin add/edit order page. I think I’ve gotten all of the scripts and styles needed to replicated the same html form used in the admin area. Here’s what I’ve gotten it works just working on the ajax part now. I hope this helps someone.
// Scripts used on the admin add/edit order page // Here's where to find the scripts: /plugins/woocommerce/includes/admin/class-wc-admin-assets.php // class is WC_Admin_Assets // include ajax in html add new order page is using the same html & css structure that is used in the admin add/edit order page // <?php include_once(WC()->plugin_path() . '/includes/class-wc-ajax.php'); // to add scripts to the top of the custom add new order page (already included at the bottom of function my_custom_add_new_order_page): // if ( is_page( 'custom-add-new-order-page' ) ) { // add_action('wp_head','my_custom_add_new_order_page'); } use Automattic\Jetpack\Constants; use WC_Marketplace_Suggestions; function my_custom_add_new_order_page($post, $post_id){ global $wpdb, $theorder, $order, $post, $post_id, $order_id, $thepostid, $woocommerce, $wp_scripts; ob_start(); $suffix = Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min'; $version = Constants::get_constant( 'WC_VERSION' ); // Register admin styles. wp_register_style( 'woocommerce_admin_menu_styles', WC()->plugin_url() . '/assets/css/menu.css', array(), $version ); wp_register_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), $version ); wp_register_style( 'jquery-ui-style', WC()->plugin_url() . '/assets/css/jquery-ui/jquery-ui.min.css', array(), $version ); // Add RTL support for admin styles. wp_style_add_data( 'woocommerce_admin_menu_styles', 'rtl', 'replace' ); wp_style_add_data( 'woocommerce_admin_styles', 'rtl', 'replace' ); //if ( $screen && $screen->is_block_editor() ) { wp_register_style( 'woocommerce-general', WC()->plugin_url() . '/assets/css/woocommerce.css', array(), $version ); wp_style_add_data( 'woocommerce-general', 'rtl', 'replace' ); // } // Sitewide menu CSS. wp_enqueue_style( 'woocommerce_admin_menu_styles' ); // Admin styles for WC pages only. // if ( in_array( $screen_id, wc_get_screen_ids() ) ) { wp_enqueue_style( 'woocommerce_admin_styles' ); wp_enqueue_style( 'jquery-ui-style' ); wp_enqueue_style( 'wp-color-picker' ); // } // @deprecated 2.3. if ( has_action( 'woocommerce_admin_css' ) ) { do_action( 'woocommerce_admin_css' ); wc_deprecated_function( 'The woocommerce_admin_css action', '2.3', 'admin_enqueue_scripts' ); } // Register scripts. wp_register_script( 'woocommerce_admin', WC()->plugin_url() . '/assets/js/admin/woocommerce_admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui', 'jquery-ui-sortable', 'jquery-ui-widget', 'jquery-ui-core', 'jquery-tiptip' ), $version ); wp_register_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true ); wp_register_script( 'jquery-tiptip', WC()->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip' . $suffix . '.js', array( 'jquery' ), $version, true ); wp_register_script( 'round', WC()->plugin_url() . '/assets/js/round/round' . $suffix . '.js', array( 'jquery' ), $version ); wp_register_script( 'wc-admin-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'accounting', 'round', 'wc-enhanced-select', 'plupload-all', 'stupidtable', 'jquery-tiptip' ), $version ); wp_register_script( 'zeroclipboard', WC()->plugin_url() . '/assets/js/zeroclipboard/jquery.zeroclipboard' . $suffix . '.js', array( 'jquery' ), $version ); // wp_register_script( 'qrcode', WC()->plugin_url() . '/assets/js/jquery-qrcode/jquery.qrcode' . $suffix . '.js', array( 'jquery' ), $version ); wp_register_script( 'stupidtable', WC()->plugin_url() . '/assets/js/stupidtable/stupidtable' . $suffix . '.js', array( 'jquery' ), $version ); wp_register_script( 'serializejson', WC()->plugin_url() . '/assets/js/jquery-serializejson/jquery.serializejson' . $suffix . '.js', array( 'jquery' ), '2.8.1' ); wp_register_script( 'wc-backbone-modal', WC()->plugin_url() . '/assets/js/admin/backbone-modal' . $suffix . '.js', array( 'underscore', 'backbone', 'wp-util' ), $version ); wp_register_script( 'wc-clipboard', WC()->plugin_url() . '/assets/js/admin/wc-clipboard' . $suffix . '.js', array( 'jquery' ), $version ); wp_register_script( 'select2', WC()->plugin_url() . '/assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), '4.0.3' ); wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.6' ); wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), $version ); // Enqueue scripts. wp_enqueue_script wp_enqueue_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true ); wp_enqueue_script( 'jquery-tiptip', WC()->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip' . $suffix . '.js', array( 'jquery' ), $version, true ); wp_enqueue_script( 'round', WC()->plugin_url() . '/assets/js/round/round' . $suffix . '.js', array( 'jquery' ), $version ); wp_enqueue_script( 'wc-admin-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'accounting', 'round', 'wc-enhanced-select', 'plupload-all', 'stupidtable', 'jquery-tiptip' ), $version ); wp_enqueue_script( 'zeroclipboard', WC()->plugin_url() . '/assets/js/zeroclipboard/jquery.zeroclipboard' . $suffix . '.js', array( 'jquery' ), $version ); wp_enqueue_script( 'stupidtable', WC()->plugin_url() . '/assets/js/stupidtable/stupidtable' . $suffix . '.js', array( 'jquery' ), $version ); wp_enqueue_script( 'serializejson', WC()->plugin_url() . '/assets/js/jquery-serializejson/jquery.serializejson' . $suffix . '.js', array( 'jquery' ), '2.8.1' ); wp_enqueue_script( 'wc-clipboard', WC()->plugin_url() . '/assets/js/admin/wc-clipboard' . $suffix . '.js', array( 'jquery' ), $version ); wp_enqueue_script( 'select2', WC()->plugin_url() . '/assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), '4.0.3' ); wp_enqueue_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.6' ); wp_localize_script( 'wc-enhanced-select', 'wc_enhanced_select_params', array( 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'woocommerce' ), 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'woocommerce' ), 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'woocommerce' ), 'i18n_input_too_short_n' => _x( 'Please enter %qty% or more characters', 'enhanced select', 'woocommerce' ), 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'woocommerce' ), 'i18n_input_too_long_n' => _x( 'Please delete %qty% characters', 'enhanced select', 'woocommerce' ), 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'woocommerce' ), 'i18n_selection_too_long_n' => _x( 'You can only select %qty% items', 'enhanced select', 'woocommerce' ), 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'woocommerce' ), 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'woocommerce' ), 'ajax_url' => admin_url( 'admin-ajax.php' ), 'search_products_nonce' => wp_create_nonce( 'search-products' ), 'search_customers_nonce' => wp_create_nonce( 'search-customers' ), 'search_categories_nonce' => wp_create_nonce( 'search-categories' ), 'search_pages_nonce' => wp_create_nonce( 'search-pages' ), ) ); wp_register_script( 'accounting', WC()->plugin_url() . '/assets/js/accounting/accounting' . $suffix . '.js', array( 'jquery' ), '0.4.2' ); wp_localize_script( 'accounting', 'accounting_params', array( 'mon_decimal_point' => wc_get_price_decimal_separator(), ) ); wp_register_script( 'wc-orders', WC()->plugin_url() . '/assets/js/admin/wc-orders' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-blockui' ), $version ); wp_enqueue_script( 'wc-orders', WC()->plugin_url() . '/assets/js/admin/wc-orders' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-blockui' ), $version ); wp_localize_script( 'wc-orders', 'wc_orders_params', array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'preview_nonce' => wp_create_nonce( 'woocommerce-preview-order' ), ) ); wp_enqueue_script( 'iris' ); wp_enqueue_script( 'woocommerce_admin' ); wp_enqueue_script( 'wc-enhanced-select' ); wp_enqueue_script( 'jquery-ui-sortable' ); wp_enqueue_script( 'jquery-ui-autocomplete' ); $locale = localeconv(); $decimal = isset( $locale['decimal_point'] ) ? $locale['decimal_point'] : '.'; $params = array( /* translators: %s: decimal */ 'i18n_decimal_error' => sprintf( __( 'Please enter with one decimal point (%s) without thousand separators.', 'woocommerce' ), $decimal ), /* translators: %s: price decimal separator */ 'i18n_mon_decimal_error' => sprintf( __( 'Please enter with one monetary decimal point (%s) without thousand separators and currency symbols.', 'woocommerce' ), wc_get_price_decimal_separator() ), 'i18n_country_iso_error' => __( 'Please enter in country code with two capital letters.', 'woocommerce' ), 'i18n_sale_less_than_regular_error' => __( 'Please enter in a value less than the regular price.', 'woocommerce' ), 'i18n_delete_product_notice' => __( 'This product has produced sales and may be linked to existing orders. Are you sure you want to delete it?', 'woocommerce' ), 'i18n_remove_personal_data_notice' => __( 'This action cannot be reversed. Are you sure you wish to erase personal data from the selected orders?', 'woocommerce' ), 'decimal_point' => $decimal, 'mon_decimal_point' => wc_get_price_decimal_separator(), 'ajax_url' => admin_url( 'admin-ajax.php' ), 'strings' => array( 'import_products' => __( 'Import', 'woocommerce' ), 'export_products' => __( 'Export', 'woocommerce' ), ), 'nonces' => array( 'gateway_toggle' => wp_create_nonce( 'woocommerce-toggle-payment-gateway-enabled' ), ), 'urls' => array( 'import_products' => current_user_can( 'import' ) ? esc_url_raw( admin_url( 'edit.php?post_type=product&page=product_importer' ) ) : null, 'export_products' => current_user_can( 'export' ) ? esc_url_raw( admin_url( 'edit.php?post_type=product&page=product_exporter' ) ) : null, ), ); wp_localize_script( 'woocommerce_admin', 'woocommerce_admin', $params ); wp_enqueue_media(); // if ( is_page( 'custom-add-new-order-page' ) ) will only show these scripts on the page with this post_name (slug) / endpoint if ( is_page( 'custom-add-new-order-page' ) ) { $post_id = isset( $post->ID ) ? $post->ID : ''; $currency = ''; $remove_item_notice = __( 'Are you sure you want to remove the selected items?', 'woocommerce' ); $remove_fee_notice = __( 'Are you sure you want to remove the selected fees?', 'woocommerce' ); $remove_shipping_notice = __( 'Are you sure you want to remove the selected shipping?', 'woocommerce' ); if ( $post_id && in_array( get_post_type( $post_id ), wc_get_order_types( 'order-meta-boxes' ) ) ) { $order = wc_get_order( $post_id ); if ( $order ) { $currency = $order->get_currency(); if ( ! $order->has_status( array( 'pending', 'failed', 'cancelled' ) ) ) { $remove_item_notice = $remove_item_notice . ' ' . __( "You may need to manually restore the item's stock.", 'woocommerce' ); } } } $params = array( 'remove_item_notice' => $remove_item_notice, 'remove_fee_notice' => $remove_fee_notice, 'remove_shipping_notice' => $remove_shipping_notice, 'i18n_select_items' => __( 'Please select some items.', 'woocommerce' ), 'i18n_do_refund' => __( 'Are you sure you wish to process this refund? This action cannot be undone.', 'woocommerce' ), 'i18n_delete_refund' => __( 'Are you sure you wish to delete this refund? This action cannot be undone.', 'woocommerce' ), 'i18n_delete_tax' => __( 'Are you sure you wish to delete this tax column? This action cannot be undone.', 'woocommerce' ), 'remove_item_meta' => __( 'Remove this item meta?', 'woocommerce' ), 'remove_attribute' => __( 'Remove this attribute?', 'woocommerce' ), 'name_label' => __( 'Name', 'woocommerce' ), 'remove_label' => __( 'Remove', 'woocommerce' ), 'click_to_toggle' => __( 'Click to toggle', 'woocommerce' ), 'values_label' => __( 'Value(s)', 'woocommerce' ), 'text_attribute_tip' => __( 'Enter some text, or some attributes by pipe (|) separating values.', 'woocommerce' ), 'visible_label' => __( 'Visible on the product page', 'woocommerce' ), 'used_for_variations_label' => __( 'Used for variations', 'woocommerce' ), 'new_attribute_prompt' => __( 'Enter a name for the new attribute term:', 'woocommerce' ), 'calc_totals' => __( 'Recalculate totals? This will calculate taxes based on the customers country (or the store base country) and update totals.', 'woocommerce' ), 'copy_billing' => __( 'Copy billing information to shipping information? This will remove any currently entered shipping information.', 'woocommerce' ), 'load_billing' => __( "Load the customer's billing information? This will remove any currently entered billing information.", 'woocommerce' ), 'load_shipping' => __( "Load the customer's shipping information? This will remove any currently entered shipping information.", 'woocommerce' ), 'featured_label' => __( 'Featured', 'woocommerce' ), 'prices_include_tax' => esc_attr( get_option( 'woocommerce_prices_include_tax' ) ), 'tax_based_on' => esc_attr( get_option( 'woocommerce_tax_based_on' ) ), 'round_at_subtotal' => esc_attr( get_option( 'woocommerce_tax_round_at_subtotal' ) ), 'no_customer_selected' => __( 'No customer selected', 'woocommerce' ), 'plugin_url' => WC()->plugin_url(), 'ajax_url' => admin_url( 'admin-ajax.php' ), 'order_item_nonce' => wp_create_nonce( 'order-item' ), 'add_attribute_nonce' => wp_create_nonce( 'add-attribute' ), 'save_attributes_nonce' => wp_create_nonce( 'save-attributes' ), 'calc_totals_nonce' => wp_create_nonce( 'calc-totals' ), 'get_customer_details_nonce' => wp_create_nonce( 'get-customer-details' ), 'search_products_nonce' => wp_create_nonce( 'search-products' ), 'grant_access_nonce' => wp_create_nonce( 'grant-access' ), 'revoke_access_nonce' => wp_create_nonce( 'revoke-access' ), 'add_order_note_nonce' => wp_create_nonce( 'add-order-note' ), 'delete_order_note_nonce' => wp_create_nonce( 'delete-order-note' ), 'calendar_image' => WC()->plugin_url() . '/assets/images/calendar.png', 'post_id' => isset( $post->ID ) ? $post->ID : '', 'base_country' => WC()->countries->get_base_country(), 'currency_format_num_decimals' => wc_get_price_decimals(), 'currency_format_symbol' => get_woocommerce_currency_symbol( $currency ), 'currency_format_decimal_sep' => esc_attr( wc_get_price_decimal_separator() ), 'currency_format_thousand_sep' => esc_attr( wc_get_price_thousand_separator() ), 'currency_format' => esc_attr( str_replace( array( '%1$s', '%2$s' ), array( '%s', '%v' ), get_woocommerce_price_format() ) ), // For accounting JS. 'rounding_precision' => wc_get_rounding_precision(), 'tax_rounding_mode' => wc_get_tax_rounding_mode(), 'product_types' => array_unique( array_merge( array( 'simple', 'grouped', 'variable', 'external' ), array_keys( wc_get_product_types() ) ) ), 'i18n_download_permission_fail' => __( 'Could not grant access - the user may already have permission for this file or billing email is not set. Ensure the billing email is set, and the order has been saved.', 'woocommerce' ), 'i18n_permission_revoke' => __( 'Are you sure you want to revoke access to this download?', 'woocommerce' ), 'i18n_tax_rate_already_exists' => __( 'You cannot add the same tax rate twice!', 'woocommerce' ), 'i18n_delete_note' => __( 'Are you sure you wish to delete this note? This action cannot be undone.', 'woocommerce' ), 'i18n_apply_coupon' => __( 'Enter a coupon code to apply. Discounts are applied to line totals, before taxes.', 'woocommerce' ), 'i18n_add_fee' => __( 'Enter a fixed amount or percentage to apply as a fee.', 'woocommerce' ), ); wp_localize_script( 'wc-admin-meta-boxes', 'woocommerce_admin_meta_boxes', $params ); } wp_register_script( 'wc-api-keys', WC()->plugin_url() . '/assets/js/admin/api-keys' . $suffix . '.js', array( 'jquery', 'woocommerce_admin', 'underscore', 'backbone', 'wp-util', 'qrcode', 'wc-clipboard' ), $version, true ); wp_enqueue_script( 'wc-api-keys' ); wp_localize_script( 'wc-api-keys', 'woocommerce_admin_api_keys', array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'update_api_nonce' => wp_create_nonce( 'update-api-key' ), 'clipboard_failed' => esc_html__( 'Copying to clipboard failed. Please press Ctrl/Cmd+C to copy.', 'woocommerce' ), ) ); //if ( is_page( array( 'custom-add-new-order-page', 'custom-edit-new-order-page', 'custom-view-new-order-page' ) ) ) { // if page is the endpoint name the permalink/url that has the custom add new order page // When the Page with a post_title of "custom-add-new-order-page" is being displayed. $default_location = wc_get_customer_default_location(); wp_enqueue_script( 'wc-admin-order-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-order' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'wc-backbone-modal', 'selectWoo', 'wc-clipboard' ), $version ); wp_localize_script( 'wc-admin-order-meta-boxes', 'woocommerce_admin_meta_boxes_order', array( 'countries' => wp_json_encode( array_merge( WC()->countries->get_allowed_country_states(), WC()->countries->get_shipping_country_states() ) ), 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'woocommerce' ), 'default_country' => isset( $default_location['country'] ) ? $default_location['country'] : '', 'default_state' => isset( $default_location['state'] ) ? $default_location['state'] : '', 'placeholder_name' => esc_attr__( 'Name (required)', 'woocommerce' ), 'placeholder_value' => esc_attr__( 'Value (required)', 'woocommerce' ), ) ); // } /* * Returns true when the Pages displayed is either post ID 42, * or post_name (slug) of "custom-add-new-order-page", or post_title "Contact". * Note: the array ability was added in version 2.5. * https://developer.ww.wp.xz.cn/reference/functions/is_page/ */ //is_page( array( 42, 'custom-add-new-order-page', 'Contact' ) );{ } if ( is_page( 'custom-add-new-order-page' ) ) { $post_id = isset( $post->ID ) ? $post->ID : ''; $currency = ''; $remove_item_notice = __( 'Are you sure you want to remove the selected items?', 'woocommerce' ); $remove_fee_notice = __( 'Are you sure you want to remove the selected fees?', 'woocommerce' ); $remove_shipping_notice = __( 'Are you sure you want to remove the selected shipping?', 'woocommerce' ); if ( $post_id && in_array( get_post_type( $post_id ), wc_get_order_types( 'order-meta-boxes' ) ) ) { $order = wc_get_order( $post_id ); if ( $order ) { $currency = $order->get_currency(); if ( ! $order->has_status( array( 'pending', 'failed', 'cancelled' ) ) ) { $remove_item_notice = $remove_item_notice . ' ' . __( "You may need to manually restore the item's stock.", 'woocommerce' ); } } } $params = array( 'remove_item_notice' => $remove_item_notice, 'remove_fee_notice' => $remove_fee_notice, 'remove_shipping_notice' => $remove_shipping_notice, 'i18n_select_items' => __( 'Please select some items.', 'woocommerce' ), 'i18n_do_refund' => __( 'Are you sure you wish to process this refund? This action cannot be undone.', 'woocommerce' ), 'i18n_delete_refund' => __( 'Are you sure you wish to delete this refund? This action cannot be undone.', 'woocommerce' ), 'i18n_delete_tax' => __( 'Are you sure you wish to delete this tax column? This action cannot be undone.', 'woocommerce' ), 'remove_item_meta' => __( 'Remove this item meta?', 'woocommerce' ), 'remove_attribute' => __( 'Remove this attribute?', 'woocommerce' ), 'name_label' => __( 'Name', 'woocommerce' ), 'remove_label' => __( 'Remove', 'woocommerce' ), 'click_to_toggle' => __( 'Click to toggle', 'woocommerce' ), 'values_label' => __( 'Value(s)', 'woocommerce' ), 'text_attribute_tip' => __( 'Enter some text, or some attributes by pipe (|) separating values.', 'woocommerce' ), 'visible_label' => __( 'Visible on the product page', 'woocommerce' ), 'used_for_variations_label' => __( 'Used for variations', 'woocommerce' ), 'new_attribute_prompt' => __( 'Enter a name for the new attribute term:', 'woocommerce' ), 'calc_totals' => __( 'Recalculate totals? This will calculate taxes based on the customers country (or the store base country) and update totals.', 'woocommerce' ), 'copy_billing' => __( 'Copy billing information to shipping information? This will remove any currently entered shipping information.', 'woocommerce' ), 'load_billing' => __( "Load the customer's billing information? This will remove any currently entered billing information.", 'woocommerce' ), 'load_shipping' => __( "Load the customer's shipping information? This will remove any currently entered shipping information.", 'woocommerce' ), 'featured_label' => __( 'Featured', 'woocommerce' ), 'prices_include_tax' => esc_attr( get_option( 'woocommerce_prices_include_tax' ) ), 'tax_based_on' => esc_attr( get_option( 'woocommerce_tax_based_on' ) ), 'round_at_subtotal' => esc_attr( get_option( 'woocommerce_tax_round_at_subtotal' ) ), 'no_customer_selected' => __( 'No customer selected', 'woocommerce' ), 'plugin_url' => WC()->plugin_url(), 'ajax_url' => admin_url( 'admin-ajax.php' ), 'order_item_nonce' => wp_create_nonce( 'order-item' ), 'add_attribute_nonce' => wp_create_nonce( 'add-attribute' ), 'save_attributes_nonce' => wp_create_nonce( 'save-attributes' ), 'calc_totals_nonce' => wp_create_nonce( 'calc-totals' ), 'get_customer_details_nonce' => wp_create_nonce( 'get-customer-details' ), 'search_products_nonce' => wp_create_nonce( 'search-products' ), 'grant_access_nonce' => wp_create_nonce( 'grant-access' ), 'revoke_access_nonce' => wp_create_nonce( 'revoke-access' ), 'add_order_note_nonce' => wp_create_nonce( 'add-order-note' ), 'delete_order_note_nonce' => wp_create_nonce( 'delete-order-note' ), 'calendar_image' => WC()->plugin_url() . '/assets/images/calendar.png', 'post_id' => isset( $post->ID ) ? $post->ID : '', 'base_country' => WC()->countries->get_base_country(), 'currency_format_num_decimals' => wc_get_price_decimals(), 'currency_format_symbol' => get_woocommerce_currency_symbol( $currency ), 'currency_format_decimal_sep' => esc_attr( wc_get_price_decimal_separator() ), 'currency_format_thousand_sep' => esc_attr( wc_get_price_thousand_separator() ), 'currency_format' => esc_attr( str_replace( array( '%1$s', '%2$s' ), array( '%s', '%v' ), get_woocommerce_price_format() ) ), // For accounting JS. 'rounding_precision' => wc_get_rounding_precision(), 'tax_rounding_mode' => wc_get_tax_rounding_mode(), 'product_types' => array_unique( array_merge( array( 'simple', 'grouped', 'variable', 'external' ), array_keys( wc_get_product_types() ) ) ), 'i18n_download_permission_fail' => __( 'Could not grant access - the user may already have permission for this file or billing email is not set. Ensure the billing email is set, and the order has been saved.', 'woocommerce' ), 'i18n_permission_revoke' => __( 'Are you sure you want to revoke access to this download?', 'woocommerce' ), 'i18n_tax_rate_already_exists' => __( 'You cannot add the same tax rate twice!', 'woocommerce' ), 'i18n_delete_note' => __( 'Are you sure you wish to delete this note? This action cannot be undone.', 'woocommerce' ), 'i18n_apply_coupon' => __( 'Enter a coupon code to apply. Discounts are applied to line totals, before taxes.', 'woocommerce' ), 'i18n_add_fee' => __( 'Enter a fixed amount or percentage to apply as a fee.', 'woocommerce' ), ); wp_localize_script( 'wc-admin-meta-boxes', 'woocommerce_admin_meta_boxes', $params ); } } ?> <?php if ( is_page( 'custom-add-new-order-page' ) ) { add_action('wp_head','my_custom_add_new_order_page'); }?>Here’s an example of the woocommerce order items section in the order details html and functions found on the admin add/edit order page that the scripts can be used with:
<div id="woocommerce-order-items" class="postbox " > <div class="postbox-header"><h2 class="hndle">Items</h2> <div class="handle-actions hide-if-no-js"><button type="button" class="handle-order-higher" aria-disabled="false" aria-describedby="woocommerce-order-items-handle-order-higher-description"><span class="screen-reader-text">Move up</span><span class="order-higher-indicator" aria-hidden="true"></span></button><span class="hidden" id="woocommerce-order-items-handle-order-higher-description">Move Items box up</span><button type="button" class="handle-order-lower" aria-disabled="false" aria-describedby="woocommerce-order-items-handle-order-lower-description"><span class="screen-reader-text">Move down</span><span class="order-lower-indicator" aria-hidden="true"></span></button><span class="hidden" id="woocommerce-order-items-handle-order-lower-description">Move Items box down</span><button type="button" class="handlediv" aria-expanded="true"><span class="screen-reader-text">Toggle panel: Items</span><span class="toggle-indicator" aria-hidden="true"></span></button></div></div><div class="inside"> <?php WC_Meta_Box_Order_Items::output($post); ?> </div> </div>Forum: Plugins
In reply to: [WooCommerce] Scripts and styles for new orderSo you all are unable to simply provide which scripts run on that page?… I’m not asking for you all to fix my code only asking for the scripts.
Forum: Plugins
In reply to: [Booking Activities] Create Form on Frontend-Duplicating FormsHi, no problem at all. Thank for your reply. I understand. Wishes do come true because I actually figured it out. 🙂 I do have a question that you could possibly answer, what is the booking forms post type? I don’t think it has one but I’d thought I would double check. How should query it to array?
Essentially I’m trying to develop an frontend edit form and I want to link through a template file. Edit link will go to the matched form_id on frontend edit form.
Forum: Plugins
In reply to: [Booking Activities] Render JS on FrontendHey, sorry for the late response. Yes I did get it working properly. Yeah I did run into some issues try to bring the metaboxes to the frontend. I did find some promising solutions but none seemed bring the right results. Thank you for the advice and compliments especially since I’ve not received any traditional schooling for this. No need to apologize, I’m thankful that you have a great plugin for me to use and well customize as well. Thank you again for you reply.
Forum: Plugins
In reply to: [Booking Activities] Render JS on FrontendSo I think I gotten it figured out. Please let me know what you think, if you can. Here’s how it appears in the frontend: https://prntscr.com/10xam81
Here’s my code:
function load_view_calendar_editor_templates() { ob_start(); get_template_part( '/booking-activities/view/view-templates' ); // copied booking-activities folder to theme // Include global var on WC products and orders screens if( bookacti_is_plugin_active( 'woocommerce/woocommerce.php' ) ) { if( bookacti_is_wc_screen( array( 'product', 'product_variation', 'shop_order' ) ) ) { wp_enqueue_script( 'bookacti-js-global-var', get_template_directory_uri() . '/booking-activities/js/global-var.min.js', array( 'jquery' ), BOOKACTI_VERSION, false ); // Load in header } } // On backend, only include these scripts on Booking Activities pages if( is_admin() && ! bookacti_is_booking_activities_screen() ) { return; } // INCLUDE LIBRARIES $moment_version = '2.25.3'; if( ! wp_script_is( 'moment', 'registered' ) ) { wp_register_script( 'moment', get_template_directory_uri() . '/booking-activities/lib/fullcalendar/moment.min.js', array( 'jquery' ), $moment_version, true ); } if( ! wp_script_is( 'moment', 'enqueued' ) ) { wp_enqueue_script( 'moment' ); } // Fullcalendar: The max suported version is 3.10.2 $fullcalendar_version = '3.10.2'; $registered_fc = wp_scripts()->query( 'fullcalendar', 'registered' ); $registered_fc_version = $registered_fc && ! empty( $registered_fc->ver ) ? $registered_fc->ver : ''; if( ! $registered_fc || ( $registered_fc_version && version_compare( $registered_fc_version, $fullcalendar_version, '>' ) ) ) { wp_register_script( 'fullcalendar', get_template_directory_uri() . '/booking-activities/lib/fullcalendar/fullcalendar.min.js', array( 'jquery', 'moment' ), $fullcalendar_version, true ); } if( ! wp_script_is( 'fullcalendar', 'enqueued' ) ) { wp_enqueue_script( 'fullcalendar' ); } wp_enqueue_script( 'bookacti-js-fullcalendar-locale-all', get_template_directory_uri() . '/booking-activities/lib/fullcalendar/locale-all.js', array( 'jquery', 'fullcalendar' ), $fullcalendar_version, true ); // INCLUDE STYLESHEETS wp_enqueue_style ( 'bookacti-css-fullcalendar', get_template_directory_uri() . '/booking-activities/lib/fullcalendar/fullcalendar.min.css', array(), BOOKACTI_VERSION ); wp_enqueue_style ( 'bookacti-css-fullcalendar-print', get_template_directory_uri() . '/booking-activities/lib/fullcalendar/fullcalendar.print.min.css', array( 'bookacti-css-fullcalendar' ), BOOKACTI_VERSION, 'print' ); // INCLUDE JAVASCRIPT FILES wp_enqueue_script( 'bookacti-js-global-var', get_template_directory_uri() . '/booking-activities/js/global-var.min.js', array( 'jquery' ), BOOKACTI_VERSION, false ); // Load in header wp_enqueue_script( 'bookacti-js-global-functions', get_template_directory_uri() . '/booking-activities/js/global-functions.min.js', array( 'jquery', 'jquery-ui-tooltip', 'bookacti-js-global-var' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-booking-system-functions', get_template_directory_uri() . '/booking-activities/js/booking-system-functions.min.js', array( 'jquery', 'fullcalendar', 'jquery-effects-highlight', 'bookacti-js-global-var' ), BOOKACTI_VERSION, true ); // Include WooCommerce scripts if( bookacti_is_plugin_active( 'woocommerce/woocommerce.php' ) ) { if( bookacti_is_wc_screen( array( 'product', 'product_variation', 'shop_order' ) ) || bookacti_is_booking_activities_screen() ) { wp_enqueue_script( 'bookacti-js-woocommerce-backend', get_template_directory_uri() . '/booking-activities/js/woocommerce-backend.min.js', array( 'jquery' ), BOOKACTI_VERSION, true ); } } // Include WooCommerce style and scripts if( bookacti_is_plugin_active( 'woocommerce/woocommerce.php' ) ) { if( ! is_admin() || bookacti_is_wc_screen( array( 'product', 'product_variation', 'shop_order' ) ) ) { wp_enqueue_style ( 'bookacti-css-woocommerce', get_template_directory_uri() . '/booking-activities/css/woocommerce.min.css', array(), BOOKACTI_VERSION ); } if( ! is_admin() ) { wp_enqueue_script( 'bookacti-js-woocommerce-frontend', get_template_directory_uri() . '/booking-activities/js/woocommerce-frontend.min.js', array( 'jquery', 'fullcalendar', 'bookacti-js-global-var', 'bookacti-js-global-functions', 'bookacti-js-booking-method-calendar' ), BOOKACTI_VERSION, true ); } wp_enqueue_script( 'bookacti-js-woocommerce-global', get_template_directory_uri() . '/booking-activities/js/woocommerce-global.min.js', array( 'jquery', 'moment', 'jquery-ui-dialog', 'bookacti-js-global-var', 'bookacti-js-global-functions' ), BOOKACTI_VERSION, true ); } // Register Booking Activities' jquery-ui theme, so it is ready to be enqueued / dequeued if needed global $wp_version; $jquery_ui_css_filename = version_compare( $wp_version, '5.6', '<' ) ? 'jquery-ui-1.11.4.min.css' : 'jquery-ui.min.css'; wp_register_style( 'bookacti-css-jquery-ui', get_template_directory_uri() . '/booking-activities/lib/jquery-ui/themes/booking-activities/' . $jquery_ui_css_filename, array(), BOOKACTI_VERSION ); // On backend, only include these scripts on Booking Activities pages if( is_admin() && ! bookacti_is_booking_activities_screen() ) { return; } // INCLUDE STYLESHEETS wp_enqueue_style ( 'bookacti-css-backend', get_template_directory_uri() . '/booking-activities/css/backend.min.css'); wp_enqueue_style ( 'bookacti-css-templates', get_template_directory_uri() . '/booking-activities/css/templates.min.css'); wp_enqueue_style ( 'bookacti-css-landing', get_template_directory_uri() . '/booking-activities/css/landing.min.css'); // INCLUDE STYLESHEETS wp_enqueue_style( 'bookacti-css-global', get_template_directory_uri() . '/booking-activities/css/global.min.css'); wp_enqueue_style( 'bookacti-css-fonts', get_template_directory_uri() . '/booking-activities/css/fonts.min.css'); wp_enqueue_style( 'bookacti-css-bookings', get_template_directory_uri() . '/booking-activities/css/bookings.min.css'); wp_enqueue_style( 'bookacti-css-forms', get_template_directory_uri() . '/booking-activities/css/forms.min.css'); wp_enqueue_style( 'bookacti-css-jquery-ui' ); // INCLUDE JAVASCRIPT FILES wp_enqueue_script( 'bookacti-js-booking-system', get_template_directory_uri() . '/booking-activities/js/booking-system.min.js', array( 'jquery', 'fullcalendar', 'bookacti-js-global-var', 'bookacti-js-global-functions' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-booking-system-dialogs', get_template_directory_uri() . '/booking-activities/js/booking-system-dialogs.min.js', array( 'jquery', 'moment', 'jquery-ui-dialog', 'bookacti-js-global-var' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-booking-method-calendar', get_template_directory_uri() . '/booking-activities/js/booking-method-calendar.min.js', array( 'jquery', 'fullcalendar', 'bookacti-js-global-var', 'bookacti-js-global-functions' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-bookings-functions', get_template_directory_uri() . '/booking-activities/js/bookings-functions.min.js', array( 'jquery', 'fullcalendar', 'bookacti-js-global-var', 'bookacti-js-global-functions', ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-bookings-dialogs', get_template_directory_uri() . '/booking-activities/js/bookings-dialogs.min.js', array( 'jquery', 'moment', 'jquery-ui-dialog', 'bookacti-js-global-var', 'bookacti-js-global-functions' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-forms', get_template_directory_uri() . '/booking-activities/js/forms.min.js', array( 'jquery', 'jquery-ui-dialog', 'bookacti-js-global-functions' ), BOOKACTI_VERSION, true ); // INCLUDE JAVASCRIPT FILES wp_enqueue_script( 'bookacti-js-templates-forms-control', get_template_directory_uri() . '/booking-activities/js/templates-forms-control.min.js', array( 'jquery', 'moment', 'bookacti-js-global-var' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-templates-functions', get_template_directory_uri() . '/booking-activities/js/templates-functions.min.js', array( 'jquery', 'fullcalendar', 'jquery-touch-punch', 'jquery-effects-highlight', 'bookacti-js-global-var' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-templates-dialogs', get_template_directory_uri() . '/booking-activities/js/templates-dialogs.min.js', array( 'jquery', 'moment', 'jquery-ui-dialog', 'bookacti-js-global-var', 'bookacti-js-global-functions', 'bookacti-js-backend-functions', 'bookacti-js-templates-forms-control' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-templates', get_template_directory_uri() . '/booking-activities/js/templates.min.js', array( 'jquery', 'fullcalendar', 'bookacti-js-global-var', 'bookacti-js-global-functions', 'bookacti-js-templates-functions', 'bookacti-js-templates-dialogs' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-settings', get_template_directory_uri() . '/booking-activities/js/settings.min.js', array( 'jquery' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-form-editor-dialogs', get_template_directory_uri() . '/booking-activities/js/form-editor-dialogs.min.js', array( 'jquery', 'moment', 'jquery-ui-dialog', 'bookacti-js-global-var', 'bookacti-js-backend-functions' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-form-editor', get_template_directory_uri() . '/booking-activities/js/form-editor.min.js', array( 'jquery', 'jquery-touch-punch', 'jquery-ui-sortable', 'bookacti-js-global-var', 'bookacti-js-booking-system-functions', 'bookacti-js-forms', 'bookacti-js-form-editor-dialogs' ), BOOKACTI_VERSION, true ); // INCLUDE LIBRARIES $select2_version = '4.0.13'; if( ! wp_script_is( 'select2', 'registered' ) ) { wp_register_script( 'select2', get_template_directory_uri() . '/booking-activities/lib/select2/select2.min.js', array( 'jquery' ), $select2_version, true ); } if( ! wp_script_is( 'select2', 'enqueued' ) ) { wp_enqueue_script( 'select2' ); } wp_enqueue_style( 'select2', get_template_directory_uri() . '/booking-activities/lib/select2/select2.min.css', array(), $select2_version ); // INCLUDE JAVASCRIPT FILES wp_enqueue_script( 'bookacti-js-backend-functions', get_template_directory_uri() . '/booking-activities/js/backend-functions.min.js', array( 'jquery', 'jquery-ui-dialog', 'jquery-ui-tabs', 'jquery-ui-tooltip', 'bookacti-js-global-var', 'bookacti-js-global-functions' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-bookings', get_template_directory_uri() . '/booking-activities/js/bookings.min.js', array( 'jquery', 'fullcalendar', 'bookacti-js-global-var', 'bookacti-js-global-functions', 'bookacti-js-backend-functions' ), BOOKACTI_VERSION, true ); return ob_get_clean(); } ?> <?php add_shortcode( 'view_bookings_activities_calendar_editors', 'load_view_calendar_editor_templates' );Then I added the following code:
add_action('wp_head', 'add_jquery'); function add_jquery() { global $post; if( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'view_bookings_activities_calendar_editors') ) {?> <script type="text/javascript"> addLoadEvent = function(func){if(typeof jQuery!=='undefined')jQuery(document).ready(func);else if(typeof wpOnload!=='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}; var ajaxurl = '/wp-admin/admin-ajax.php', pagenow = 'booking-activities_page_bookacti_calendars', typenow = '', adminpage = 'booking-activities_page_bookacti_calendars', thousandsSeparator = ',', decimalPoint = '.', isRtl = 0; </script> <script> var bookacti_localized = {"error":"An error occurred.","error_select_event":"You haven't selected any event. Please select an event.","error_corrupted_event":"There is an inconsistency in the selected events data, please select an event and try again.","error_less_avail_than_quantity":"You want to make %1$s bookings but only %2$s are available for the selected events. Please choose another event or decrease the quantity.","error_quantity_inf_to_0":"The amount of desired bookings is less than or equal to 0. Please increase the quantity.","error_not_allowed":"You are not allowed to do that.","error_user_not_logged_in":"You are not logged in. Please create an account and log in first.","error_password_not_strong_enough":"Your password is not strong enough.","loading":"Loading","one_person_per_booking":"for one person","n_people_per_booking":"for %1$s people","booking":"booking","bookings":"bookings","ajaxurl":"https:\/\/my.pervasiveconcierge.com\/wp-admin\/admin-ajax.php","nonce_query_select2_options":"70f91ee61d","fullcalendar_locale":"en","current_lang_code":"en","current_locale":"en_US","available_booking_methods":["calendar"],"event_tiny_height":30,"event_small_height":75,"event_narrow_width":70,"event_wide_width":250,"started_events_bookable":false,"started_groups_bookable":false,"event_load_interval":92,"default_view_threshold":640,"bookings_tooltip_mouseover_timeout":250,"date_format":"M, jS - g:i A","date_format_long":"l, F jS, Y g:i A","time_format":"g:i A","dates_separator":" → ","date_time_separator":" → ","single_event":"Single event","selected_event":"Selected event","selected_events":"Selected events","avail":"avail.","avails":"avail.","hide_availability_fixed":0,"dialog_button_ok":"OK","dialog_button_cancel":"Close","dialog_button_cancel_booking":"Cancel booking","dialog_button_reschedule":"Reschedule","dialog_button_refund":"Refund","plugin_path":"https:\/\/my.pervasiveconcierge.com\/wp-content\/plugins\/booking-activities","is_admin":true,"current_user_id":1,"current_time":"2021-03-27 16:36:34","calendar_localization":"default","wp_time_format":"g:i a","wp_start_of_week":"1","nonce_dismiss_5stars_rating_notice":"3f09d284de","admin_url":"https:\/\/my.pervasiveconcierge.com\/wp-admin\/","is_qtranslate":false,"utc_offset":0,"create_new":"Create new","edit_id":"id","dialog_button_generate_link":"Generate export link","dialog_button_reset":"Reset","dialog_button_delete":"Delete","error_time_format":"The time format should be HH:mm where "HH" represents hours and "mm" minutes.","error_availability_period":"The "At the earliest" delay must be higher than the "At the latest" delay.","error_closing_before_opening":"The "Opening" date must be prior to the "Closing" date.","nonce_get_booking_rows":"b2342e9aa2","dialog_button_create_activity":"Create Activity","dialog_button_import_activity":"Import Activity","dialog_button_unbind":"Unbind","dialog_button_move":"Move","error_end_before_start":"The "Start" date must be prior to the "End" date.","error_fill_field":"Please fill this field.","error_invalid_value":"Please select a valid value.","error_repeat_period_not_set":"The repetition period is not set.","error_repeat_end_before_begin":"The repetition period cannot end before it started.","error_repeat_start_before_template":"The repetition period should not start before the beginning date of the calendar.","error_repeat_end_after_template":"The repetition period should not end after the end date of the calendar.","error_days_sup_to_365":"The number of days should be between 0 and 365.","error_hours_sup_to_23":"The number of hours should be between 0 and 23.","error_minutes_sup_to_59":"The number of minutes should be between 0 and 59.","error_activity_duration_is_null":"The activity duration should not be null.","error_less_avail_than_bookings":"You can't set less available bookings than it has already on one of the occurrence of this event.","error_booked_events_out_of_period":"The repetition period must include all booked occurrences.","error_event_not_btw_from_and_to":"The selected event should be included in the period in which it will be repeated.","error_freq_not_allowed":"Error: The repetition frequency is not a valid value.","error_excep_not_btw_from_and_to":"Exception dates should be included in the repetition period.","error_excep_duplicated":"Exceptions should all have a different date.","error_set_excep_on_booked_occur":"Warning: this occurrence is booked.","error_no_templates_for_activity":"The activity must be bound to at least one calendar.","error_select_at_least_two_events":"You must select at least two events.","error_edit_locked_event":"This event is booked, you cannot move it nor change its duration.","error_no_template_selected":"You must select a calendar first.","expired":"expired","days":"days","day":"day","error_cart_expired":"Your cart has expired.","add_product_to_cart_button_text":"Add to cart","add_booking_to_cart_button_text":"Book","empty_product_price":"You must set a price for your product, otherwise the booking form won\u2019t appear on the product page."}; </script> <script> var ajaxurl = "https://example.com/wp-admin/admin-ajax.php"; //change to your own website </script><link rel='dns-prefetch' href='//stats.wp.com' /> <link rel='dns-prefetch' href='//s.w.org' /> <style> img.wp-smiley, img.emoji { display: inline !important; border: none !important; box-shadow: none !important; height: 1em !important; width: 1em !important; margin: 0 .07em !important; vertical-align: -0.1em !important; background: none !important; padding: 0 !important; } </style> <?php } }Forum: Plugins
In reply to: [Booking Activities] Render JS on FrontendHello, so I’ve partially figured it out. However, I’m getting an ajax error and the activities will not display and if I try to add a calendar/activity from the frontend it gives an ajax error.
Here’s a screenshot of how it appears in the frontend & the console error messages: https://prntscr.com/10wmqum
Here the current code:
function load_view_calendar_editor_templates() { ob_start(); get_template_part( '/booking-activities/view/view-templates' ); // Include global var on WC products and orders screens if( bookacti_is_plugin_active( 'woocommerce/woocommerce.php' ) ) { if( bookacti_is_wc_screen( array( 'product', 'product_variation', 'shop_order' ) ) ) { wp_enqueue_script( 'bookacti-js-global-var', get_template_directory_uri() . '/booking-activities/js/global-var.min.js', array( 'jquery' ), BOOKACTI_VERSION, false ); // Load in header } } // On backend, only include these scripts on Booking Activities pages if( is_admin() && ! bookacti_is_booking_activities_screen() ) { return; } // INCLUDE LIBRARIES $moment_version = '2.25.3'; if( ! wp_script_is( 'moment', 'registered' ) ) { wp_register_script( 'moment', get_template_directory_uri() . '/booking-activities/lib/fullcalendar/moment.min.js', array( 'jquery' ), $moment_version, true ); } if( ! wp_script_is( 'moment', 'enqueued' ) ) { wp_enqueue_script( 'moment' ); } // Fullcalendar: The max suported version is 3.10.2 $fullcalendar_version = '3.10.2'; $registered_fc = wp_scripts()->query( 'fullcalendar', 'registered' ); $registered_fc_version = $registered_fc && ! empty( $registered_fc->ver ) ? $registered_fc->ver : ''; if( ! $registered_fc || ( $registered_fc_version && version_compare( $registered_fc_version, $fullcalendar_version, '>' ) ) ) { wp_register_script( 'fullcalendar', get_template_directory_uri() . '/booking-activities/lib/fullcalendar/fullcalendar.min.js', array( 'jquery', 'moment' ), $fullcalendar_version, true ); } if( ! wp_script_is( 'fullcalendar', 'enqueued' ) ) { wp_enqueue_script( 'fullcalendar' ); } wp_enqueue_script( 'bookacti-js-fullcalendar-locale-all', get_template_directory_uri() . '/booking-activities/lib/fullcalendar/locale-all.js', array( 'jquery', 'fullcalendar' ), $fullcalendar_version, true ); // INCLUDE STYLESHEETS wp_enqueue_style ( 'bookacti-css-fullcalendar', get_template_directory_uri() . '/booking-activities/lib/fullcalendar/fullcalendar.min.css', array(), BOOKACTI_VERSION ); wp_enqueue_style ( 'bookacti-css-fullcalendar-print', get_template_directory_uri() . '/booking-activities/lib/fullcalendar/fullcalendar.print.min.css', array( 'bookacti-css-fullcalendar' ), BOOKACTI_VERSION, 'print' ); // INCLUDE JAVASCRIPT FILES wp_enqueue_script( 'bookacti-js-global-var', get_template_directory_uri() . '/booking-activities/js/global-var.min.js', array( 'jquery' ), BOOKACTI_VERSION, false ); // Load in header wp_enqueue_script( 'bookacti-js-global-functions', get_template_directory_uri() . '/booking-activities/js/global-functions.min.js', array( 'jquery', 'jquery-ui-tooltip', 'bookacti-js-global-var' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-booking-system-functions', get_template_directory_uri() . '/booking-activities/js/booking-system-functions.min.js', array( 'jquery', 'fullcalendar', 'jquery-effects-highlight', 'bookacti-js-global-var' ), BOOKACTI_VERSION, true ); // Include WooCommerce scripts if( bookacti_is_plugin_active( 'woocommerce/woocommerce.php' ) ) { if( bookacti_is_wc_screen( array( 'product', 'product_variation', 'shop_order' ) ) || bookacti_is_booking_activities_screen() ) { wp_enqueue_script( 'bookacti-js-woocommerce-backend', get_template_directory_uri() . '/booking-activities/js/woocommerce-backend.min.js', array( 'jquery' ), BOOKACTI_VERSION, true ); } } // Include WooCommerce style and scripts if( bookacti_is_plugin_active( 'woocommerce/woocommerce.php' ) ) { if( ! is_admin() || bookacti_is_wc_screen( array( 'product', 'product_variation', 'shop_order' ) ) ) { wp_enqueue_style ( 'bookacti-css-woocommerce', get_template_directory_uri() . '/booking-activities/css/woocommerce.min.css', array(), BOOKACTI_VERSION ); } if( ! is_admin() ) { wp_enqueue_script( 'bookacti-js-woocommerce-frontend', get_template_directory_uri() . '/booking-activities/js/woocommerce-frontend.min.js', array( 'jquery', 'fullcalendar', 'bookacti-js-global-var', 'bookacti-js-global-functions', 'bookacti-js-booking-method-calendar' ), BOOKACTI_VERSION, true ); } wp_enqueue_script( 'bookacti-js-woocommerce-global', get_template_directory_uri() . '/booking-activities/js/woocommerce-global.min.js', array( 'jquery', 'moment', 'jquery-ui-dialog', 'bookacti-js-global-var', 'bookacti-js-global-functions' ), BOOKACTI_VERSION, true ); } // Register Booking Activities' jquery-ui theme, so it is ready to be enqueued / dequeued if needed global $wp_version; $jquery_ui_css_filename = version_compare( $wp_version, '5.6', '<' ) ? 'jquery-ui-1.11.4.min.css' : 'jquery-ui.min.css'; wp_register_style( 'bookacti-css-jquery-ui', get_template_directory_uri() . '/booking-activities/lib/jquery-ui/themes/booking-activities/' . $jquery_ui_css_filename, array(), BOOKACTI_VERSION ); // On backend, only include these scripts on Booking Activities pages if( is_admin() && ! bookacti_is_booking_activities_screen() ) { return; } // INCLUDE STYLESHEETS wp_enqueue_style ( 'bookacti-css-backend', get_template_directory_uri() . '/booking-activities/css/backend.min.css'); wp_enqueue_style ( 'bookacti-css-templates', get_template_directory_uri() . '/booking-activities/css/templates.min.css'); wp_enqueue_style ( 'bookacti-css-landing', get_template_directory_uri() . '/booking-activities/css/landing.min.css'); // INCLUDE STYLESHEETS wp_enqueue_style( 'bookacti-css-global', get_template_directory_uri() . '/booking-activities/css/global.min.css'); wp_enqueue_style( 'bookacti-css-fonts', get_template_directory_uri() . '/booking-activities/css/fonts.min.css'); wp_enqueue_style( 'bookacti-css-bookings', get_template_directory_uri() . '/booking-activities/css/bookings.min.css'); wp_enqueue_style( 'bookacti-css-forms', get_template_directory_uri() . '/booking-activities/css/forms.min.css'); wp_enqueue_style( 'bookacti-css-jquery-ui' ); // INCLUDE JAVASCRIPT FILES wp_enqueue_script( 'bookacti-js-booking-system', get_template_directory_uri() . '/booking-activities/js/booking-system.min.js', array( 'jquery', 'fullcalendar', 'bookacti-js-global-var', 'bookacti-js-global-functions' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-booking-system-dialogs', get_template_directory_uri() . '/booking-activities/js/booking-system-dialogs.min.js', array( 'jquery', 'moment', 'jquery-ui-dialog', 'bookacti-js-global-var' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-booking-method-calendar', get_template_directory_uri() . '/booking-activities/js/booking-method-calendar.min.js', array( 'jquery', 'fullcalendar', 'bookacti-js-global-var', 'bookacti-js-global-functions' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-bookings-functions', get_template_directory_uri() . '/booking-activities/js/bookings-functions.min.js', array( 'jquery', 'fullcalendar', 'bookacti-js-global-var', 'bookacti-js-global-functions', ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-bookings-dialogs', get_template_directory_uri() . '/booking-activities/js/bookings-dialogs.min.js', array( 'jquery', 'moment', 'jquery-ui-dialog', 'bookacti-js-global-var', 'bookacti-js-global-functions' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-forms', get_template_directory_uri() . '/booking-activities/js/forms.min.js', array( 'jquery', 'jquery-ui-dialog', 'bookacti-js-global-functions' ), BOOKACTI_VERSION, true ); // INCLUDE JAVASCRIPT FILES wp_enqueue_script( 'bookacti-js-templates-forms-control', get_template_directory_uri() . '/booking-activities/js/templates-forms-control.min.js', array( 'jquery', 'moment', 'bookacti-js-global-var' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-templates-functions', get_template_directory_uri() . '/booking-activities/js/templates-functions.min.js', array( 'jquery', 'fullcalendar', 'jquery-touch-punch', 'jquery-effects-highlight', 'bookacti-js-global-var' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-templates-dialogs', get_template_directory_uri() . '/booking-activities/js/templates-dialogs.min.js', array( 'jquery', 'moment', 'jquery-ui-dialog', 'bookacti-js-global-var', 'bookacti-js-global-functions', 'bookacti-js-backend-functions', 'bookacti-js-templates-forms-control' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-templates', get_template_directory_uri() . '/booking-activities/js/templates.min.js', array( 'jquery', 'fullcalendar', 'bookacti-js-global-var', 'bookacti-js-global-functions', 'bookacti-js-templates-functions', 'bookacti-js-templates-dialogs' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-settings', get_template_directory_uri() . '/booking-activities/js/settings.min.js', array( 'jquery' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-form-editor-dialogs', get_template_directory_uri() . '/booking-activities/js/form-editor-dialogs.min.js', array( 'jquery', 'moment', 'jquery-ui-dialog', 'bookacti-js-global-var', 'bookacti-js-backend-functions' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-form-editor', get_template_directory_uri() . '/booking-activities/js/form-editor.min.js', array( 'jquery', 'jquery-touch-punch', 'jquery-ui-sortable', 'bookacti-js-global-var', 'bookacti-js-booking-system-functions', 'bookacti-js-forms', 'bookacti-js-form-editor-dialogs' ), BOOKACTI_VERSION, true ); // INCLUDE LIBRARIES $select2_version = '4.0.13'; if( ! wp_script_is( 'select2', 'registered' ) ) { wp_register_script( 'select2', get_template_directory_uri() . '/booking-activities/lib/select2/select2.min.js', array( 'jquery' ), $select2_version, true ); } if( ! wp_script_is( 'select2', 'enqueued' ) ) { wp_enqueue_script( 'select2' ); } wp_enqueue_style( 'select2', get_template_directory_uri() . '/booking-activities/lib/select2/select2.min.css', array(), $select2_version ); // INCLUDE JAVASCRIPT FILES wp_enqueue_script( 'bookacti-js-backend-functions', get_template_directory_uri() . '/booking-activities/js/backend-functions.min.js', array( 'jquery', 'jquery-ui-dialog', 'jquery-ui-tabs', 'jquery-ui-tooltip', 'bookacti-js-global-var', 'bookacti-js-global-functions' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-bookings', get_template_directory_uri() . '/booking-activities/js/bookings.min.js', array( 'jquery', 'fullcalendar', 'bookacti-js-global-var', 'bookacti-js-global-functions', 'bookacti-js-backend-functions' ), BOOKACTI_VERSION, true ); // INCLUDE JAVASCRIPT FILES wp_enqueue_script('jquery'); return ob_get_clean(); } ?> <script> var bookacti_localized = <?php echo json_encode( bookacti_get_js_variables() ); ?>; </script> <?php add_action('wp_head', 'define_ajaxurl'); function define_ajaxurl() { ?> <script type="text/javascript"> var ajaxurl = "' . admin_url('admin-ajax.php') . '"; </script> <?php } ?> <?php add_shortcode( 'view_bookings_activities_calendar_editors', 'load_view_calendar_editor_templates' );So I found the right hook for adding product type options:
add_filter( 'wcfm_product_manage_fields_general', 'custom_function_name' );Here’s my modified copied code from WcLovers Forum that works below however I need to incorporate the product tab and product tab content. Can you please help me?
function add_new_general_fields( $fields, $product_id, $product_type, $wcfm_is_translated_product, $wcfm_wpml_edit_disable_element ) { $wcfm_capability_options = get_option( 'wcfm_capability_options', array() ); $is_new_val_cap = ( isset( $wcfm_capability_options['_bookacti_is_activity'] ) ) ? $wcfm_capability_options['_bookacti_is_activity'] : 'no'; if($is_new_val_cap=='yes') return $fields; $is_new_val = ( get_post_meta( $product_id, '_bookacti_is_activity', true ) == 'yes' ) ? 'enable' : ''; $new_field = array( "_bookacti_is_activity" => array( 'desc' => __( 'Booking Activity', 'wc-frontend-manager' ), 'type' => 'checkbox', 'class' => 'wcfm-checkbox wcfm_ele wcfm_half_ele_checkbox simple non-booking non-variable-subscription non-job_package non-resume_package non-redq_rental non-accommodation-booking' . ' ' . $wcfm_wpml_edit_disable_element, 'desc_class' => 'wcfm_title wcfm_ele virtual_ele_title checkbox_title simple non-booking non-variable-subscription non-job_package non-resume_package non-redq_rental non-accommodation-booking' . ' ' . $wcfm_wpml_edit_disable_element, 'value' => 'enable', 'dfvalue' => $is_new_val ) ); return array_slice( $fields, 0, 1, true ) + $new_field + array_slice( $fields, 1, count( $fields ) - 1, true ); } add_filter( 'wcfm_product_manage_fields_general', 'add_new_general_fields', 9, 5 ); function save_new_field_values( $new_product_id, $wcfm_products_manage_form_data ) { $is_new_val = ! empty( $wcfm_products_manage_form_data['_bookacti_is_activity'] ) ? 'yes' : 'no'; update_post_meta( $new_product_id, '_bookacti_is_activity', $is_new_val ); } add_action( 'after_wcfm_products_manage_meta_save', 'save_new_field_values', 10, 2 ); function wcfmcap_new_field_product_typess( $product_types, $handler = 'wcfm_capability_options', $wcfm_capability_options = array() ) { $new_field = ( isset( $wcfm_capability_options['_bookacti_is_activity'] ) ) ? $wcfm_capability_options['_bookacti_is_activity'] : 'no'; $product_types["_bookacti_is_activity"] = array( 'label' => __( 'Activity', 'wc-frontend-manager' ), 'name' => $handler . '[_bookacti_is_activity]', 'type' => 'checkboxoffon', 'class' => 'wcfm-checkbox wcfm_ele', 'value' => 'yes', 'label_class' => 'wcfm_title checkbox_title', 'dfvalue' => $new_field ); return $product_types; } add_filter( 'wcfm_capability_settings_fields_product_types', 'wcfmcap_new_field_product_types', 60, 3 );Forum: Plugins
In reply to: [WooCommerce] Payment Method Endpoint Not Showing on My Account PageHello, thank you for your quick response. It was the payment gateway. What is the best Woocommerce payment gateway plugin that allows for saving payment methods?