/**
  * Add total weight to review order table
  *
  * @access public
  * @return HTML
  * @since 8.0.0
  */
 public function show_total_weight()
 {
     echo '<tr>' . "\n";
     echo '<th>' . __('Total weight', 'agenwebsite') . '</th>' . "\n";
     echo '<td>' . WC_JNE()->shipping->get_total_weight_checkout() . apply_filters('weight_unit_total_weight', WC_JNE()->get_woocommerce_weight_unit()) . '</td>' . "\n";
     echo '</tr>' . "\n";
 }
 /**
  * Add notice to review order table
  *
  * @access public
  * @return HTML
  * @since 8.1.0
  */
 public function on_checkout()
 {
     global $woocommerce;
     $shipping_chosen = $woocommerce->session->get('chosen_shipping_methods');
     $message = array_key_exists('packing_kayu_text', $this->options) ? $this->options['packing_kayu_text'] : '';
     $label = array_key_exists('packing_kayu_label', $this->options) ? $this->options['packing_kayu_label'] : '';
     if (!empty($shipping_chosen[0])) {
         if (strpos($shipping_chosen[0], 'jne') !== false) {
             woocommerce_get_template('jne-packing-kayu.php', array('label' => $label, 'message_jne_packing_kayu' => $message), 'woocommerce-jne-exclusive', untrailingslashit(WC_JNE()->plugin_path()) . '/templates/checkout/');
         }
     }
 }
Example #3
0
 /**
  * Show JNE asuransi checkbox on the frontend
  *
  * @access public
  * @return void
  * @since 8.0.0
  **/
 public function asuransi_html()
 {
     global $post;
     $options = $this->options;
     $asuransi_is = $this->asuransi_is($post->ID);
     $product = new WC_Product($post->ID);
     $asuransi_price = wc_price($this->get_asuransi_price($product->price));
     if ($asuransi_is['jne_enable'] && ($asuransi_is['override'] || $asuransi_is['enable'])) {
         $current_value = !empty($_REQUEST['jne_asuransi']) ? 1 : 0;
         if ($asuransi_is['required'] && !$asuransi_is['override']) {
             $message_required = array_key_exists('asuransi_teks_required', $options) ? $options['asuransi_teks_required'] : '';
             $message_required = str_replace('{harga}', $asuransi_price, $message_required);
             woocommerce_get_template('jne-asuransi.php', array('message_jne_asuransi' => sprintf($message_required, $asuransi_price)), 'woocommerce-jne-exclusive', untrailingslashit(WC_JNE()->plugin_path()) . '/templates/');
         } else {
             $message = array_key_exists('asuransi_teks', $options) ? $options['asuransi_teks'] : '';
             $message = str_replace('{harga}', $asuransi_price, $message);
             $checkbox = '<input type="checkbox" name="jne_asuransi" value="yes" ' . checked($current_value, 1, false) . ' />';
             woocommerce_get_template('jne-asuransi.php', array('message_jne_asuransi' => sprintf($checkbox . $message, $asuransi_price)), 'woocommerce-jne-exclusive', untrailingslashit(WC_JNE()->plugin_path()) . '/templates/');
         }
     }
 }
