ing functionality * of the plugin. * * @since 1.0.0 * @access private */ private function define_public_hooks() { if (get_option('wcmlim_license') != '' || get_option('wcmlim_license') == 'valid') { $plugin_public = new Wcmlim_Public($this->get_plugin_name(), $this->get_version()); $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles'); $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts'); $hide_out_of_stock_location = get_option('wcmlim_hide_show_location_dropdown'); $specific_location = get_option('wcmlim_enable_specific_location'); $geo_location = get_option('wcmlim_geo_location'); $enable_price = get_option('wcmlim_enable_price'); $ispreferred = get_option('wcmlim_preferred_location'); $coordinates_calculator = get_option('wcmlim_distance_calculator_by_coordinates'); $isshipping = get_option('wcmlim_enable_shipping_zones'); $wcmlim_location_fee = get_option('wcmlim_location_fee'); $locationOnShop = get_option('wcmlim_enable_location_onshop'); $locationPriceOnShop = get_option('wcmlim_enable_location_price_onshop'); $shortShopAsLocation = get_option("wcmlim_hide_outofstock_products"); $widgetOnShop = get_option("wcmlim_use_location_widget"); $restricUsers = get_option('wcmlim_enable_userspecific_location'); $isLocationsGroup = get_option('wcmlim_enable_location_group'); if (($restricUsers == "on" ) && ( get_current_user_id() )) { add_action('wp_enqueue_scripts', function () { wp_enqueue_script( 'usspecloc_js', plugins_url('', dirname(__FILE__) ) . '/public/js/specloc-min.js', array('jquery'), rand() ); }); } if ($isLocationsGroup == "on") { $this->loader->add_short_code('wcmlim_loc_storedropdown', $plugin_public, 'woo_storelocator_dropdown'); } if ($ispreferred == 'on') { $this->loader->add_action('init', $plugin_public, 'handle_switch_form_submit'); $this->loader->add_short_code('wcmlim_locations_switch', $plugin_public, 'woo_switch_content'); $this->loader->add_action('wp_ajax_wcmlim_closest_location', $plugin_public, 'wcmlim_closest_location'); $this->loader->add_action('wp_ajax_nopriv_wcmlim_closest_location', $plugin_public, 'wcmlim_closest_location'); } $isPaymentMethods = get_option('wcmlim_assign_payment_methods_to_locations'); if ($isPaymentMethods == "on") { require_once plugin_dir_path(dirname(__FILE__)) . 'public/partials/locationwisePaymentMethod.php'; } $isClearCart = get_option('wcmlim_clear_cart'); if ($isClearCart == "on") { $this->loader->add_action( 'woocommerce_cart_item_removed', $plugin_public, 'action_woocommerce_cart_item_removed', 10, 2 ); $this->loader->add_action('wp_ajax_wcmlim_empty_cart_content', $plugin_public, 'wcmlim_empty_cart_content'); $this->loader->add_action('wp_ajax_nopriv_wcmlim_empty_cart_content', $plugin_public, 'wcmlim_empty_cart_content'); $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts_clear_cart', 99); } if ($isshipping == 'on') { require_once plugin_dir_path(dirname(__FILE__)) . 'public/partials/displayShippingZone.php'; } if ($wcmlim_location_fee == 'on') { require_once plugin_dir_path(dirname(__FILE__)) . 'public/partials/wcmlim_locationfee.php'; } $this->loader->add_action('wp_ajax_wcmlim_closest_location', $plugin_public, 'wcmlim_closest_location'); $this->loader->add_action('wp_ajax_nopriv_wcmlim_closest_location', $plugin_public, 'wcmlim_closest_location'); $this->loader->add_action('wp_ajax_wcmlim_closest_instock_location', $plugin_public, 'wcmlim_closest_instock_location'); $this->loader->add_action('wp_ajax_nopriv_wcmlim_closest_instock_location', $plugin_public, 'wcmlim_closest_instock_location'); $this->loader->add_action('woocommerce_before_add_to_cart_button', $plugin_public, 'wcmlim_display_location'); $this->loader->add_action('wp_ajax_wcmlim_display_location', $plugin_public, 'wcmlim_display_location_dropdown'); $this->loader->add_action('wp_ajax_nopriv_wcmlim_display_location', $plugin_public, 'wcmlim_display_location_dropdown'); $this->loader->add_action('wp_ajax_wcmlim_drop2_location', $plugin_public, 'wcmlim_getdropdown_location'); $this->loader->add_action('wp_ajax_nopriv_wcmlim_drop2_location', $plugin_public, 'wcmlim_getdropdown_location'); $this->loader->add_filter('woocommerce_add_cart_item_data', $plugin_public, 'wcmlim_add_location_item_data', 10, 4); $this->loader->add_filter('woocommerce_cart_item_name', $plugin_public, 'wcmlim_cart_item_name', 10, 3); $this->loader->add_action('woocommerce_add_order_item_meta', $plugin_public, 'add_order_item_meta', 10, 3); //removing extra meta data from email $this->loader->add_filter('woocommerce_order_item_get_formatted_meta_data', $plugin_public, 'wcmlim_remove_item_meta_from_mail', 10, 3); $this->loader->add_filter('woocommerce_hidden_order_itemmeta', $plugin_public, 'hidden_order_itemmeta', 50); // modify input on cart page as per location quantity $this->loader->add_filter('woocommerce_quantity_input_args', $plugin_public, 'wcmlim_max_qty_input_args', 10, 2); /**Custom Notice message */ $this->loader->add_filter('woocommerce_get_script_data', $plugin_public, 'wcmlim_get_wc_script_data', 10, 2); if ($enable_price == 'on') { // hook for modify product price as per location $this->loader->add_action('woocommerce_before_calculate_totals', $plugin_public, 'wcmlim_add_custom_price'); $this->loader->add_filter('woocommerce_cart_item_price', $plugin_public, 'wcmlim_cart_item_price', 10, 3); $this->loader->add_filter('woocommerce_product_price_class', $plugin_public, 'wcmlim_woocommerce_price_class', 10, 2); } if ($locationOnShop == 'on') { $this->loader->add_action('woocommerce_after_shop_loop_item', $plugin_public, 'wcmlim_show_stock_shop', 10); } if ($locationPriceOnShop == 'on') { $this->loader->add_filter('woocommerce_get_price_html', $plugin_public, 'wcmlim_change_product_price', 10, 2); } if ($hide_out_of_stock_location == 'on') { $this->loader->add_filter('woocommerce_get_availability_text', $plugin_public, 'wcmlim_stock_availability_location', 10, 2); } if ($specific_location == 'on') { $this->loader->add_filter('woocommerce_get_availability_text', $plugin_public, 'wcmlim_stock_availability_for_each_location', 10, 2); } // $this->loader->add_action('woocommerce_after_shop_loop_item', $plugin_public, 'wcmlim_locations_on_shop', 1); $this->loader->add_filter('woocommerce_loop_add_to_cart_link', $plugin_public, 'wcmlim_replacing_add_to_cart_button', 10, 2); $this->loader->add_action('wp_ajax_wcmlim_ajax_add_to_cart', $plugin_public, 'wcmlim_ajax_add_to_cart'); $this->loader->add_action('wp_ajax_nopriv_wcmlim_ajax_add_to_cart', $plugin_public, 'wcmlim_ajax_add_to_cart'); $this->loader->add_action('wp_ajax_wcmlim_ajax_validation_manage_stock', $plugin_public, 'wcmlim_ajax_validation_manage_stock'); $this->loader->add_action('wp_ajax_nopriv_wcmlim_ajax_validation_manage_stock', $plugin_public, 'wcmlim_ajax_validation_manage_stock'); // Checking and validating when products are added to cart $this->loader->add_filter('woocommerce_add_to_cart_validation', $plugin_public, 'wcmlim_select_location_validation', 10, 5); $this->loader->add_filter('woocommerce_add_to_cart_validation', $plugin_public, 'wcmlim_location_stock_allowed_add_to_cart', 10, 3); $this->loader->add_action('init', $plugin_public, 'wcmlim_url_init'); $this->loader->add_action('template_redirect', $plugin_public, 'wcmlim_url_redirect'); $this->loader->add_action('wp_ajax_wcmlim_calculate_distance_search', $plugin_public, 'wcmlim_calculate_distance_search'); $this->loader->add_action('wp_ajax_nopriv_wcmlim_calculate_distance_search', $plugin_public, 'wcmlim_calculate_distance_search'); $this->loader->add_action('wp_ajax_wcmlim_filter_map_product_wise', $plugin_public, 'wcmlim_filter_map_product_wise'); $this->loader->add_action('wp_ajax_nopriv_wcmlim_filter_map_product_wise', $plugin_public, 'wcmlim_filter_map_product_wise'); $this->loader->add_action("woocommerce_payment_complete", $plugin_public, "wcmlim_maybe_reduce_stock_levels"); $this->loader->add_action('woocommerce_order_status_completed', $plugin_public, "wcmlim_maybe_reduce_stock_levels"); $this->loader->add_action('woocommerce_order_status_processing', $plugin_public, "wcmlim_maybe_reduce_stock_levels"); $this->loader->add_action('woocommerce_order_status_on-hold', $plugin_public, "wcmlim_maybe_reduce_stock_levels"); $this->loader->add_action('woocommerce_order_status_cancelled', $plugin_public, 'wcmlim_maybe_increase_stock_levels'); $this->loader->add_action('woocommerce_order_status_pending', $plugin_public, 'wcmlim_maybe_increase_stock_levels'); // * OpenPOS Compatibility $wcmlim_pos_compatibility = get_option('wcmlim_pos_compatiblity'); if ($wcmlim_pos_compatibility == "on" && in_array('woocommerce-openpos/woocommerce-openpos.php', apply_filters('active_plugins', get_option('active_plugins')))) { $this->loader->add_action( 'woocommerce_order_status_processing_to_refunded', $plugin_public, 'restore_order_stock' , 10, 1 ); } $this->loader->add_action('woocommerce_product_query', $plugin_public, 'wcmlim_change_cookie_change_location'); $this->loader->add_action('wp_ajax_wcmlim_ajax_cart_count', $plugin_public, 'wcmlim_ajax_cart_count'); $this->loader->add_action('wp_ajax_nopriv_wcmlim_ajax_cart_count', $plugin_public, 'wcmlim_ajax_cart_count'); if ($shortShopAsLocation == 'on') { $this->loader->add_action('woocommerce_product_query', $plugin_public, 'wcmlim_change_product_query'); // display an 'Out of Stock' label on archive pages $this->loader->add_action('woocommerce_before_shop_loop_item_title', $plugin_public, 'woocommerce_template_loop_stock', 10); } if ($widgetOnShop == 'on') { $this->loader->add_action('woocommerce_product_query', $plugin_public, 'wcmlim_widget_product_query'); } $this->loader->add_short_code('wcmlim_location_info', $plugin_public, 'woo_locations_info'); $this->loader->add_short_code('wcmlim_location_finder', $plugin_public, 'woo_store_finder'); $this->loader->add_short_code('wcmlim_location_finder_list_view', $plugin_public, 'woo_store_finder_list_view'); // Product Page Shortcode with location id attribute $this->loader->add_filter('shortcode_atts_products', $plugin_public, 'wcmlim_shortcode_atts_products', 10, 4); $this->loader->add_filter( 'woocommerce_shortcode_products_query', $plugin_public, 'wcmlim_woocommerce_shortcode_products_query', 10, 2 ); // * popup settings require_once plugin_dir_path(dirname(__FILE__)) . 'public/partials/shortcodes/wcmlim-location-popup.php'; //display tax on checkout according to locations $isTaxLocation = get_option('wcmlim_allow_tax_to_locations'); if ($isTaxLocation == "on") { $this->loader->add_action( 'woocommerce_cart_calculate_fees', $plugin_public, 'action_woocommerce_add_tax_each_location', 10, 2 ); } //add tax class for each line item $isTaxClassLineItem = get_option('wcmlim_enable_tax_to_each_item'); if ($isTaxClassLineItem == 'on') { add_action('woocommerce_cart_totals_get_item_tax_rates', $plugin_public, 'overwrite_tax_calculation_to_use_product_tax_class_and_location_zip_code', 10, 3); } // *WooCommerce shipstation compatibility if(in_array('woocommerce-shipstation-integration/woocommerce-shipstation.php', apply_filters('active_plugins', get_option('active_plugins')))){ add_filter( 'woocommerce_shipstation_export_custom_field_2', array($plugin_public, 'wcmlim_shipstation_custom_field_2'), 10, 2 ); } $b4L = get_option('wcmlim_enable_backorder_for_locations'); if(true){ //Backorder for each location $this->loader->add_action('wp_ajax_wcmlim_backorder4el', $plugin_public, 'wcmlim_backorder4el'); $this->loader->add_action('wp_ajax_nopriv_wcmlim_backorder4el', $plugin_public, 'wcmlim_backorder4el'); } $specific_location = get_option('wcmlim_enable_specific_location'); if(true){ //allow each location $this->loader->add_action('wp_ajax_wcmlim_allow_each_location', $plugin_public, 'wcmlim_allow_each_location'); $this->loader->add_action('wp_ajax_nopriv_wcmlim_allow_each_location', $plugin_public, 'wcmlim_allow_each_location'); } //advanced list view ajax for location information $this->loader->add_action('wp_ajax_wcmlim_prepare_advanced_view_information', $plugin_public, 'wcmlim_prepare_advanced_view_information'); $this->loader->add_action('wp_ajax_nopriv_wcmlim_prepare_advanced_view_information', $plugin_public, 'wcmlim_prepare_advanced_view_information'); $service_radius_for_location = get_option('wcmlim_service_radius_for_location'); if ($service_radius_for_location == 'on') { $this->loader->add_filter('woocommerce_package_rates', $plugin_public, 'checking_order_is_in_location_radius',10, 2); } } // variation product hide of setting $this->loader->add_action('wp_ajax_action_variation_dropdown',$plugin_public, 'wcmlim_display_selected_location_dropdown'); $this->loader->add_action('wp_ajax_nopriv_action_variation_dropdown', $plugin_public,'wcmlim_display_selected_location_dropdown'); //restrict user instock quantity text change $this->loader->add_filter('woocommerce_get_availability_text', $plugin_public, 'wcmlim_restrict_user_instock_quantity_text', 99, 2); } private function define_product_taxonomy() { new Wcmlim_Product_Taxonomy(); } /** * Run the loader to execute all of the hooks with WordPress. * * @since 1.0.0 */ public function run() { $this->loader->run(); } /** * The name of the plugin used to uniquely identify it within the context of * WordPress and to define internationalization functionality. * * @since 1.0.0 * @return string The name of the plugin. */ public function get_plugin_name() { return $this->plugin_name; } /** * The reference to the class that orchestrates the hooks with the plugin. * * @since 1.0.0 * @return Wcmlim_Loader Orchestrates the hooks of the plugin. */ public function get_loader() { return $this->loader; } /** * Retrieve the version number of the plugin. * * @since 1.0.0 * @return string The version number of the plugin. */ public function get_version() { return $this->version; } }