/** * Load JS & CSS FrontEnd * * @access public * @return void * @since 8.0.0 */ public function load_scripts() { $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; $assets_path = str_replace(array('http:', 'https:'), '', WC()->plugin_url()) . '/assets/'; // select2 $select2_js_path = $assets_path . 'js/select2/select2' . $suffix . '.js'; $select2_css_path = $assets_path . 'css/select2.css'; if (!wp_script_is('select2', 'registered')) { wp_register_script('select2', $select2_js_path, array('jquery'), '3.5.2'); } if (!wp_style_is('select2', 'registered')) { wp_register_style('select2', $select2_css_path); } // chosen $chosen_js_path = $assets_path . 'js/chosen/chosen.jquery' . $suffix . '.js'; $chosen_css_path = $assets_path . 'css/chosen.css'; if (!wp_script_is('chosen', 'registered')) { wp_register_script('chosen', $chosen_js_path, array('jquery'), '1.0.0', true); } if (!wp_style_is('chosen', 'registered')) { wp_enqueue_style('woocommerce_chosen_styles', $chosen_css_path); } wp_register_script('woocommerce-jne-shipping', $this->plugin_url() . '/assets/js/shipping' . $suffix . '.js', array('jquery'), '1.0.12', true); // shipping if ($this->shipping->is_enable()) { if (is_checkout() || is_wc_endpoint_url('edit-address')) { wp_enqueue_script('woocommerce-jne-shipping'); wp_localize_script('woocommerce-jne-shipping', 'agenwebsite_woocommerce_jne_params', $this->localize_script('shipping')); } } }
/** * Load JS & CSS FrontEnd * * @access public * @return void * @since 8.0.0 */ public function load_scripts() { $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; $assets_path = str_replace(array('http:', 'https:'), '', WC()->plugin_url()) . '/assets/'; // select2 $select2_js_path = $assets_path . 'js/select2/select2' . $suffix . '.js'; $select2_css_path = $assets_path . 'css/select2.css'; if (!wp_script_is('select2', 'registered')) { wp_register_script('select2', $select2_js_path, array('jquery'), '3.5.2'); } if (!wp_style_is('select2', 'registered')) { wp_register_style('select2', $select2_css_path); } // chosen $chosen_js_path = $assets_path . 'js/chosen/chosen.jquery' . $suffix . '.js'; $chosen_css_path = $assets_path . 'css/chosen.css'; if (!wp_script_is('chosen', 'registered')) { wp_register_script('chosen', $chosen_js_path, array('jquery'), '1.0.0', true); } if (!wp_style_is('chosen', 'registered')) { wp_enqueue_style('woocommerce_chosen_styles', $chosen_css_path); } wp_register_script('woocommerce-jne-shipping', $this->plugin_url() . '/assets/js/shipping' . $suffix . '.js', array('jquery'), '1.0.12', true); wp_register_script('woocommerce-jne-cekongkir', $this->plugin_url() . '/assets/js/cekongkir' . $suffix . '.js', array('jquery'), '1.0.12', true); wp_register_style('woocommerce-jne-cekongkir', $this->plugin_url() . '/assets/css/cekongkir.css'); wp_register_style('woocommerce-jne-tracking-widget', $this->plugin_url() . '/assets/css/tracking.widget.css'); // shipping if ($this->shipping->is_enable()) { if (is_checkout() || is_cart() || is_wc_endpoint_url('edit-address')) { wp_enqueue_script('woocommerce-jne-shipping'); wp_localize_script('woocommerce-jne-shipping', 'agenwebsite_woocommerce_jne_params', $this->localize_script('shipping')); } } // cek ongkir if (is_product() && $this->shipping->cek_ongkir->tab_is_enable() || is_active_widget(false, false, 'jne_cekongkir_widget', true) || $this->is_active_shortcode('jne_cek_ongkir')) { wp_enqueue_style('woocommerce-jne-cekongkir'); wp_enqueue_script('woocommerce-jne-cekongkir'); wp_localize_script('woocommerce-jne-cekongkir', 'agenwebsite_woocommerce_jne_cekongkir_params', $this->localize_script('cekongkir')); } // load selec2 or chosen if ($this->shipping->is_enable() && is_cart() || is_product() && $this->shipping->cek_ongkir->tab_is_enable() || is_active_widget(false, false, 'jne_cekongkir_widget', true) || $this->is_active_shortcode('jne_cek_ongkir')) { if (!wp_script_is('select2')) { wp_enqueue_script('select2'); } if (!wp_style_is('select2')) { wp_enqueue_style('select2'); } if (!wp_script_is('chosen')) { wp_enqueue_script('chosen'); } if (!wp_style_is('chosen')) { wp_enqueue_style('chosen'); } } }
/** * Calculate JNE Weight * To calculate weight tolerance from jne. * * @link http://jne.co.id/share_article.php?id=2013020404274222 * @access public * @param integer $weight * @return integer Total Weight in Kilograms * @since 8.0.0 **/ public function calculate_jne_weight($weight) { if (WC_JNE_Shipping::is_decimal($weight)) { $desimal = explode('.', $weight); $jne_weight = $desimal[0] == 0 || substr($desimal[1], 0, 1) > 3 || substr($desimal[1], 0, 2) > 30 ? ceil($weight) : floor($weight); $weight = $jne_weight == 0 ? 1 : $jne_weight; } return $weight; }