Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
Update to Version 1.5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
tig-mvonk committed Dec 30, 2021
2 parents 4780bee + f98d26a commit 73c92b7
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 40 deletions.
4 changes: 4 additions & 0 deletions assets/js/frontend/checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,10 @@ jQuery(
* @returns {boolean}
*/
validate_delivery_option: function () {
if (gls_delivery_options_form.is_tig_gls_shipping_selected() === false) {
return true;
}

if (gls_delivery_options_form.selected_delivery_option === false) {
gls_delivery_options_form.$error_container.html('Please select a delivery option').fadeIn();
return false;
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"type": "woocommerce-plugin",
"license": "GPL-3.0-or-later",
"version": "1.5.0",
"version": "1.5.2",
"authors": [
{
"name": "TIG",
Expand Down
2 changes: 1 addition & 1 deletion gls-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin Name: GLS for WooCommerce
* Plugin URI: https://gls-group.eu/NL/nl/home
* Description: GLS offers shipping solutions nationally and internationally in Europe and worldwide. By using this plugin you can integrate GLS shipping methods in WooCommerce.
* Version: 1.5.0
* Version: 1.5.2
* Author: TIG
* Author URI: https://tig.nl/
* Developer: TIG
Expand Down
4 changes: 2 additions & 2 deletions includes/admin/class-gls-admin-bulk-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ public function gls_handle_bulk_action_create_label($redirect_to, $action, $post
}
}
$processed_ids = GLS_Pdf::add_pdf_label_to_array($post_ids);
if (get_option('tig_gls_services')['order_status'] === 'yes') {
if (get_option(GLS_Admin::GLS_SETTINGS_SERVICES)[GLS_Admin::SETTING_CHANGE_ORDER_STATUS] === 'yes') {
foreach ($post_ids as $postId) {
$order = wc_get_order($postId);
$newOrderStatus = get_option('tig_gls_services')['new_order_status'];
$newOrderStatus = get_option(GLS_Admin::GLS_SETTINGS_SERVICES)[GLS_Admin::SETTING_NEW_ORDER_STATUS];
$order->update_status($newOrderStatus);
}
}
Expand Down
11 changes: 10 additions & 1 deletion includes/admin/class-gls-admin-order-columns.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,16 @@ public function column_content($column) {
}

public function add_gls_print_label_button($actions, $order) {
$shipping_method = array_pop($order->get_shipping_methods())->get_data()['method_id'];
if (!$order || !is_object($order)) {
return $actions;
}

if (count($order->get_shipping_methods()) == 0) {
return $actions;
}

$shipping_methods_array = $order->get_shipping_methods();
$shipping_method = array_pop($shipping_methods_array)->get_data()['method_id'];
if ($shipping_method === 'tig_gls') {
$order_id = method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id;
$actions['gls_print_label'] = array(
Expand Down
16 changes: 16 additions & 0 deletions includes/admin/class-gls-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,23 @@
class GLS_Admin
{
const GLS_SETTINGS_SERVICES = 'tig_gls_services';
const SETTING_NEW_ORDER_STATUS = 'new_order_status';
const SETTING_CHANGE_ORDER_STATUS = 'order_status_change';
const SETTING_DISPLAY_SHOPS = 'display_shops';
const SETTING_PROCESSING_TIME = 'processing_time';
const SETTING_CUTOFF_TIME = 'cutoff_time';
const SETTING_ENABLE_SHOP_RETURN = 'shop_return';
const SETTING_ENABLE_FLEX_DELIVERY = 'flex_delivery';
const SETTING_LABEL_FORMAT = 'label_format';
const SETTING_MARGIN_LEFT_A4 = 'label_margin_left_a4';
const SETTING_MARGIN_TOP_A4 = 'label_margin_top_a4';

const GLS_SETTINGS_API = 'tig_gls_api';
const API_TEST_MODE = 'test_mode';
const API_USERNAME = 'username';
const API_PASSWORD = 'password';
const API_SUBSCRIPTION_KEY = 'subscription_key';
const API_CUSTOMER_NUMBER = 'customer_no';

/**
* Constructor.
Expand Down
36 changes: 18 additions & 18 deletions includes/admin/settings/class-gls-settings-delivery-options.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,31 +117,31 @@ public function get_settings($current_section = '')
'type' => 'checkbox',
'desc_tip' => __('Use test mode in staging or development environments', 'gls-woocommerce'),
'default' => 'no',
'id' => GLS_Admin::GLS_SETTINGS_API . '[test_mode]'
'id' => GLS_Admin::GLS_SETTINGS_API . '[' . GLS_Admin::API_TEST_MODE . ']'
),
array(
'title' => __('Username', 'gls-woocommerce'),
'desc_tip' => __('Need help with setting up the plugin? See support box above for details, don\'t hesitate to contact us!', 'gls-woocommerce'),
'type' => 'encrypt_text',
'id' => GLS_Admin::GLS_SETTINGS_API . '[username]'
'id' => GLS_Admin::GLS_SETTINGS_API . '[' . GLS_Admin::API_USERNAME . ']'
),
array(
'title' => __('Password', 'gls-woocommerce'),
'desc_tip' => __('Need help with setting up the plugin? See support box above for details, don\'t hesitate to contact us!', 'gls-woocommerce'),
'type' => 'encrypt_password',
'id' => GLS_Admin::GLS_SETTINGS_API . '[password]'
'id' => GLS_Admin::GLS_SETTINGS_API . '[' . GLS_Admin::API_PASSWORD . ']'
),
array(
'title' => __('Subscription key', 'gls-woocommerce'),
'type' => 'encrypt_password',
'desc_tip' => __('Need help with setting up the plugin? See support box above for details, don\'t hesitate to contact us!', 'gls-woocommerce'),
'id' => GLS_Admin::GLS_SETTINGS_API . '[subscription_key]'
'id' => GLS_Admin::GLS_SETTINGS_API . '[' . GLS_Admin::API_SUBSCRIPTION_KEY . ']'
),
array(
'title' => __('Customer number', 'gls-woocommerce'),
'type' => 'encrypt_text',
'desc_tip' => __('Need help with setting up the plugin? See support box above for details, don\'t hesitate to contact us!', 'gls-woocommerce'),
'id' => GLS_Admin::GLS_SETTINGS_API . '[customer_no]'
'id' => GLS_Admin::GLS_SETTINGS_API . '[' . GLS_Admin::API_CUSTOMER_NUMBER . ']'
),
array(
'title' => __('Test credentials', 'gls-woocommerce'),
Expand Down Expand Up @@ -169,77 +169,77 @@ public function get_settings($current_section = '')
'title' => __('Cut-off Time', 'gls-woocommerce'),
'desc' => __('Deadline at which an order can be placed in order to be processed.', 'gls-woocommerce'),
'type' => 'select',
'id' => GLS_Admin::GLS_SETTINGS_SERVICES . '[cutoff_time]',
'id' => GLS_Admin::GLS_SETTINGS_SERVICES . '[' . GLS_Admin::SETTING_CUTOFF_TIME . ']',
'options' => $this->generateTimeIntervals(),
'default' => '17:00'
),
array(
'title' => __('Processing Time', 'gls-woocommerce'),
'desc' => __('The time (in days) it takes to process and package an order before it\'s shipped.', 'gls-woocommerce'),
'type' => 'number',
'id' => GLS_Admin::GLS_SETTINGS_SERVICES . '[processing_time]',
'id' => GLS_Admin::GLS_SETTINGS_SERVICES . '[' . GLS_Admin::SETTING_PROCESSING_TIME . ']',
'min' => '0',
'default' => '0'
),
array(
'title' => __('Label format', 'gls-woocommerce'),
'desc' => __('Which label format do you need', 'gls-woocommerce'),
'type' => 'select',
'id' => GLS_Admin::GLS_SETTINGS_SERVICES . '[label_format]',
'id' => GLS_Admin::GLS_SETTINGS_SERVICES . '[' . GLS_Admin::SETTING_LABEL_FORMAT . ']',
'options' => $this->getLabelFormat(),
'default' => 'pdfA6S'
),
array(
'title' => __('Label Margin Top (only PDF A4)', 'gls-woocommerce'),
'desc' => __('Distance in mm', 'gls-woocommerce'),
'type' => 'number',
'id' => GLS_Admin::GLS_SETTINGS_SERVICES . '[label_margin_top_a4]',
'id' => GLS_Admin::GLS_SETTINGS_SERVICES . '[' . GLS_Admin::SETTING_MARGIN_TOP_A4 . ']',
'min' => '0',
'default' => '0'
),
array(
'title' => __('Label Margin Left (only PDF A4)', 'gls-woocommerce'),
'desc' => __('Distance in mm', 'gls-woocommerce'),
'type' => 'number',
'id' => GLS_Admin::GLS_SETTINGS_SERVICES . '[label_margin_left_a4]',
'id' => GLS_Admin::GLS_SETTINGS_SERVICES . '[' . GLS_Admin::SETTING_MARGIN_LEFT_A4 . ']',
'min' => '0',
'default' => '0'
),
array(
'title' => __('No. of Shops to Display', 'gls-woocommerce'),
'desc' => __('Number of ParcelShops to display in the ShopDelivery-tab in checkout.', 'gls-woocommerce'),
'type' => 'number',
'id' => GLS_Admin::GLS_SETTINGS_SERVICES . '[display_shops]',
'id' => GLS_Admin::GLS_SETTINGS_SERVICES . '[' . GLS_Admin::SETTING_DISPLAY_SHOPS . ']',
'min' => '1',
'default' => '5'
),
array(
'title' => __('Enable changing order status', 'gls-woocommerce'),
'desc' => __('Enable this to change the order status when a GLS label is created.', 'gls-woocommerce'),
'type' => 'checkbox',
'id' => GLS_Admin::GLS_SETTINGS_SERVICES . '[order_status_change]',
'id' => GLS_Admin::GLS_SETTINGS_SERVICES . '[' . GLS_Admin::SETTING_CHANGE_ORDER_STATUS . ']',
'default' => 'no'
),
array(
'title' => __('Order status', 'gls-woocommerce'),
'desc' => __('Status of the order after creating the label', 'gls-woocommerce'),
'type' => 'select',
'id' => GLS_Admin::GLS_SETTINGS_SERVICES . '[new_order_status]',
'id' => GLS_Admin::GLS_SETTINGS_SERVICES . '[' . GLS_Admin::SETTING_NEW_ORDER_STATUS . ']',
'options' => $this->getOrderStatusses(),
'default' => 'wc-pending'
),
array(
'title' => __('Enable ShopReturnService', 'gls-woocommerce'),
'desc' => __('Enable this to offer easy returns to your customers. A return label is generated along with every delivery label. (Only for shipping in the Netherlands)', 'gls-woocommerce'),
'type' => 'checkbox',
'id' => GLS_Admin::GLS_SETTINGS_SERVICES . '[shop_return]',
'id' => GLS_Admin::GLS_SETTINGS_SERVICES . '[' . GLS_Admin::SETTING_ENABLE_SHOP_RETURN . ']',
'default' => 'yes'
),
array(
'title' => __('Enable FlexDeliveryService', 'gls-woocommerce'),
'desc' => __("Enable this to send updates to your customers about their shipment and allow them to adjust delivery times while it's in transit.", 'gls-woocommerce'),
'type' => 'checkbox',
'id' => GLS_Admin::GLS_SETTINGS_SERVICES . '[flex_delivery]',
'id' => GLS_Admin::GLS_SETTINGS_SERVICES . '[' . GLS_Admin::SETTING_ENABLE_FLEX_DELIVERY . ']',
'default' => 'yes'
),
array(
Expand Down Expand Up @@ -702,9 +702,9 @@ public function save()

//encrypt post values
$post_values = GLS()->post(GLS_Admin::GLS_SETTINGS_API);
$_POST[GLS_Admin::GLS_SETTINGS_API]['password'] = $this->encryption::encrypt($post_values['password']);
$_POST[GLS_Admin::GLS_SETTINGS_API]['username'] = $this->encryption::encrypt($post_values['username']);
$_POST[GLS_Admin::GLS_SETTINGS_API]['subscription_key'] = $this->encryption::encrypt($post_values['subscription_key']);
$_POST[GLS_Admin::GLS_SETTINGS_API][GLS_Admin::API_PASSWORD] = $this->encryption::encrypt($post_values[GLS_Admin::API_PASSWORD]);
$_POST[GLS_Admin::GLS_SETTINGS_API][GLS_Admin::API_USERNAME] = $this->encryption::encrypt($post_values[GLS_Admin::API_USERNAME]);
$_POST[GLS_Admin::GLS_SETTINGS_API][GLS_Admin::API_SUBSCRIPTION_KEY] = $this->encryption::encrypt($post_values[GLS_Admin::API_SUBSCRIPTION_KEY]);
}

// TODO: Encrypt storage of passwords in database.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct()
* @param $form_fields
* @return mixed
*/
public function filter_woocommerce_shipping_instance_form_fields_tig_gls ($form_fields)
public static function filter_woocommerce_shipping_instance_form_fields_tig_gls ($form_fields)
{

$form_field_home_delivery_label = array(
Expand Down
4 changes: 2 additions & 2 deletions includes/api/class-gls-api-get-delivery-options.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ private function setBody()
$timezone = new DateTimeZone($timezone_string);
$date_time = new DateTime(null, $timezone);
$current_time = $date_time->format('H:m:s');
$cutoff_time = get_option('tig_gls_services')['cutoff_time'];
$cutoff_time = get_option(GLS_Admin::GLS_SETTINGS_SERVICES)[GLS_Admin::SETTING_CUTOFF_TIME];
$shipping_date = $date_time;

if ($processingTime = get_option('tig_gls_services')['processing_time']) {
if ($processingTime = get_option(GLS_Admin::GLS_SETTINGS_SERVICES)[GLS_Admin::SETTING_PROCESSING_TIME]) {
$shipping_date->modify("+ $processingTime days");
}

Expand Down
2 changes: 1 addition & 1 deletion includes/api/class-gls-api-get-parcel-shops.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private function setBody()
{
return [
'zipcode' => $this->postcode,
'amountOfShops' => get_option('tig_gls_services')['display_shops'] ?? 3
'amountOfShops' => get_option(GLS_Admin::GLS_SETTINGS_SERVICES)[GLS_Admin::SETTING_DISPLAY_SHOPS] ?? 3
];
}

Expand Down
10 changes: 5 additions & 5 deletions includes/api/label/class-gls-api-label-create.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function setBody()
private function map_services($details, $type = null, $countryCode = 'NL')
{
$service = [
"shopReturnService" => (bool) ($this->options['shop_return'] == 'yes' && $countryCode == 'NL')
"shopReturnService" => (bool) ($this->options[GLS_Admin::SETTING_ENABLE_SHOP_RETURN] == 'yes' && $countryCode == 'NL')
];
switch ($type) {
case 'ParcelShop':
Expand All @@ -146,23 +146,23 @@ private function map_services($details, $type = null, $countryCode = 'NL')
*/
private function get_label_type()
{
return $this->options['label_format'] ?? 'pdfA6S';
return $this->options[GLS_Admin::SETTING_LABEL_FORMAT] ?? 'pdfA6S';
}

/**
* @return int|mixed
*/
private function get_label_margin_top()
{
return $this->options['label_margin_top_a4'] ?? 0;
return $this->options[GLS_Admin::SETTING_MARGIN_TOP_A4] ?? 0;
}

/**
* @return int|mixed
*/
private function get_label_margin_left()
{
return $this->options['label_margin_left_a4'] ?? 0;
return $this->options[GLS_Admin::SETTING_MARGIN_LEFT_A4] ?? 0;
}

/**
Expand All @@ -189,7 +189,7 @@ private function prepare_notification_email()
*/
private function is_flex_delivery_enabled()
{
return $this->options['flex_delivery'] == 'yes';
return $this->options[GLS_Admin::SETTING_ENABLE_FLEX_DELIVERY] == 'yes';
}

/**
Expand Down
4 changes: 2 additions & 2 deletions includes/class-gls-ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ public static function create_label()
self::catch_other_errors($response);

$order->update_meta_data('_gls_label', $response);
if (get_option('tig_gls_services')[order_status] === 'yes') {
$newOrderStatus = get_option('tig_gls_services')[new_order_status];
if (get_option(GLS_Admin::GLS_SETTINGS_SERVICES)[GLS_Admin::SETTING_CHANGE_ORDER_STATUS] === 'yes') {
$newOrderStatus = get_option(GLS_Admin::GLS_SETTINGS_SERVICES)[GLS_Admin::SETTING_NEW_ORDER_STATUS];
$order->update_status($newOrderStatus);
}
$order->save();
Expand Down
8 changes: 4 additions & 4 deletions includes/class-gls-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static function instance()
*/
public function __construct() {
$this->options = get_option(GLS_Admin::GLS_SETTINGS_API);
$this->http = $this->options['test_mode'] == 'yes' ? $this->url . 'Test/V1/api/' : $this->url . 'V1/api/';
$this->http = $this->options[GLS_Admin::API_TEST_MODE] == 'yes' ? $this->url . 'Test/V1/api/' : $this->url . 'V1/api/';
$this->encryption = GLS_Encryption::instance();
}

Expand All @@ -88,8 +88,8 @@ protected function addAuthentication($body)
try {
$body['shippingSystemName'] = self::GLS_API_CONTROLLER_MODULE;
$body['shippingSystemVersion'] = GLS_VERSION;
$body['username'] = $this->encryption->Decrypt($this->options['username']);
$body['password'] = $this->encryption->Decrypt($this->options['password']);
$body['username'] = $this->encryption->Decrypt($this->options[GLS_Admin::API_USERNAME]);
$body['password'] = $this->encryption->Decrypt($this->options[GLS_Admin::API_PASSWORD]);
}
catch(Exception $exception) {
return false;
Expand Down Expand Up @@ -122,7 +122,7 @@ protected function addCustomerNo($body)
public function call(GlsApiCallInterface $apiCall)
{
try {
$subscription_key = $this->encryption->Decrypt($this->options['subscription_key']);
$subscription_key = $this->encryption->Decrypt($this->options[GLS_Admin::API_SUBSCRIPTION_KEY]);
}
catch(Exception $exception) {
//nothing
Expand Down
2 changes: 1 addition & 1 deletion includes/class-gls.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ final class GLS
*
* @var string
*/
public $version = '1.2.1';
public $version = '1.5.2';

/**
* The single instance of the class.
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Requires at least: 4.6
Tested up to: 5.8.2
WC Tested up to: 6.0
Requires PHP: 7.1
Stable tag: 1.5.0
Stable tag: 1.5.2
License: GPL-3.0-or-later
License URI: http://www.gnu.org/licenses/gpl-3.0.html

Expand Down

0 comments on commit 73c92b7

Please sign in to comment.