Plugin Directory

Changeset 2669998


Ignore:
Timestamp:
01/31/2022 05:03:17 PM (4 years ago)
Author:
shindhl
Message:

Release 2.8.1 (DHL Parcel)

  • DHL Parcel: Added a new available action hook for label creation
Location:
dhl-for-woocommerce
Files:
15 edited
1 copied

Legend:

Unmodified
Added
Removed
  • dhl-for-woocommerce/tags/2.8.1/dhlpwoocommerce/README.md

    r2650826 r2669998  
    11# DHL Parcel plugin for WooCommerce
     2 
     3v1.3.17
     4## Changes
     5- Small fix for ServicePoint locator in checkout
    26 
    37v1.3.16
  • dhl-for-woocommerce/tags/2.8.1/dhlpwoocommerce/dhlpwoocommerce.php

    r2650826 r2669998  
    55Description: This is the official DHL Parcel for WooCommerce plugin.
    66Author: DHL Parcel
    7 Version: 1.3.17
     7Version: 1.3.18
    88WC requires at least: 3.0.0
    99WC tested up to: 4.3.3
  • dhl-for-woocommerce/tags/2.8.1/dhlpwoocommerce/includes/controller/admin/class-dhlpwc-controller-admin-order-metabox.php

    r2624412 r2669998  
    3232            add_action('wp_ajax_dhlpwc_metabox_parcelshop_search', array($this, 'parcelshop_search'));
    3333
    34             $service = DHLPWC_Model_Service_Access_Control::instance();
    35             if ($service->check(DHLPWC_Model_Service_Access_Control::ACCESS_PRINTER)) {
    36                 add_action('wp_ajax_dhlpwc_label_print',  array($this, 'print_label'));
    37             }
    38 
    39             $service = DHLPWC_Model_Service_Access_Control::instance();
    40             if ($service->check(DHLPWC_Model_Service_Access_Control::ACCESS_LABEL_REQUEST)) {
    41                 add_action('wp_ajax_dhlpwc_print_label_request',  array($this, 'print_label_request'));
    42             }
     34            $service = DHLPWC_Model_Service_Access_Control::instance();
     35            if ($service->check(DHLPWC_Model_Service_Access_Control::ACCESS_PRINTER)) {
     36                add_action('wp_ajax_dhlpwc_label_print',  array($this, 'print_label'));
     37            }
     38
     39            $service = DHLPWC_Model_Service_Access_Control::instance();
     40            if ($service->check(DHLPWC_Model_Service_Access_Control::ACCESS_LABEL_REQUEST)) {
     41                add_action('wp_ajax_dhlpwc_print_label_request',  array($this, 'print_label_request'));
     42            }
    4343        }
    4444    }
     
    175175    }
    176176
    177     /**
    178     * Handler for the label_print AJAX call
    179     */
    180     public function print_label()
    181     {
    182         $post_id = wc_clean($_POST['post_id']);
    183         $label_id = wc_clean($_POST['label_id']);
    184 
    185         $service = new DHLPWC_Model_Service_Printer();
    186         $success = $service->send($label_id);
    187 
    188         // Set Flash message
    189         $messages = DHLPWC_Model_Core_Flash_Message::instance();
    190         if ($success) {
    191             $messages->add_notice(__('Sent to printer successfully.', 'dhlpwc'), 'dhlpwc_label_meta');
    192         } else {
    193             $messages->add_warning(__('Failed to send to printer.', 'dhlpwc'), 'dhlpwc_label_meta');
    194         }
    195 
    196         // Send JSON response
    197         $json_response = new DHLPWC_Model_Response_JSON();
    198         $json_response->set_data(array(
    199             'view' => $this->load_all($post_id)
    200         ));
    201         wp_send_json($json_response->to_array(), 200);
    202     }
    203 
    204     /**
    205     * Handler for the label_print AJAX call
    206     */
    207     public function print_label_request()
    208     {
    209         $post_id = wc_clean($_GET['post_id']);
    210         $label_id = wc_clean($_GET['label_id']);
    211 
    212         // Get Label
    213         $label_service = DHLPWC_Model_Service_Order_Meta::instance();
    214         $label = $label_service->get_label($post_id, $label_id);
    215 
    216         if ($label === false) {
    217             echo __('Label not found', 'dhlpwc');
    218             exit;
    219         }
    220 
    221         if (empty($label['request'])) {
    222             echo __('Label request not found', 'dhlpwc');
    223             exit;
    224         }
    225 
    226         echo $label['request'];
    227         exit;
    228     }
     177    /**
     178    * Handler for the label_print AJAX call
     179    */
     180    public function print_label()
     181    {
     182        $post_id = wc_clean($_POST['post_id']);
     183        $label_id = wc_clean($_POST['label_id']);
     184
     185        $service = new DHLPWC_Model_Service_Printer();
     186        $success = $service->send($label_id);
     187
     188        // Set Flash message
     189        $messages = DHLPWC_Model_Core_Flash_Message::instance();
     190        if ($success) {
     191            $messages->add_notice(__('Sent to printer successfully.', 'dhlpwc'), 'dhlpwc_label_meta');
     192        } else {
     193            $messages->add_warning(__('Failed to send to printer.', 'dhlpwc'), 'dhlpwc_label_meta');
     194        }
     195
     196        // Send JSON response
     197        $json_response = new DHLPWC_Model_Response_JSON();
     198        $json_response->set_data(array(
     199            'view' => $this->load_all($post_id)
     200        ));
     201        wp_send_json($json_response->to_array(), 200);
     202    }
     203
     204    /**
     205    * Handler for the label_print AJAX call
     206    */
     207    public function print_label_request()
     208    {
     209        $post_id = wc_clean($_GET['post_id']);
     210        $label_id = wc_clean($_GET['label_id']);
     211
     212        // Get Label
     213        $label_service = DHLPWC_Model_Service_Order_Meta::instance();
     214        $label = $label_service->get_label($post_id, $label_id);
     215
     216        if ($label === false) {
     217            echo __('Label not found', 'dhlpwc');
     218            exit;
     219        }
     220
     221        if (empty($label['request'])) {
     222            echo __('Label request not found', 'dhlpwc');
     223            exit;
     224        }
     225
     226        echo $label['request'];
     227        exit;
     228    }
    229229
    230230    public function load_options()
  • dhl-for-woocommerce/tags/2.8.1/dhlpwoocommerce/includes/model/logic/class-dhlpwc-model-logic-access-control.php

    r2624412 r2669998  
    906906    }
    907907
    908       public function check_label_request()
    909       {
     908    public function check_label_request()
     909    {
    910910        $shipping_method = get_option('woocommerce_dhlpwc_settings');
    911911
     
    931931
    932932        return true;
    933       }
     933    }
    934934
    935935    public function check_validation_rule($identifier)
  • dhl-for-woocommerce/tags/2.8.1/dhlpwoocommerce/includes/model/meta/class-dhlpwc-model-meta-order-label.php

    r2519608 r2669998  
    1919    public $order_reference;
    2020    public $is_return;
    21     public $request;
     21    public $request;
    2222
    2323    /** @var DHLPWC_Model_Meta_Order_Label_PDF $pdf */
  • dhl-for-woocommerce/tags/2.8.1/dhlpwoocommerce/includes/model/service/class-dhlpwc-model-service-access-control.php

    r2624412 r2669998  
    248248                break;
    249249
    250             case self::ACCESS_PRINTER:
    251                 $logic = DHLPWC_Model_Logic_Access_Control::instance();
    252                 return $logic->check_printer();
    253                 break;
    254 
    255             case self::ACCESS_LABEL_REQUEST:
    256                 $logic = DHLPWC_Model_Logic_Access_Control::instance();
    257                 return $logic->check_label_request();
    258                 break;
     250            case self::ACCESS_PRINTER:
     251                $logic = DHLPWC_Model_Logic_Access_Control::instance();
     252                return $logic->check_printer();
     253                break;
     254
     255            case self::ACCESS_LABEL_REQUEST:
     256                $logic = DHLPWC_Model_Logic_Access_Control::instance();
     257                return $logic->check_label_request();
     258                break;
    259259
    260260            case self::ACCESS_DEBUG:
  • dhl-for-woocommerce/tags/2.8.1/dhlpwoocommerce/includes/model/service/class-dhlpwc-model-service-label-metabox.php

    r2628039 r2669998  
    295295
    296296        $service = DHLPWC_Model_Service_Access_Control::instance();
    297         $printer = $service->check(DHLPWC_Model_Service_Access_Control::ACCESS_PRINTER);
    298         $debug_label_requests = $service->check(DHLPWC_Model_Service_Access_Control::ACCESS_LABEL_REQUEST);
     297        $printer = $service->check(DHLPWC_Model_Service_Access_Control::ACCESS_PRINTER);
     298        $debug_label_requests = $service->check(DHLPWC_Model_Service_Access_Control::ACCESS_LABEL_REQUEST);
    299299
    300300        $actions = array();
     
    326326
    327327        if ($debug_label_requests && !empty($label['request'])) {
    328             $actions[] = array(
    329                 'url'    => admin_url('admin-ajax.php?action=dhlpwc_print_label_request&post_id=' . $post_id . '&label_id=' . $label['label_id']),
    330                 'name'   => __('Show Label Request', 'dhlpwc'),
    331                 'action' => "dhlpwc_action_request",
    332                 'external_link' => false
    333             );
     328            $actions[] = array(
     329                'url'           => admin_url('admin-ajax.php?action=dhlpwc_print_label_request&post_id=' . $post_id . '&label_id=' . $label['label_id']),
     330                'name'          => __('Show Label Request', 'dhlpwc'),
     331                'action'        => "dhlpwc_action_request",
     332                'external_link' => false
     333            );
    334334        }
    335335
  • dhl-for-woocommerce/tags/2.8.1/dhlpwoocommerce/includes/model/service/class-dhlpwc-model-service-order-meta.php

    r2519608 r2669998  
    2626    }
    2727
    28     public function get_labels($order_id)
    29     {
    30         return DHLPWC_Model_Logic_Order_Meta::instance()->get_stack(
    31             self::ORDER_LABELS, $order_id
    32         );
    33     }
     28    public function get_labels($order_id)
     29    {
     30        return DHLPWC_Model_Logic_Order_Meta::instance()->get_stack(
     31            self::ORDER_LABELS, $order_id
     32        );
     33    }
    3434
    35     public function get_label($order_id, $label_id)
    36     {
    37         $labels = $this->get_labels($order_id, $label_id);
     35    public function get_label($order_id, $label_id)
     36    {
     37        $labels = $this->get_labels($order_id, $label_id);
    3838
    39         foreach ($labels as $label) {
    40             if ($label['label_id'] == $label_id) {
    41                 return $label;
    42             }
    43         }
     39        foreach ($labels as $label) {
     40            if ($label['label_id'] == $label_id) {
     41                return $label;
     42            }
     43        }
    4444
    45         return false;
    46     }
     45        return false;
     46    }
    4747
    4848}
  • dhl-for-woocommerce/tags/2.8.1/dhlpwoocommerce/includes/model/service/class-dhlpwc-model-service-shipment.php

    r2624412 r2669998  
    102102        $pdf_info = $label_logic->create_pdf_file($order_id, $label['pdf']);
    103103
    104         $label_data = array(
    105             'label_id' => $label['labelId'],
    106             'label_type' => $label['labelType'],
    107             'label_size' => $label_size,
    108             'tracker_code' => $label['trackerCode'],
    109             'routing_code' => $label['routingCode'],
    110             'order_reference' => $label['orderReference'],
    111 
    112             'pdf' => array(
    113                 'url' => $pdf_info['url'],
    114                 'path' => $pdf_info['path'],
    115             )
    116         );
    117 
    118         // Save label request or not
    119         $service = DHLPWC_Model_Service_Access_Control::instance();
    120         $debug_label_requests = $service->check(DHLPWC_Model_Service_Access_Control::ACCESS_LABEL_REQUEST);
    121         if ($debug_label_requests) {
    122             $label_data['request'] = json_encode($shipment_data);
    123         }
     104        $label_data = array(
     105            'label_id' => $label['labelId'],
     106            'label_type' => $label['labelType'],
     107            'label_size' => $label_size,
     108            'tracker_code' => $label['trackerCode'],
     109            'routing_code' => $label['routingCode'],
     110            'order_reference' => $label['orderReference'],
     111
     112            'pdf' => array(
     113                'url' => $pdf_info['url'],
     114                'path' => $pdf_info['path'],
     115            )
     116        );
     117
     118        // Save label request or not
     119        $service = DHLPWC_Model_Service_Access_Control::instance();
     120        $debug_label_requests = $service->check(DHLPWC_Model_Service_Access_Control::ACCESS_LABEL_REQUEST);
     121        if ($debug_label_requests) {
     122            $label_data['request'] = json_encode($shipment_data);
     123        }
     124
     125        // Create label do action hook
     126        do_action('dhlpwc_create_label', $order_id, $label_data);
    124127
    125128        $meta = new DHLPWC_Model_Service_Order_Meta();
     
    145148            $return_pdf_info = $label_logic->create_pdf_file($order_id, $return_label['pdf']);
    146149
    147             $label_data = array(
    148                 'label_id' => $return_label['labelId'],
    149                 'label_type' => $return_label['labelType'],
    150                 'label_size' => $label_size,
    151                 'tracker_code' => $return_label['trackerCode'],
    152                 'routing_code' => $return_label['routingCode'],
    153                 'order_reference' => $return_label['orderReference'],
    154                 'is_return' => true,
    155 
    156                 'pdf' => array(
    157                     'url' => $return_pdf_info['url'],
    158                     'path' => $return_pdf_info['path'],
    159                 ),
    160             );
    161 
    162             // Save label request or not
    163             $service = DHLPWC_Model_Service_Access_Control::instance();
    164             $debug_label_requests = $service->check(DHLPWC_Model_Service_Access_Control::ACCESS_LABEL_REQUEST);
    165             if ($debug_label_requests) {
    166                 $label_data['request'] = json_encode($return_shipment_data);
    167             }
     150            $label_data = array(
     151                'label_id' => $return_label['labelId'],
     152                'label_type' => $return_label['labelType'],
     153                'label_size' => $label_size,
     154                'tracker_code' => $return_label['trackerCode'],
     155                'routing_code' => $return_label['routingCode'],
     156                'order_reference' => $return_label['orderReference'],
     157                'is_return' => true,
     158
     159                'pdf' => array(
     160                    'url' => $return_pdf_info['url'],
     161                    'path' => $return_pdf_info['path'],
     162                ),
     163            );
     164
     165            // Save label request or not
     166            $service = DHLPWC_Model_Service_Access_Control::instance();
     167            $debug_label_requests = $service->check(DHLPWC_Model_Service_Access_Control::ACCESS_LABEL_REQUEST);
     168            if ($debug_label_requests) {
     169                $label_data['request'] = json_encode($return_shipment_data);
     170            }
     171
     172            // Create label do action hook
     173            do_action('dhlpwc_create_label', $order_id, $label_data);
    168174
    169175            $return_meta = new DHLPWC_Model_Service_Order_Meta();
  • dhl-for-woocommerce/tags/2.8.1/dhlpwoocommerce/includes/model/service/class-dhlpwc-model-service-snippets.php

    r2624412 r2669998  
    4848    }
    4949
     50    public function create_order_label_note()
     51    {
     52        $snippet = <<<'EOD'
     53// The following example code can be added to the child theme's functions.php file
     54add_action('dhlpwc_create_label', 'dhlpwc_add_order_note_on_create_label', 10, 2);
     55
     56function dhlpwc_add_order_note_on_create_label($order_id, $label_data)
     57{
     58    // Create an order note with create label data
     59    $order = new WC_Order($order_id);
     60    if ($label_data['is_return'] !== true) {
     61        $note = __('Creating label with tracking code: ' . $label_data['tracker_code']);
     62    } else {
     63        $note = __('Creating a return label with tracking code: ' . $label_data['tracker_code']);
     64    }
     65    $order->add_order_note($note);
     66}
     67EOD;
     68        return esc_html($snippet);
     69    }
     70
    5071}
    5172
  • dhl-for-woocommerce/tags/2.8.1/dhlpwoocommerce/includes/model/woocommerce/settings/class-dhlpwc-model-woocommerce-settings-shipping-method.php

    r2624412 r2669998  
    184184            $this->get_order_status_change_fields(),
    185185
    186             array(
     186            array(
    187187                'change_order_status_to' => array(
    188188                    'type'    => 'select',
     
    435435                ),
    436436                'enable_auto_print' => array(
    437                     'title'       => __('Enable auto printer features', 'dhlpwc'),
    438                     'type'        => 'checkbox',
    439                     'label'       => __('Enable', 'dhlpwc'),
    440                     'description' => __('Automatically create and print labels when order has a specific status and has no labels already', 'dhlpwc'),
     437                    'title'       => __('Enable auto printer features', 'dhlpwc'),
     438                    'type'        => 'checkbox',
     439                    'label'       => __('Enable', 'dhlpwc'),
     440                    'description' => __('Automatically create and print labels when order has a specific status and has no labels already', 'dhlpwc'),
    441441                ),
    442442                'auto_print_on_status' => array(
    443                     'title'       => __('Auto print orders with this status', 'dhlpwc'),
    444                     'type'    => 'select',
    445                     'options' => array_merge(
    446                         array('null' => __('Do not change order status', 'dhlpwc')),
    447                         array_map(array($this, 'on_status_to_option_update'), wc_get_order_statuses())
    448                     ),
    449                     'default' => 'null',
     443                    'title'       => __('Auto print orders with this status', 'dhlpwc'),
     444                    'type'    => 'select',
     445                    'options' => array_merge(
     446                        array('null' => __('Do not change order status', 'dhlpwc')),
     447                        array_map(array($this, 'on_status_to_option_update'), wc_get_order_statuses())
     448                    ),
     449                    'default' => 'null',
    450450                ),
    451451            ),
     
    458458                    'description' => __('Settings for developers.', 'dhlpwc'),
    459459                ),
    460                 'enable_debug'                      => array(
    461                     'title'       => __('Report errors', 'dhlpwc'),
    462                     'type'        => 'checkbox',
    463                     'label'       => __('Enable', 'dhlpwc'),
    464                     'description' => __('Enable this and select one of the reporting methods below to automatically send errors of this plugin to the development team.', 'dhlpwc'),
    465                 ),
     460                'enable_debug'                      => array(
     461                    'title'       => __('Report errors', 'dhlpwc'),
     462                    'type'        => 'checkbox',
     463                    'label'       => __('Enable', 'dhlpwc'),
     464                    'description' => __('Enable this and select one of the reporting methods below to automatically send errors of this plugin to the development team.', 'dhlpwc'),
     465                ),
    466466                'enable_debug_mail'                 => array(
    467467                    'title'       => __('By mail', 'dhlpwc'),
     
    480480                    'description' => __("Alternative secondary API-URL. Used by developers. Will not be used if left empty (recommended).", 'dhlpwc'),
    481481                ),
    482                 'enable_debug_requests' => array(
    483                     'title'       => __('Log Requests for debugging', 'dhlpwc'),
    484                     'type'        => 'checkbox',
    485                     'label'       => __('Enable', 'dhlpwc'),
    486                     'description' => __('Enable this and you can check your request.', 'dhlpwc'),
    487                 ),
     482                'enable_debug_requests' => array(
     483                    'title'       => __('Log Requests for debugging', 'dhlpwc'),
     484                    'type'        => 'checkbox',
     485                    'label'       => __('Enable', 'dhlpwc'),
     486                    'description' => __('Enable this and you can check your request.', 'dhlpwc'),
     487                ),
    488488
    489489                // Feedback
     
    11661166    protected function get_order_status_change_fields()
    11671167    {
    1168         $fields = array ();
    1169         $order_statuses = wc_get_order_statuses();
    1170         $add_title = true;
     1168        $fields = array ();
     1169        $order_statuses = wc_get_order_statuses();
     1170        $add_title = true;
    11711171        foreach ($order_statuses as $order_status_key => $order_status_label) {
    11721172            $fields['change_order_status_from_' . $order_status_key] = array(
  • dhl-for-woocommerce/tags/2.8.1/dhlpwoocommerce/includes/view/cart/parcelshop-locator.php

    r2519608 r2669998  
    11<?php if (!defined('ABSPATH')) { exit; } ?>
    22<div id="dhlparcel_shipping_locator_real_reset">
    3     <div id="dhl-servicepoint-locator-component"
    4          data-query=""
    5          data-limit="7"
    6     ></div>
     3    <div id="dhl-servicepoint-locator-component"
     4         data-query=""
     5         data-limit="7"
     6    ></div>
    77</div>
  • dhl-for-woocommerce/tags/2.8.1/pr-dhl-woocommerce.php

    r2669684 r2669998  
    88 * Text Domain: dhl-for-woocommerce
    99 * Domain Path: /lang
    10  * Version: 2.8.0
     10 * Version: 2.8.1
    1111 * WC requires at least: 3.0
    1212 * WC tested up to: 5.6
     
    3636class PR_DHL_WC {
    3737
    38     private $version = "2.8.0";
     38    private $version = "2.8.1";
    3939
    4040    /**
  • dhl-for-woocommerce/tags/2.8.1/readme.txt

    r2669684 r2669998  
    66Requires PHP: 5.6
    77Tested up to: 5.9
    8 Stable tag: 2.8.0
     8Stable tag: 2.8.1
    99WC requires at least: 3.0
    1010WC tested up to: 6.1
     
    8686
    8787== Changelog ==
     88 
     89= 2.8.1 =
     90* DHL Parcel: Added a new available action hook for label creation
    8891
    8992= 2.8.0 =
  • dhl-for-woocommerce/trunk/readme.txt

    r2669684 r2669998  
    66Requires PHP: 5.6
    77Tested up to: 4.8.2
    8 Stable tag: 2.8.0
     8Stable tag: 2.8.1
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset for help on using the changeset viewer.