Example #4
0
 /**
  * AJAX Get data kecamatan
  *
  * @access public
  * @return json
  * @since 8.0.0
  **/
 public static function shipping_get_kecamatan()
 {
     check_ajax_referer(WC_JNE()->get_nonce());
     $datakota = WC_JNE()->shipping->get_datakota();
     $result = array();
     if (count($datakota)) {
         if (is_array($datakota)) {
             foreach ($datakota as $nama_provinsi => $data_kota) {
                 if ($_POST['provinsi'] === $nama_provinsi) {
                     foreach ($data_kota as $nama_kota => $data_kecamatan) {
                         if ($_POST['kota'] === $nama_kota) {
                             foreach ($data_kecamatan as $nama_kecamatan => $data_harga) {
                                 $result[] = $nama_kecamatan;
                             }
                         }
                     }
                 }
             }
         }
     }
     wp_send_json($result);
     wp_die();
 }
        /**
         * Front-end display of widget.
         *
         * @see WP_Widget::widget()
         * @access public
         * @param array $args		Widget arguments.
         * @param array $instance	Saved values from database
         * @return void
         * @since 8.0.0
         **/
        public function widget($args, $instance)
        {
            extract($args);
            extract($instance);
            wp_enqueue_style('woocommerce-jne-tracking-widget');
            $output = $before_widget;
            $output .= $before_title;
            $output .= $title;
            $output .= $after_title;
            $output .= '<form method="post" action="' . WC_JNE()->tracking->base_url . WC_JNE()->tracking->endpoint_url . '" target="_blank" class="jne_tracking" id="jne_tracking_widget">' . "\n";
            $output .= '<label for="awbnum_widget">' . $placeholder_tracking_number . '</label>' . "\n";
            $output .= '<input type="text" id="awbnum_widget" name="awbnum" placeholder="' . $placeholder_tracking_number . '" class="input_resi" style="margin-bottom:15px;" required />' . "\n";
            $output .= '<div class="captcha_img">' . "\n";
            $output .= '<img id="captcha_widget" alt="" src="' . WC_JNE()->tracking->base_url . WC_JNE()->tracking->captcha_url . '" width="140" /><br />' . "\n";
            $output .= '<a id="change-image-widget" href="javascript:void">' . __('Refresh', 'agenwebsite') . ' <span class="dashicons dashicons-update"></span></a><br />' . "\n";
            $output .= '</div>' . "\n";
            $output .= '<script type="text/javascript">' . "\n";
            $output .= '
							jQuery(document).ready(function($) {
								var captchaID = $(\'#captcha_widget\');
								$( "#change-image-widget" ).click(function(){
									$( "form#jne_tracking_widget" ).addClass("updating-captcha");
									
									$( captchaID ).one("load", function() {
										$( "form#jne_tracking_widget" ).removeClass("updating-captcha");
									}).attr( "src", \'' . WC_JNE()->tracking->base_url . WC_JNE()->tracking->captcha_url . '?\' + Math.random() );
								});
							});
					';
            $output .= '</script>' . "\n";
            $output .= '<label for="awbcaptcha_widget">' . $placeholder_captcha . '</label>' . "\n";
            $output .= '<input id="awbcaptcha_widget" name="captcha" type="text" placeholder="' . $placeholder_captcha . '" class="input_captcha" required />' . "\n";
            $output .= '<p><input type="submit" value="' . $button . '" class="button alt" name="submittracking" /></p>' . "\n";
            $output .= '</form>' . "\n";
            $output .= $after_widget;
            echo $output;
        }
 /**
  * Add total weight to review order table
  *
  * @access public
  * @return HTML
  * @since 8.0.0
  */
 public function show_total_weight()
 {
     $total_weight = WC_JNE()->shipping->get_total_weight_checkout();
     if (array_key_exists('virtual', $total_weight) && $total_weight['virtual'] !== 'yes' || $total_weight['weight'] !== 0) {
         echo '<tr>' . "\n";
         echo '<th>' . __('Total weight', 'agenwebsite') . '</th>' . "\n";
         echo '<td>' . $total_weight['weight'] . apply_filters('weight_unit_total_weight', WC_JNE()->get_woocommerce_weight_unit()) . '</td>' . "\n";
         echo '</tr>' . "\n";
     }
 }
            </td>
        </tr>
        <tr>
        	<td>
				<?php 
echo __('WC Currency Decimals', 'agenwebsite');
?>
                <?php 
echo WC_JNE()->help_tip('Pengaturan WooCommmerce untuk jumlah angka nol dibelakang koma. saran: maksimal 2', 'right');
?>
                
            </td>
            <td><?php 
echo WC_JNE()->shipping->get_price_decimals() > 2 ? '<mark class="no">' . WC_JNE()->shipping->get_price_decimals() . '</mark>' : '<mark class="yes">' . WC_JNE()->shipping->get_price_decimals() . '</mark>';
?>
</td>
            <td>
            	<?php 
if (WC_JNE()->shipping->get_price_decimals() > 2) {
    ?>
                    <?php 
    echo WC_JNE()->link_tip('Saran: maksimal sampai 2. Klik untuk melihat cara ganti currency decimals', 'Bantuan', $dok_currency_decimals, 'new');
    ?>
				<?php 
}
?>
            </td>
        </tr>
   	</tbody>
</table>
Example #8
0
 /**
  * AJAX Get data harga jne on cekongkir tab
  *
  * @access public
  * @return json
  * @since 8.0.0
  **/
 public static function cekongkir_get_harga()
 {
     check_ajax_referer(WC_JNE()->get_nonce());
     $tujuan['weight'] = WC_JNE()->shipping->calculate_jne_weight($_POST['berat']);
     $tujuan['weight_unit'] = $_POST['type'] == 'tab' ? $_POST['weight_unit'] : WC_JNE()->get_woocommerce_weight_unit();
     $tujuan['provinsi'] = $_POST['provinsi'];
     $tujuan['kota'] = $_POST['kota'];
     $tujuan['kecamatan'] = $_POST['kecamatan'];
     $args = array('provinsi' => $_POST['provinsi'], 'kota' => $_POST['kota'], 'kecamatan' => $_POST['kecamatan'], 'berat' => $_POST['berat']);
     $tarif = WC_JNE()->api->remote_get('tarif', $args);
     $layanan = array();
     foreach ($tarif['result']['tarif'] as $nama_layanan => $data_layanan) {
         if (!empty($data_layanan['harga'])) {
             $layanan[$nama_layanan]['harga'] = wc_price($data_layanan['harga'] * $tujuan['weight']);
             $layanan[$nama_layanan]['etd'] = $data_layanan['etd'];
         }
     }
     $template_path = $_POST['type'] == 'tab' ? 'single-product/tabs/cek-ongkir-result.php' : 'cek-ongkir-widget-result.php';
     ob_start();
     woocommerce_get_template($template_path, array('id' => $_POST['type'] == 'widget' ? 'widget' : 'shortcode', 'tujuan' => $tujuan, 'layanan' => $layanan), 'woocommerce-jne-exclusive', untrailingslashit(WC_JNE()->plugin_path()) . '/templates/');
     $result = ob_get_clean();
     wp_send_json($result);
     wp_die();
 }
Example #9
0
 /**
  * Get total weight
  *
  * @access public
  * @return integer Total weight
  * @since 8.0.0
  **/
 public function get_total_weight_checkout()
 {
     $settings = get_option('woocommerce_jne_shipping_settings');
     $default_weight = $settings['default_weight'];
     $weight = 0;
     $weight_unit = WC_JNE()->get_woocommerce_weight_unit();
     foreach (WC()->cart->cart_contents as $cart_item_key => $values) {
         $_product = $values['data'];
         if ($_product->is_downloadable() == false && $_product->is_virtual() == false) {
             $_product_weight = $_product->get_weight();
             if ($_product_weight == '') {
                 if ($weight_unit == 'g') {
                     $default_weight *= 1000;
                 }
                 $_product_weight = $default_weight;
             }
             $weight += $_product_weight * $values['quantity'];
             $output['virtual'] = 'yes';
         }
     }
     if ($weight_unit == 'g') {
         if ($weight > 1000) {
             $weight = $weight / 1000;
             $weight = number_format((double) $weight, 2, '.', '');
             add_filter('weight_unit_total_weight', array(&$this, 'change_to_kg'));
         }
     }
     $output['weight'] = $weight;
     return $output;
 }
 /**
  * Render the custom product tab panel content for the given $tab
  *
  * $tab structure:
  * Array(
  *   'title'    => (string) Tab title,
  *   'priority' => (string) Tab priority,
  *   'callback' => (mixed) callback function,
  *   'id'       => (int) tab post identifier,
  *   'content'  => (sring) tab content,
  * )
  *
  * @param string $key tab key
  * @param array $tab tab data
  *
  * @since 8.0.0
  */
 public function product_tabs_panel_content($key, $tab)
 {
     woocommerce_get_template('single-product/tabs/cek-ongkir.php', array('id' => $this->id, 'weight' => WC_JNE()->shipping->cek_ongkir->weight_product(), 'fields' => apply_filters('woocommerce_jne_cek_ongkir_fields', WC_JNE()->shipping->cek_ongkir->fields())), 'woocommerce-jne-exclusive', untrailingslashit(WC_JNE()->plugin_path()) . '/templates/');
 }
Example #11
0
 /**
  * Add jne tracking to shortcode list
  *
  * @access public
  * @param array $shortcodes
  * @return array
  * @since 8.1.10
  */
 public function add_shortcode_to_list($shortcodes = array())
 {
     return WC_JNE()->add_shortcode_list($shortcodes, 'jne_tracking', 'jne cek resi');
 }
 /**
  * Localize Scripts
  *
  * @access public
  * @return void
  * @since 8.0.0
  */
 public function localize_script($handle)
 {
     switch ($handle) {
         case 'admin':
             return array('i18n_input_too_short_3' => __('Ketikkan huruf minimal 3 atau lebih', 'agenwebsite'), 'i18n_searching' => __('Pencairan data&hellip;', 'agenwebsite'), 'i18n_no_matches' => __('Data tidak ditemukan', 'agenwebsite'), 'i18n_reset_default' => __('Peringatan! Semua pengaturan anda akan dihapus. Anda yakin untuk kembalikan ke pengaturan awal ?', 'agenwebsite'), 'i18n_delete_all' => __('Anda yakin untuk hapus semua ?', 'agenwebsite'), 'i18n_is_available' => __('sudah tersedia', 'agenwebsite'), 'jabodetabek' => WC_JNE()->shipping->get_jabodetabek(), 'license' => $_POST && isset($_POST['woocommerce_jne_shipping_license_code']) ? $_POST['woocommerce_jne_shipping_license_code'] : '', 'tab' => $_GET && isset($_GET['tab_jne']) ? $_GET['tab_jne'] : 'general', 'ajax_url' => self::ajax_url(), 'jne_admin_wpnonce' => wp_create_nonce('woocommerce_jne_admin'));
             break;
         case 'shipping':
             return array('i18n_placeholder_kota' => __('Pilih Kota / Kabupaten', 'agenwebsite'), 'i18n_placeholder_kecamatan' => __('Pilih Kecamatan', 'agenwebsite'), 'i18n_label_kecamatan' => __('Kecamatan', 'agenwebsite'), 'i18n_no_matches' => __('Data tidak ditemukan', 'agenwebsite'), 'i18n_required_text' => __('required', 'agenwebsite'), 'i18n_loading_data' => __('Meminta data...', 'agenwebsite'), 'wc_version' => self::get_woocommerce_version(), 'ajax_url' => self::ajax_url(), 'page' => self::get_page(), '_wpnonce' => wp_create_nonce($this->nonce));
             break;
         case 'cekongkir':
             return array('i18n_placeholder_kota' => __('Pilih Kota / Kabupaten', 'agenwebsite'), 'i18n_placeholder_kecamatan' => __('Pilih Kecamatan', 'agenwebsite'), 'i18n_no_matches' => __('Data tidak ditemukan', 'agenwebsite'), 'ajax_url' => self::ajax_url(), '_wpnonce' => wp_create_nonce($this->nonce));
             break;
     }
 }
Example #13
0
 /**
  * Field type jne_service
  *
  * @access public
  * @return HTML
  * @since 8.0.0
  **/
 public function generate_jne_service_html()
 {
     $html = '<tr valign="top">';
     $html .= '<th scope="row" class="titledesc">' . __('Layanan JNE', 'agenwebsite') . '</th>';
     $html .= '<td class="forminp">';
     $html .= '<table class="widefat wc_input_table sortable" cellspacing="0">';
     $html .= '<thead>';
     $html .= '<tr>';
     $html .= '<th class="sort">&nbsp;</th>';
     $html .= '<th>Nama Pengiriman ' . WC_JNE()->help_tip('Metode pengiriman yang digunakan.') . '</th>';
     $html .= '<th>Tambahan Biaya ' . WC_JNE()->help_tip('Biaya tambahan, bisa disetting untuk tambahan biaya packing dan lain-lain.') . '</th>';
     $html .= '<th style="width:14%;text-align:center;">Aktifkan</th>';
     $html .= '</tr>';
     $html .= '</thead>';
     $html .= '<tbody>';
     $i = 0;
     foreach (get_option($this->option_layanan) as $service) {
         $html .= '<tr class="service">';
         $html .= '<td class="sort"></td>';
         $html .= '<td><input type="text" value="' . $service['name'] . '" name="service_name[' . $i . '][' . $service['id'] . ']" /></td>';
         $html .= '<td><input type="number" value="' . $service['extra_cost'] . '" name="service_extra_cost[' . $i . '][' . $service['id'] . ']" /></td>';
         $html .= '<td style="text-align:center;"><input type="checkbox" value="1" ' . checked($service['enable'], 1, FALSE) . ' name="service_enable[' . $i . '][' . $service['id'] . ']" /><input type="hidden" value="' . $service['id'] . '" name="service_id[' . $i . ']" /></td>';
         $html .= '</tr>';
         $i++;
     }
     $html .= '</tbody>';
     $html .= '</table>';
     $html .= '</td>';
     $html .= '</tr>';
     return $html;
 }
 /**
  * JNE get provinsi by kota
  * Mendapatkan nama provinsi berdasarkan kota
  *
  * @access public
  * @param string $kota
  * @return string
  * @since 8.0.0
  */
 public function get_provinsi_by_kota($kota)
 {
     $array_data = WC_JNE()->shipping->get_datakota();
     $provinsi = '';
     if (strpos($kota, 'Kota') != TRUE) {
         $kota = 'Kota ' . $kota;
     }
     if (count($array_data) > 0) {
         if (is_array($array_data) && count($array_data) > 0) {
             foreach ($array_data as $nama_provinsi => $data_kota) {
                 foreach ($data_kota as $nama_kota => $data_kecamatan) {
                     if ($kota == $nama_kota) {
                         $provinsi = $nama_provinsi;
                     }
                 }
             }
         }
     }
     return $provinsi;
 }
/assets/images/<?php 
echo $icon;
?>
" /> <span><b><?php 
echo $teks;
?>
</b></span></center></td>
        </tr>
<?php 
if ($status == 'success') {
    foreach ($data as $title => $value) {
        // replace dash to space
        $value = $title == 'basis_kota' ? str_replace('-', ' ', $value) : $value;
        // replace underscore to space
        $title = str_replace('_', ' ', $title);
        // not print value array
        $no_print = array('code', 'message');
        // convert format
        if ($title == 'expire date') {
            $value = WC_JNE()->convert_date($value, 'd M Y');
        }
        // loop value from api
        if (!in_array($title, $no_print)) {
            echo '<tr>';
            echo '<td>' . ucfirst($title) . '</td>';
            echo '<td><mark class="yes">' . $value . '</mark></td>';
            echo '<td></td>';
            echo '</tr>';
        }
    }
}
Example #16
0
 /**
  * Load JS dan CSS admin
  *
  * @access public
  * @return void
  * @since 8.0.0
  */
 public function load_scripts_admin()
 {
     global $pagenow;
     $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     if ($pagenow == 'admin.php' && (isset($_GET['page']) && $_GET['page'] == 'wc-settings') && (isset($_GET['tab']) && $_GET['tab'] == 'shipping') && (isset($_GET['section']) && $_GET['section'] == 'wc_jne')) {
         // Load for admin common JS & CSS
         wp_enqueue_script('woocommerce-jne-js-admin', WC_JNE()->plugin_url() . '/assets/js/admin' . $suffix . '.js', array('jquery'), '1.0.2', true);
         wp_enqueue_style('woocommerce-jne-admin', WC_JNE()->plugin_url() . '/assets/css/admin.css');
         // Load localize admin params
         wp_localize_script('woocommerce-jne-js-admin', 'agenwebsite_jne_admin_params', $this->localize_script('admin'));
     }
 }
 /**
  * Load template jne cek ongkir widget
  *
  * @access public
  * @return void
  * @since 8.0.0
  */
 public function cek_ongkir_widget()
 {
     $weight['unit'] = 'kg';
     $weight['product'] = '1';
     woocommerce_get_template('cek-ongkir-widget.php', array('id' => 'widget', 'weight' => $weight, 'fields' => apply_filters('woocommerce_jne_cek_ongkir_fields', WC_JNE()->shipping->cek_ongkir->fields())), 'woocommerce-jne-exclusive', untrailingslashit(WC_JNE()->plugin_path()) . '/templates/');
 }