Skip to content

Commit

Permalink
Merge pull request #300 from mijora/Develop
Browse files Browse the repository at this point in the history
Develop from v1.18.2
  • Loading branch information
markakk authored Jan 13, 2025
2 parents a3c561a + 0ad0492 commit bf913f6
Show file tree
Hide file tree
Showing 48 changed files with 3,551 additions and 2,861 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## [1.19.0]
### Fixed
- fixed loading of the parcel terminal selection on the Cart page
- fixed that when saving an order, data would only be saved once

### Improved
- removed dependency on XML API structure
- removed duplicate functions and optimized functions usage
- created the possibility to specify the type of shipment
- new shipping methods added for Estonia: Letter (Courier) and Letter (Post office)

## [1.18.2]
### Fixed
- fixed shipment registration error when plugin installed in a new shop
Expand Down
6 changes: 6 additions & 0 deletions omniva-woocommerce/assets/css/omniva_admin_order.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@
max-width: 25%;
display: inline;
}
#order_data .order_data_column .form-field-wide.omnivalt-additional_service input[type="checkbox"] {
width: unset;
}
#order_data .order_data_column .form-field-wide.omnivalt-additional_service input[type="checkbox"] + label {
cursor: pointer;
}
15 changes: 10 additions & 5 deletions omniva-woocommerce/assets/js/omniva.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ function omnivalt_init_map() {
}

(function($) {
$(document).ready(function() {
$(document.body).on( 'updated_wc_div', function(){
omnivalt_init_map();
});
});

window.omnivaltMap = {
lib: null,
Expand Down Expand Up @@ -161,18 +166,18 @@ jQuery('document').ready(function($){
$('input.shipping_method').on('click',function(){
var current_method = $(this);
if (current_method.val() == "omnivalt_pt"){
$('.terminal-container').show();
$('.omnivalt_terminal_container.old').show();
} else {
$('.terminal-container').hide();
$('.omnivalt_terminal_container.old').hide();
}
});
$('input.shipping_method:checked').trigger('click');

$(document.body).on( 'updated_wc_div', function(){
if ($(".woocommerce-shipping-calculator").length) {
$("select.shipping_method, :input[name^=shipping_method]:checked").trigger('change'); //TODO: Need better solution for dropdown update when in cart change country
} else {
if (omnivalt_settings.show_map) {
} else if ( $('.omnivalt_terminal_container.old').length ) {
if ( typeof omnivalt_settings !== 'undefined' && omnivalt_settings.show_map) {
omnivalt_init_map();
} else {
$('.omnivalt_terminal').omniva(); //TODO: Not working when country select is enabled in cart
Expand Down Expand Up @@ -283,7 +288,7 @@ var omniva_addrese_change = false;
e.preventDefault();
showModal();
});
$('.terminal-container').on('click','#show-omniva-map',function(e){
$('.omnivalt_terminal_container.old').on('click','#show-omniva-map',function(e){
e.preventDefault();
showModal();
});
Expand Down
10 changes: 2 additions & 8 deletions omniva-woocommerce/assets/js/omniva_admin_settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,11 @@ jQuery('document').ready(function($){
"pc":"private_customer",
"pn":"post_near",
"ps":"post_specific",
"lc":"letter_courier",
"lp":"letter_post",
"eu":"",
"non":"",
};
var enable_only = { //Enable shipping method only in specified countries in array. If array empty, enable for all countries.
"pt":[],
"c":[],
"cp":["EE"],
"pn":[],
"ps":[],
"pc":["EE"]
};

/** Functions **/
var omnivalt_settings = {
Expand Down
8 changes: 8 additions & 0 deletions omniva-woocommerce/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
== Changelog ==

= 1.19.0 =
- fixed loading of the parcel terminal selection on the Cart page
- fixed that when saving an order, data would only be saved once
- removed dependency on XML API structure
- removed duplicate functions and optimized functions usage
- created the possibility to specify the type of shipment
- new shipping methods added for Estonia: Letter (Courier) and Letter (Post office)

= 1.18.2 =
- fixed shipment registration error when plugin installed in a new shop
- changelog moved to separate file
Expand Down
46 changes: 24 additions & 22 deletions omniva-woocommerce/core/api/class-api-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class OmnivaLt_Api_Core
{
private $omnivalt_settings;
private $omnivalt_configs;
private $need_convert = false;

public function __construct()
{
Expand All @@ -36,6 +37,27 @@ protected function get_configs()
return $this->omnivalt_configs;
}

public function set_need_convert( $need_convert )
{
$this->need_convert = (bool) $need_convert;
return $this;
}

public function is_need_convert()
{
return $this->need_convert;
}

public function get_service_code( ...$args )
{
return false;
}

public static function get_additional_services()
{
return array();
}

public function register_shipment( $id_order )
{
return array('status' => false, 'barcodes' => array(), 'msg' => __('The used API cant get register shipment', 'omnivalt'));
Expand Down Expand Up @@ -491,29 +513,9 @@ protected function fill_comment_variables( $comment, $variables, $order )
return $comment;
}

protected function get_additional_services( $order, $shipment_service )
protected function get_additional_services_for_shipment( $order, $shipment_service )
{
$order_services = OmnivaLt_Helper::get_order_services($order);
$active_omx = ($this->omnivalt_configs['api']['type'] === 'omx');
$service_additional_services = Shipment::getAdditionalServicesForShipment($shipment_service);
$additional_services = array();

foreach ( $this->omnivalt_configs['additional_services'] as $service_key => $service_values ) {
$add_service = (in_array($service_key, $order_services)) ? true : false;

if ( ! $add_service && $service_values['add_always'] ) {
$add_service = true;
}
if ( ! $active_omx && ! in_array($service_values['code'], $service_additional_services) ) {
$add_service = false;
}

if ( $add_service ) {
$additional_services[$service_key] = $service_values['code'];
}
}

return $additional_services;
return array();
}

protected function get_reference_number( $order_number )
Expand Down
10 changes: 10 additions & 0 deletions omniva-woocommerce/core/api/class-api-omx-international.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ public function register_shipment( $id_order )

/* Get package key and zone */
$method_exploded = explode('_', $data_package->method);
if ( $this->is_need_convert() ) {
$country_options = ServicePackageHelper::getCountryOptions($data_client->country);
if ( empty($country_options) || ! $country_options['eu'] ) {
throw new OmnivaException(__('Cant convert shipment to international', 'omnivalt'));
}
$method_exploded = array('standard', 'eu');
}
$method_package = $method_exploded[0];
$method_zone = $method_exploded[1];

Expand Down Expand Up @@ -94,6 +101,9 @@ public function register_shipment( $id_order )
->setPostcode($data_client->postcode)
->setDeliverypoint($data_client->city)
->setStreet($data_client->street);
if ( ! empty($data_package->terminal) ) {
$api_receiver_address->setOffloadPostcode($data_package->terminal);
}
$api_receiver_contact = new Contact();
$api_receiver_contact
->setAddress($api_receiver_address)
Expand Down
Loading

0 comments on commit bf913f6

Please sign in to comment.