Plugin Directory

Changeset 3087389


Ignore:
Timestamp:
05/16/2024 01:44:57 AM (23 months ago)
Author:
jtexpress
Message:

thermal

Location:
jt-express/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • jt-express/trunk/admin/class-jnt-admin.php

    r2998619 r3087389  
    2626        $plugins = get_plugins();
    2727        $current_version = $plugins[$plugin_slug]['Version'];
    28         $latest_version = '2.0.7';
     28        $latest_version = '2.0.10';
    2929
    3030        if (version_compare($current_version, $latest_version, '<')) {
  • jt-express/trunk/admin/class-jnt-thermal.php

    r2415591 r3087389  
    11<?php
    2  
    3 class Jnt_Thermal {
     2
     3class Jnt_Thermal
     4{
    45
    56    public $jnt_helper = null;
    67
    7     public function __construct() {
     8    public function __construct()
     9    {
    810
    911        $this->jnt_helper = new Jnt_Helper();
    1012        $this->define_hooks();
    11 
    1213    }
    1314
    1415    /**
    15     * Define hooks
    16     */
    17     protected function define_hooks() {
     16     * Define hooks
     17     */
     18    protected function define_hooks()
     19    {
    1820
    19         add_filter( 'bulk_actions-edit-shop_order', [ $this, 'bulk_actions_consignment_note_thermal' ], 30 );
    20         add_filter( 'handle_bulk_actions-edit-shop_order', [$this, 'handle_bulk_action_consignment_note_thermal'], 10, 3 );
    21        
     21        add_filter('bulk_actions-woocommerce_page_wc-orders', [$this, 'bulk_actions_consignment_note_thermal'], 30);
     22        add_filter('handle_bulk_actions-edit-shop_order', [$this, 'handle_bulk_action_consignment_note_thermal'], 10, 3);
     23
     24        add_filter('bulk_actions-edit-shop_order', [$this, 'bulk_actions_consignment_note_thermal'], 30);
     25        add_filter('handle_bulk_actions-edit-shop_order', [$this, 'handle_bulk_action_consignment_note_thermal'], 10, 3);
    2226    }
    2327
    24     public function bulk_actions_consignment_note_thermal ( $actions ) {
     28    public function bulk_actions_consignment_note_thermal($actions)
     29    {
    2530
    26         $actions['jnt_consignment_note_thermal'] = __( 'Print J&T Consignment Note (Thermal)' );
     31        $actions['jnt_consignment_note_thermal'] = __('Print J&T Consignment Note (Thermal)');
    2732
    2833        return $actions;
    2934    }
    3035
    31     public function handle_bulk_action_consignment_note_thermal ( $redirect_to, $action, $post_ids ) {
     36    public function handle_bulk_action_consignment_note_thermal($redirect_to, $action, $post_ids)
     37    {
    3238
    33         if ( $action !== 'jnt_consignment_note_thermal' ) {
     39        if ($action !== 'jnt_consignment_note_thermal') {
    3440            return $redirect_to;
    3541        }
     
    3844        $empty_awb = array();
    3945
    40         foreach ( $post_ids as $post_id ) {
    41             if ( ! get_post_meta( $post_id, 'jtawb', true ) ) {
    42                 $empty_awb[] = $post_id;
    43             }else{
    44                 $processed_ids[] = get_post_meta( $post_id, 'jtawb', true );
     46        foreach ($post_ids as $post_id) {
     47            $order = wc_get_order($post_id);
     48            if (!$order->get_meta('jtawb')) {
     49            } else {
     50                $processed_ids[] = $post_id;
    4551            }
    46         }
     52        }
    4753
    48         if ( ! empty( $processed_ids ) ) {
     54        if (!empty($processed_ids)) {
    4955            $result = $this->jnt_helper->process_print_thermal($processed_ids);
     56        } else {
    5057
    51         }else{
    52 
    53             $redirect_to = add_query_arg( array(
     58            $redirect_to = add_query_arg(array(
    5459                'acti' => 'error',
    5560                'msg' => 'Not yet Order',
    56             ), $redirect_to );
     61            ), $redirect_to);
    5762
    5863            return $redirect_to;
    5964        }
    60 
    6165    }
    62 
    6366}
  • jt-express/trunk/includes/class-jnt-api.php

    r2998619 r3087389  
    121121        $result = wp_remote_post($url, array('body' => $post));
    122122        header('Content-Type: application/pdf');
    123         print_r(wp_remote_retrieve_body($result));
     123        echo wp_remote_retrieve_body($result);
     124        exit;
    124125    }
    125126
  • jt-express/trunk/includes/class-jnt-helper.php

    r3059538 r3087389  
    119119    }
    120120
    121     public function process_print_thermal($awbs)
     121    public function process_print_thermal($ids)
    122122    {
    123 
     123        $awbs = array();
    124124        $setting = get_option('woocommerce_jnt_settings');
    125125        $cuscode = $setting['vipcode'];
    126         $awbs = implode(",", $awbs);
     126        foreach ($ids as $key => $id) {
     127            $order = wc_get_order($id);
     128            $awbs[] = $order->get_meta('jtawb');
     129        }
     130        $awb = implode(",", $awbs);
    127131
    128         $this->jnt_api->print($cuscode, $awbs);
     132        $this->jnt_api->print($cuscode, $awb);
    129133    }
    130134
  • jt-express/trunk/jnt.php

    r3059538 r3087389  
    55Description: WooCommerce integration for J&T Express Malaysia.
    66Author: woocs
    7 Version: 2.0.9
     7Version: 2.0.10
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
     
    1414}
    1515
    16 define('JNT_VERSION', '2.0.7');
     16define('JNT_VERSION', '2.0.10');
    1717define('JNT_PLUGIN_DIR', plugin_dir_path(__FILE__));
    1818
Note: See TracChangeset for help on using the changeset viewer.