golden hour
/home/godaofbq/beyondhyperbarics.com/wp-content/plugins/woocompositeproduct/includes/backoffice
⬆️ Go Up
Upload
File/Folder
Size
Actions
composite-product.php
268 B
Del
OK
extendons-composite-backend.php
15.21 KB
Del
OK
Edit: extendons-composite-backend.php
<?php if ( ! defined( 'ABSPATH' ) ) exit; class EXTENDONS_COMPOSTIE_PRODUCT_ADMIN extends EXTENDONS_COMPOSTIE_PRODUCT { public function __construct() { add_action( 'admin_enqueue_scripts', array( $this, 'composite_product_scripts_admin' )); add_action( 'plugins_loaded', array($this,'compositepro_product_bundles_product_type')); add_filter( 'woocommerce_product_data_tabs', array( $this, 'compositepro_product_data_tabs' )); add_filter( 'product_type_selector', array( $this, 'compositepro_product_type_selector' )); add_filter( 'product_type_options', array( $this, 'compositepro_product_type_option' )); add_action( 'woocommerce_product_data_panels', array( $this, 'compositepro_product_data_panels' ) ); add_action( 'woocommerce_process_product_meta_compositepro', array( $this, 'compositepro_save_option_field' ) ); } public function compositepro_product_bundles_product_type() { require_once( cmposite_ext_dir.'includes/backoffice/composite-product.php' ); } public function compositepro_product_data_tabs( $tabs ) { $tabs['compositepro'] = array( 'label' => esc_html__( 'Extendons Composite', 'extendons-composite-products' ), 'target' => 'compositepro_settings', 'class' => array( 'show_if_compositepro'), ); $tabs['compositepro-dependecies'] = array( 'label' => esc_html__( 'Extendons Dependencies', 'extendons-composite-products' ), 'target' => 'compositepro_settings_options', 'class' => array( 'show_if_compositepro', '' ), ); return $tabs; } public function compositepro_product_type_selector( $types ) { $types['compositepro'] = _x( 'Extendons Composite Product', 'extendons-composite-products' ); return $types; } public function compositepro_product_type_option( $options ) { $options['compositepro_virtual'] = array( 'id' => '_compositepro_virtual', 'wrapper_class' => 'show_if_compositepro', 'label' => __( 'Virtual', 'extendons-composite-products' ), 'description' => __( 'Virtual products are intangible and are not shipped.', '' ), 'default' => 'no' ); $options['compositepro_downloadable'] = array( 'id' => '_compositepro_downloadable', 'wrapper_class' => 'show_if_compositepro', 'label' => __( 'Downloadable', 'extendons-composite-products' ), 'description' => __( 'Downloadable products give access to a file upon purchase.', '' ), 'default' => 'no' ); $options[ 'compositepro_per_item_shipping' ] = array( 'id' => '_compositepro_per_item_shipping', 'wrapper_class' => 'show_if_compositepro compositepro_per_item_shipping', 'label' => __( 'Per-Item Shipping', 'extendons-composite-products' ), 'description' => __( 'If your Composite product consists of items that are assembled or packaged together, leave this box un-checked and define the shipping properties of the entire Composite below. If, however, the contents of the Composite product are shipped individually, check this option to retain theiroriginal shipping weight and dimensions. <strong>Per-Item Shipping</strong> should also be checked if all composite items are virtual.', '' ), 'default' => 'no' ); $options[ 'compositepro_per_item_pricing' ] = array( 'id' => '_compositepro_per_item_pricing', 'wrapper_class' => 'show_if_compositepro compositepro_per_item_pricing', 'label' => __( 'Per-Item Pricing', 'extendons-composite-products' ), 'description' => __( 'When <strong>Per-Item Pricing</strong> is checked, the Composite product will be priced according to the cost of its contents. In this case the regular price will be a fixed cost added to the total price', '' ), 'default' => 'no' ); $options[ 'compositepro_per_item_pricing' ] = array( 'id' => '_compositepro_per_item_pricing', 'wrapper_class' => 'show_if_compositepro compositepro_per_item_pricing', 'label' => __( 'Per-Item Pricing', 'extendons-composite-products' ), 'description' => __( 'When <strong>Per-Item Pricing</strong> is checked, the Composite product will be priced according to the cost of its contents. In this case the regular price will be a fixed cost added to the total price', '' ), 'default' => 'no' ); return $options; } public function compositepro_product_data_panels() { global $post; $post_id = $post->ID; ?> <input type="hidden" id="test" name="test" value="frstym"> <div id='compositepro_settings' class='bootstrap-iso panel woocommerce_options_panel compositepro_table'> <?php woocommerce_wp_select( array( 'id' => '_compositepro_layout_options', 'label' => __( 'Composite product layout', 'extendons-composite-products' ), 'options' => array( 'list' => __( 'Simple list', 'extendons-composite-products' ), 'accordion' => __( 'Accordion list', 'extendons-composite-products' ), 'step' => __( 'Steps', 'extendons-composite-products' ), ), 'desc_tip' => true, 'description' => __( 'This option modifies the way the plugin list of components is shown', 'extendons-composite-products' ), 'value' => get_post_meta($post_id, '_compositepro_layout_options', true) )); ?> <!-- panal starts from here composite --> <div class="compositepro_panal_wrap"> <div class="toolbar compositepro_wrap_toolbar"> <span class="compositepro_list_title"> <?php _e( 'Components', 'extendons-composite-products' ); ?> <?php echo wc_help_tip( __( 'List of components', 'extendons-composite-products' ) ); ?> </span> <nav class="compositepro-nav navbar navbar-default"> <a alt="Close All" href="javascript:void(0)" class="open-uiacc btn btn-primary btn-sm"> <span class="dashicons-menu"></span> </a> <a alt="Expend All" href="javascript:void(0)" class="close-uiacc btn btn-primary btn-sm"> <span class="dashicons-editor-expand"></span> </a> </nav> </div> </div> <div id="compositepro_make_composite" class=""> <?php include( cmposite_ext_dir . 'includes/backoffice-views/composite-list-form.php' ); ?> </div> <div class="compositepro_action_button"> <button type="button" class="button" id="compositepro_save_component"> <?php esc_html_e('Save Components', 'extendons-composite-products'); ?> </button> <span id="spinnerCompnent"> <img src="<?php echo cmposite_ext_url . 'assets/images/fancybox_loading.gif'; ?>"> </span> <button type="button" class="button button-primary" id="compositepro_add_new_componenet"> <span class="dashicons-plus-alt"></span> <?php esc_html_e('Add New Component', 'extendons-composite-products'); ?> </button> </div> </div> <div id='compositepro_settings_options' class='bootstrap-iso panel woocommerce_options_panel compositepro_table'> <?php $list = get_post_meta($post_id, '_ywcp_component_data_list', true); $metaCompositeComponent = get_post_meta($post_id, '_composite_component_data', true); $unse = unserialize($metaCompositeComponent); ?> <!-- panal starts from here composite --> <div class="compositepro_panal_wrap"> <div class="toolbar compositepro_wrap_toolbar"> <span class="compositepro_list_title"> <?php _e( 'Dependencies', 'extendons-composite-products' ); ?> <?php echo wc_help_tip( __( 'List of Dependencies', 'extendons-composite-products' ) ); ?> </span> <nav class="compositepro-nav navbar navbar-default"> <a alt="Close All" href="javascript:void(0)" class="open-uiacc btn btn-primary btn-sm"> <span class="dashicons-menu"></span> </a> <a alt="Expend All" href="javascript:void(0)" class="close-uiacc btn btn-primary btn-sm"> <span class="dashicons-editor-expand"></span> </a> </nav> </div> </div> <div id="compositepro_make_composite_denpendence" class="sortable" > <?php include( cmposite_ext_dir . 'includes/backoffice-views/dependencies-list-form.php' ); ?> </div> <div class="compositepro_action_button"> <button type="button" class="button" id="compositepro_save_dependencies"> <?php esc_html_e('Save Dependencies', 'extendons-composite-products'); ?> </button> <span id="saveDependenceSpinner"> <img src="<?php echo cmposite_ext_url.'assets/images/fancybox_loading.gif'; ?>"> </span> <span id="add_dependence_loader"> <img src="<?php echo cmposite_ext_url.'assets/images/fancybox_loading.gif'; ?>"> </span> <button type="button" class="button button-primary" id="compositepro_add_new_dependencies"> <span class="dashicons-plus-alt"></span> <?php esc_html_e('Add New Dependence', 'extendons-composite-products'); ?> </button> </div> </div> <?php } public static function echo_product_categories_child( $id = 0, $tabs = 0, $categories_array = array() ) { if( ! is_array( $categories_array ) ) { $categories_array = array(); } $categories = get_categories( array( 'taxonomy'=>'product_cat', 'parent'=>$id, 'orderby'=>'name', 'order'=>'ASC' ) ); foreach ( $categories as $key => $value ) { echo '<option value="' . $value->slug . '" ' . ( in_array( $value->slug, $categories_array ) ? 'selected="selected"' : '' ) . '>' . str_repeat( '—', $tabs ) . ' ' . $value->name . '</option>'; $childs = get_categories( array( 'taxonomy'=>'product_cat', 'parent'=>$value->term_id, 'orderby'=>'name', 'order'=>'ASC' ) ); if ( count( $childs ) > 0 ) { self::echo_product_categories_child( $value->term_id, $tabs + 1, $categories_array ); } } } public static function echo_product_tags_childs_of( $tabs = 0, $tags_array = array() ) { if( ! is_array( $tags_array ) ) { $tags_array = array(); } $tags = get_terms( array( 'taxonomy' => 'product_tag', 'hide_empty' => false, ) ); foreach ( $tags as $key => $value ) { echo '<option value="' . $value->slug . '" ' . ( in_array( $value->slug, $tags_array ) ? 'selected="selected"' : '' ) . '>' . str_repeat( '—', $tabs ) . ' ' . $value->name . '</option>'; } } public function compositepro_save_option_field($post_id) { $product = wc_get_product( $post_id ); if ( !$product ) return; // adding composite product componenet $wcp_composite_data = isset( $_POST[ '_composite_component_data' ] ) ? $_POST[ '_composite_component_data' ] : false; $wcp_composite_datas = array_values($wcp_composite_data); update_post_meta($post_id, '_composite_component_data', serialize($wcp_composite_datas)); // composite layout product $wcp_layout_option = isset( $_POST[ '_compositepro_layout_options' ] ) ? $_POST[ '_compositepro_layout_options' ] : false; update_post_meta($post_id, '_compositepro_layout_options', $wcp_layout_option); // composite product options $_compositepro_virtual = isset( $_POST[ '_compositepro_virtual' ] ) ? 'yes' : 'no'; update_post_meta( $post_id, '_compositepro_virtual', $_compositepro_virtual ); $_compositepro_downloadable = isset( $_POST[ '_compositepro_downloadable' ] ) ? 'yes' : 'no'; update_post_meta( $post_id, '_compositepro_downloadable', $_compositepro_downloadable ); $_compositepro_per_item_shipping = isset( $_POST[ '_compositepro_per_item_shipping' ] ) ? 'yes' : 'no'; update_post_meta( $post_id, '_compositepro_per_item_shipping', $_compositepro_per_item_shipping ); $_compositepro_per_item_pricing = isset( $_POST[ '_compositepro_per_item_pricing' ] ) ? 'yes' : 'no'; update_post_meta( $post_id, '_compositepro_per_item_pricing', $_compositepro_per_item_pricing ); } public function composite_product_scripts_admin() { if(is_admin()) { global $post; $post_id = ''; if (!empty($post->ID)) { $post_id = $post->ID; } wp_enqueue_script('jquery'); wp_enqueue_script( 'jquery-ui-accordion' ); // wp_register_style( 'select2css', '//cdnjs.cloudflare.com/ajax/libs/select2/3.4.8/select2.css', false, '1.0', 'all' ); // wp_register_script( 'select2', '//cdnjs.cloudflare.com/ajax/libs/select2/3.4.8/select2.js', array( 'jquery' ), '1.0', true ); // wp_enqueue_style( 'select2css' ); // wp_enqueue_script( 'select2' ); // wp_enqueue_script('select2-js', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.1.0-beta.1/js/select2.min.js'); // wp_enqueue_script('select2-js', plugins_url('/js/select2.min.js', __FILE__), false, '1.0.0'); wp_enqueue_style( 'compositepro-backend-style', plugins_url( '../../assets/css/backend.css', __FILE__ ), false ); wp_enqueue_script( 'compositepro-backend-script', plugins_url( '../../assets/js/backend.js', __FILE__ ), false ); wp_localize_script( 'compositepro-backend-script', 'composite_vars', array( 'composite_nonce' => wp_create_nonce( 'composite_nonce' ), 'ajax_url' => admin_url( 'admin-ajax.php' ), 'plugin_dir_url' => plugin_dir_url( __FILE__ ), 'id' => $post_id, ) ); } } } new EXTENDONS_COMPOSTIE_PRODUCT_ADMIN();
Save