diff --git a/upload/.DS_Store b/upload/.DS_Store
new file mode 100644
index 0000000..5008ddf
Binary files /dev/null and b/upload/.DS_Store differ
diff --git a/upload/admin/controller/extension/module/myparcelnl.php b/upload/admin/controller/extension/module/myparcelnl.php
index f64a1a8..822a0cd 100755
--- a/upload/admin/controller/extension/module/myparcelnl.php
+++ b/upload/admin/controller/extension/module/myparcelnl.php
@@ -161,7 +161,7 @@ public function index()
$data['order_status'] = $this->model_localisation_order_status->getOrderStatuses();
$data['log_dir_is_file'] = is_file(MyParcel()->getLogsDir());
$data['log_url'] = MyParcel()->getLogsUrl();
-
+ $data['custom_field_address'] = MyParcel()->helper->getAddressCustomFields();
$this->response->setOutput($this->load->view(MyParcel()->getMyparcelModulePath(), $data));
}
diff --git a/upload/admin/language/en-gb/extension/module/myparcelnl.php b/upload/admin/language/en-gb/extension/module/myparcelnl.php
index 23cbc35..57c1c2a 100755
--- a/upload/admin/language/en-gb/extension/module/myparcelnl.php
+++ b/upload/admin/language/en-gb/extension/module/myparcelnl.php
@@ -1,6 +1,6 @@
db->query("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = '". DB_PREFIX ."myparcel_shipment' AND table_schema = '". DB_DATABASE ."' AND column_name = 'external_id'");
+ if(count($query->row) == 0 ){
+ $this->db->query("ALTER TABLE `" .DB_PREFIX. "myparcel_shipment` ADD COLUMN `external_id` VARCHAR(50) NULL DEFAULT NULL;");
+ }
+ $query = $this->db->query("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = '". DB_PREFIX ."myparcel_shipment' AND table_schema = '". DB_DATABASE ."' AND column_name = 'type'");
+ if(count($query->row) == 0 ){
+ $this->db->query("ALTER TABLE `" .DB_PREFIX. "myparcel_shipment` ADD COLUMN `type` VARCHAR(50) NULL DEFAULT NULL;");
+ }
}
function installMyParcelTotal()
diff --git a/upload/admin/model/extension/myparcelnl/shipment.php b/upload/admin/model/extension/myparcelnl/shipment.php
index 0d99f07..54f21f0 100755
--- a/upload/admin/model/extension/myparcelnl/shipment.php
+++ b/upload/admin/model/extension/myparcelnl/shipment.php
@@ -3,6 +3,17 @@ class ModelExtensionMyparcelnlShipment extends Model
{
static $table_name = 'myparcel_shipment';
+ /**
+ * Get myparcel export settings saved from backoffice
+ * @param int $order_id
+ * @return array options
+ **/
+ public function getData($order_id, $column_name)
+ {
+ $order_query = $this->db->query("SELECT " . $column_name . " FROM `" . DB_PREFIX . self::$table_name . "` WHERE order_id = " . $order_id . " LIMIT 1");
+ return $this->getValueFromQuery($column_name, $order_query);
+ }
+
/**
* Get myparcel export settings saved from backoffice
* @param int $order_id
diff --git a/upload/admin/view/template/extension/module/myparcelnl.twig b/upload/admin/view/template/extension/module/myparcelnl.twig
index 42d9155..1f7e582 100755
--- a/upload/admin/view/template/extension/module/myparcelnl.twig
+++ b/upload/admin/view/template/extension/module/myparcelnl.twig
@@ -180,7 +180,15 @@
- {{ entry_tab_1_checkbox_use_address3_as_number_suffix }}
+
+ {{ entry_tab_1_checkbox_use_address3_as_number_suffix_1 }}
+
+ {{ entry_tab_1_checkbox_use_address3_as_number_suffix_2 }}
@@ -739,6 +747,41 @@
{{ entry_tab_3_textbox_delivery_days_window }}
+
+
{{ entry_tab_3_label_only_apply_for_xtension_checkout }}
+
+
+
+
+
{{ entry_tab_3_title_customizations }}
diff --git a/upload/catalog/controller/extension/myparcelnl/myparcel_xtension_delivery.php b/upload/catalog/controller/extension/myparcelnl/myparcel_xtension_delivery.php
new file mode 100755
index 0000000..4f68d44
--- /dev/null
+++ b/upload/catalog/controller/extension/myparcelnl/myparcel_xtension_delivery.php
@@ -0,0 +1,366 @@
+registry);
+ $this->load->language('extension/module/myparcelnl.php');
+ }
+ }
+
+ function index()
+ {
+ $registry = MyParcel::$registry;
+ $config = $registry->get('config');
+ $myparcelnl_checkout_settings = $config->get('module_myparcelnl_fields_checkout');
+
+ $shipping_method_code = '';
+ $shipping_address = [];
+ if (isset($this->session->data['shipping_address'])) {
+ $shipping_address = $this->session->data['shipping_address'];
+ }
+ if(isset($this->request->post['shipping_method'])){
+ $shipping_method = $this->request->post['shipping_method'];
+ $shipping_method = explode('.',$shipping_method);
+ if(isset($shipping_method[1])){
+ $shipping_method_code = explode('_',$shipping_method[1])[1];
+ }
+ if(!isset($shipping_method_code) && $shipping_method_code == null){
+ $json['error']['warning'] = $this->language->get('error_shipping');
+ }
+ }
+ if(isset($this->session->data['myparcel_delivery'])){
+ $myparcel_delivery = $this->session->data['myparcel_delivery'];
+ }
+ else{
+ if (!empty($shipping_address) && ($shipping_address['iso_code_2'] == 'NL' || $shipping_address['iso_code_2'] == 'BE')) {
+ $api = MyParcel()->api;
+ $current_currency_code = $this->session->data['currency'];
+ $delivery_params = MyParcel()->helper->getDeliveryParams($shipping_address);
+ $myparcel_delivery = $api->getDeliveryOptions($delivery_params);
+
+ if(isset($myparcel_delivery['code']) && $myparcel_delivery['code'] == 200){
+ $myparcel_delivery = MyParcel()->helper->formatDeliveryPrice($myparcel_delivery, $shipping_address ,$this->cart->getSubTotal(),$this->language,$current_currency_code);
+
+ /** @var \Cart\Currency $currency **/
+ $currency = $registry->get('currency');
+
+ $this->session->data['myparcel_delivery'] = $myparcel_delivery['body']['data'];
+ $myparcel_delivery = $myparcel_delivery['body']['data'];
+ }
+ }
+ }
+ if(isset($myparcel_delivery[$shipping_method_code])){
+ $this->data['myparcel_delivery_option'] = $myparcel_delivery[$shipping_method_code];
+ $this->data['shipping_method_code'] = $shipping_method_code;
+ if($shipping_method_code == 'delivery'){
+ $this->data['min_date'] = date('Y-m-d',strtotime($this->data['myparcel_delivery_option'][0]['date']));
+ $this->data['max_date'] = date('Y-m-d',strtotime($this->data['myparcel_delivery_option'][count($this->data['myparcel_delivery_option']) - 1]['date']));
+ $this->data['entry_delivery_date'] = $this->language->get('entry_select') . ' ' . $this->language->get('entry_delivery_date');
+ $this->data['date_format'] = 'DD-MM-YYYY';
+ $this->data['date_pick'] = (isset($this->session->data['delivery_date']) && date('Y-m-d',strtotime($this->data['min_date'])) < date('Y-m-d',strtotime($this->session->data['delivery_date']))) ? date('Y-m-d',strtotime($this->session->data['delivery_date'])) : date('Y-m-d',strtotime($this->data['min_date']));
+ $this->data['delivery_time_start'] = isset($this->session->data['delivery_time_start']) ? $this->session->data['delivery_time_start'] : '';
+ $this->data['delivery_time_end'] = isset($this->session->data['delivery_time_end']) ? $this->session->data['delivery_time_end'] : '';
+ $this->data['dropoff_days']= implode(',' , MyParcel()->helper->getDisableDropoffDays($myparcel_delivery));
+ }
+ else{
+ if(isset($this->session->data['pickup_location'])){
+ foreach ($this->data['myparcel_delivery_option'] as $value){
+ if($value['location'] == $this->session->data['pickup_location']){
+ $this->data['pickup_detail'] = $value;
+ break;
+ }
+ }
+ }
+ if(!isset($this->data['pickup_detail'])){
+ $this->data['pickup_detail'] = $this->data['myparcel_delivery_option'][0];
+ }
+ $this->data['entry_date'] = $this->language->get('entry_date');
+ $this->data['entry_pickup_from'] = $this->language->get('entry_pickup_from');
+ $this->data['pickup_time_start'] = isset($this->session->data['pickup_time_start']) ? $this->session->data['pickup_time_start'] : '';
+ }
+ }
+
+ if(isset($shipping_address['iso_code_2']) && $shipping_address['iso_code_2'] == 'NL'){
+ if(!isset($currency)){
+ $registry = MyParcel::$registry;
+ /** @var \Cart\Currency $currency **/
+ $currency = $registry->get('currency');
+ }
+ $current_currency_code = $this->session->data['currency'];
+ $shipment_class = MyParcel()->shipment;
+ /** @var MyParcel_Shipment_Checkout $checkout_helper **/
+ $checkout_helper = $shipment_class->checkout;
+ $additional_service = $checkout_helper->getDeliveryPrices(false, true, '', true, 0,$this->cart->getSubTotal());
+ $arr_additional_service = [];
+ $array_additional_key = ['signed','only_recipient'];
+ $default_price_0_text = isset($myparcelnl_checkout_settings['default_price_0_text']) ? $myparcelnl_checkout_settings['default_price_0_text'] : '';
+
+ foreach ($additional_service[$shipping_address['iso_code_2']] as $key => $value){
+ if(in_array($key,$array_additional_key) && $value !== 'disabled'){
+ $key_title = 'entry_'. $key;
+ $arr_additional_service[$key]['amount'] = round($currency->convert($value,'EUR',$current_currency_code),2);
+ $arr_additional_service[$key]['text_amount'] = ($arr_additional_service[$key]['amount'] == 0 && $default_price_0_text != '') ? $default_price_0_text : $currency->format($arr_additional_service[$key]['amount'],$current_currency_code);
+ $arr_additional_service[$key]['title'] = $this->language->get($key_title);
+ $this->data['myparcel_additional_checked'][$key] = isset($this->session->data['additional_service_checked'][$shipping_method_code][$key]) ?$this->session->data['additional_service_checked'][$shipping_method_code][$key] : false;
+
+ }
+ }
+ $this->data['additional_title'] = $this->language->get('entry_additional_service');
+ if(count($arr_additional_service) > 0){
+ $this->data['additional_service'] = $arr_additional_service;
+ $this->session->data['additional_service'] = $arr_additional_service;
+ }
+
+ }
+
+ $this->data['action'] = MyParcel()->getMyparcelXtensionControllerPath();
+ $this->response->setOutput($this->load->view(MyParcel()->getMyparcelXtensionViewPath() . 'myparcel_xtension_delivery', $this->data));
+
+ }
+
+
+ function change(){
+ $shipping_methods = [];
+ $myparcel_delivery = [];
+ $shipping_method_code = '';
+ $json['success'] = false;
+
+ $registry = MyParcel::$registry;
+ $config = $registry->get('config');
+ $myparcelnl_checkout_settings = $config->get('module_myparcelnl_fields_checkout');
+ if(isset($this->session->data['myparcel_delivery'])){
+ $myparcel_delivery = $this->session->data['myparcel_delivery'];
+ }
+
+ if(isset($this->request->post['myparcel_pickup_location'])){
+ $myparcel_pickup_location = $this->request->post['myparcel_pickup_location'];
+ $shipping_method_code = 'pickup';
+ foreach ($myparcel_delivery[$shipping_method_code] as $value){
+ if($value['location'] == $myparcel_pickup_location){
+ $this->session->data['pickup_location'] = $value['location'];
+// $this->session->data['pickup_time_start'] = $value['time'][0]['start'];
+ $this->data['pickup_detail'] = $value;
+ $this->data['pickup_time_start'] = '';
+ if(isset($this->session->data['pickup_time_start'])){
+ unset($this->session->data['pickup_time_start']);
+ }
+ if(isset($this->session->data['myparcel_price_pickup'])){
+ unset($this->session->data['myparcel_price_pickup']);
+ }
+ break;
+ }
+ }
+ $this->data['entry_date'] = $this->language->get('entry_date');
+ $this->data['entry_pickup_from'] = $this->language->get('entry_pickup_from');
+ }
+ elseif(isset($this->request->post['delivery_date'])){
+ $shipping_method_code = 'delivery';
+ $delivery_date = date('Y-m-d',strtotime($this->request->post['delivery_date']));
+ foreach ($myparcel_delivery[$shipping_method_code] as $value){
+ if(date('m-d-Y',strtotime($value['date'])) == date('m-d-Y',strtotime($delivery_date)) ) {
+ $this->data['delivery_time_start'] = '';
+ $this->data['delivery_time_end'] = '';
+ $this->data['delivery_detail'] = $value;
+
+ $this->session->data['delivery_time_start'] = '';
+ $this->session->data['delivery_time_end'] = '';
+ $this->session->data['delivery_date'] = $delivery_date;
+ if(isset($this->session->data['myparcel_price_delivery'])){
+ unset($this->session->data['myparcel_price_delivery']);
+ }
+ break;
+ }
+ }
+ $shipping_address = [];
+ if (isset($this->session->data['shipping_address'])) {
+ $shipping_address = $this->session->data['shipping_address'];
+ }
+ if(isset($shipping_address['iso_code_2']) && $shipping_address['iso_code_2'] == 'NL' && $shipping_method_code == 'delivery'){
+ if(!isset($currency)){
+ $registry = MyParcel::$registry;
+ /** @var \Cart\Currency $currency **/
+ $currency = $registry->get('currency');
+ }
+ $current_currency_code = $this->session->data['currency'];
+ $shipment_class = MyParcel()->shipment;
+ /** @var MyParcel_Shipment_Checkout $checkout_helper **/
+ $checkout_helper = $shipment_class->checkout;
+ $additional_service = $checkout_helper->getDeliveryPrices(false, true, '', true, 0,$this->cart->getSubTotal());
+ $arr_additional_service = [];
+ $array_additional_key = ['signed','only_recipient'];
+ $default_price_0_text = isset($myparcelnl_checkout_settings['default_price_0_text']) ? $myparcelnl_checkout_settings['default_price_0_text'] : '';
+
+ foreach ($additional_service[$shipping_address['iso_code_2']] as $key => $value){
+ if(in_array($key,$array_additional_key) && $value !== 'disabled'){
+ $key_title = 'entry_'. $key;
+ $arr_additional_service[$key]['amount'] = round($currency->convert($value,'EUR',$current_currency_code),2);
+ $arr_additional_service[$key]['text_amount'] = ($arr_additional_service[$key]['amount'] == 0 && $default_price_0_text != '') ? $default_price_0_text : $currency->format($arr_additional_service[$key]['amount'],$current_currency_code);
+ $arr_additional_service[$key]['title'] = $this->language->get($key_title);
+ $this->data['myparcel_additional_checked'][$key] = isset($this->session->data['additional_service_checked'][$shipping_method_code][$key]) ?$this->session->data['additional_service_checked'][$shipping_method_code][$key] : false;
+ }
+ }
+ $this->data['additional_title'] = $this->language->get('entry_additional_service');
+ $this->data['additional_service'] = $arr_additional_service;
+ $this->session->data['additional_service'] = $arr_additional_service;
+
+ }
+ }
+ $this->data['action'] = MyParcel()->getMyparcelXtensionControllerPath();
+ $this->data['shipping_method_code'] = $shipping_method_code;
+ if(isset($this->session->data['myparcel_shipping_choosed'])){
+ unset($this->session->data['myparcel_shipping_choosed']);
+ }
+ if($shipping_method_code != ''){
+ $json['html'] = $this->load->view(MyParcel()->getMyparcelXtensionViewPath() . 'myparcel_xtension_'. $shipping_method_code .'_change', $this->data);
+ $json['success'] = true;
+ }
+ echo json_encode($json);
+ die();
+ }
+
+ function save(){
+ $shipping_methods = [];
+ $myparcel_delivery = [];
+ $json['success'] = false;
+ if(isset($this->session->data['shipping_methods'])){
+ $shipping_methods = $this->session->data['shipping_methods'];
+ }
+ if(isset($this->session->data['myparcel_delivery'])){
+ $myparcel_delivery = $this->session->data['myparcel_delivery'];
+ }
+ if(isset($this->request->post['myparcel_option'])){
+ $myparcel_option = $this->request->post['myparcel_option'];
+ $shipping_method_code = explode('-',$myparcel_option)[0];
+ $key_shipping = "myparcel_". $shipping_method_code;
+ if($shipping_method_code == 'delivery'){
+ $this->session->data['delivery_date'] = date('Y-m-d',strtotime($this->request->post['delivery_date']));
+ $delivery_option_time = explode('-',str_replace($shipping_method_code.'-','',$myparcel_option));
+ $this->session->data['delivery_time_start'] = $delivery_option_time[0];
+ $this->session->data['delivery_time_end'] = $delivery_option_time[1];
+
+ //update shipping_methods
+ foreach ($myparcel_delivery[$shipping_method_code] as $key => $value){
+ if(date('d-m-Y',strtotime($value['date'])) == date('d-m-Y',strtotime($this->session->data['delivery_date'])) ) {
+ foreach ($value['time'] as $k => $time){
+ if($time['start'] == $this->session->data['delivery_time_start'] && $time['end'] == $this->session->data['delivery_time_end']){
+ $shipping_methods[$key_shipping]['quote'][$key_shipping]['cost'] = $time['price']['current_currency_amount'];
+ $shipping_methods[$key_shipping]['quote'][$key_shipping]['text'] = $time['price']['current_currency_amount'];
+ $this->session->data['myparcel_shipping_choosed']['date'] = date('Y-m-d',strtotime($value['date']));
+ $this->session->data['myparcel_shipping_choosed']['time'][] = $time;
+ $this->session->data['myparcel_shipping_choosed']['code'] = 'myparcel_'. $shipping_method_code;
+ $this->session->data['myparcel_shipping_choosed']['additional_service'] = (isset($this->session->data['additional_service_checked']['delivery'])) ? $this->session->data['additional_service_checked']['delivery'] : [];
+ $time['price']['shipping_method_code'] = $shipping_method_code;
+ $time['price']['text_myparcel_price_delivery'] = date('d-m-Y',strtotime($value['date'])) . ' - ' . date('H:i',strtotime($time['start'])) . ' - ' .date('H:i',strtotime($time['end']));
+ $this->session->data['myparcel_price_delivery'] = $time['price'];
+ $this->session->data['shipping_methods'] = $shipping_methods;
+
+ break;
+ }
+ }
+ break;
+ }
+ }
+ $json['success'] = true;
+
+ }
+ else if($shipping_method_code == 'pickup'){
+ $pickup_option_time = explode('-',str_replace($shipping_method_code.'-','',$myparcel_option));
+ //update shipping_methods
+ foreach ($myparcel_delivery[$shipping_method_code] as $key => $value){
+ if($value['location'] == $pickup_option_time[0] ) {
+ foreach ($value['time'] as $k => $time){
+ if($time['start'] == $pickup_option_time[1]){
+ $shipping_methods[$key_shipping]['quote'][$key_shipping]['cost'] = $time['price']['current_currency_amount'];
+ $shipping_methods[$key_shipping]['quote'][$key_shipping]['text'] = $time['price']['current_currency_amount'];
+ $time['price']['shipping_method_code'] = $shipping_method_code;
+ $time['price']['text_myparcel_price_pickup'] = $value['location'] . ' - ' .date('d-m-Y',strtotime($value['date'])) . ' - ' . date('H:i',strtotime($time['start']));
+ $this->session->data['myparcel_price_pickup'] = $time['price'];
+ $this->session->data['shipping_methods'] = $shipping_methods;
+ $value['code'] = 'myparcel_'. $shipping_method_code;
+ $value['additional_service'] = [];
+ $value['time'] = [];
+ $value['time'][] = $time;
+ $this->session->data['myparcel_shipping_choosed'] = $value;
+ $this->session->data['pickup_time_start'] = $time['start'];
+ break;
+ }
+ }
+ break;
+ }
+ }
+ $json['success'] = true;
+ }
+ }
+
+ if(isset($this->request->post['addition_name']) && isset($_POST['addition_value'])){
+ $addition_name = $this->request->post['addition_name'];
+ $addition_value = $_POST['addition_value'];
+ $this->session->data['additional_service_checked']['delivery'][$addition_name] = ($addition_value == 'false') ? false : true;
+ if(isset($this->session->data['myparcel_shipping_choosed'])){
+ $this->session->data['myparcel_shipping_choosed']['additional_service'] = $this->session->data['additional_service_checked']['delivery'];
+ }
+ $json['success'] = true;
+ }
+
+ echo json_encode($json);
+ die();
+ }
+
+ function externalValidate(){
+ if(!isset($this->session->data['myparcel_shipping_choosed'])){
+ $json['warning'] = $this->language->get('error_external_validate');
+ $json['action'] = 'index.php?route=' .MyParcel()->getMyparcelXtensionControllerPath();
+ $entry_title = 'entry_select_' . explode('.',$this->session->data['shipping_method']['code'])[0];
+ $json['title'] =$this->language->get($entry_title);
+ return $json;
+ }
+ return false;
+ }
+ function forgetMyParcelChoosed(){
+ if(isset($this->session->data['myparcel_shipping_choosed'])){
+ unset($this->session->data['myparcel_shipping_choosed']);
+ }
+ if(isset($this->session->data['additional_service'])){
+ unset($this->session->data['additional_service']);
+ }
+ if(isset($this->session->data['pickup_time_start'])){
+ unset($this->session->data['pickup_time_start']);
+ }
+ if(isset($this->session->data['additional_service_checked'])){
+ unset($this->session->data['additional_service_checked']);
+ }
+ if(isset($this->session->data['pickup_time_start'])){
+ unset($this->session->data['pickup_time_start']);
+ }
+ if(isset($this->session->data['myparcel_price_pickup'])){
+ unset($this->session->data['myparcel_price_pickup']);
+ }
+ if(isset($this->session->data['myparcel_price_delivery'])){
+ unset($this->session->data['myparcel_price_delivery']);
+ }
+ if(isset($this->session->data['delivery_time_start'])){
+ unset($this->session->data['delivery_time_start']);
+ }
+ if(isset($this->session->data['delivery_time_end'])){
+ unset($this->session->data['delivery_time_end']);
+ }
+ if(isset($this->session->data['delivery_date'])){
+ unset($this->session->data['delivery_date']);
+ }
+ if(isset($this->session->data['pickup_location'])){
+ unset($this->session->data['pickup_location']);
+ }
+ if(isset($this->session->data['myparcel_option_title'])){
+ unset($this->session->data['myparcel_option_title']);
+ }
+
+ echo json_encode(array('status' => true));
+ die();
+ }
+}
\ No newline at end of file
diff --git a/upload/catalog/language/en-gb/extension/module/myparcelnl.php b/upload/catalog/language/en-gb/extension/module/myparcelnl.php
index 63441ea..4c35b5a 100755
--- a/upload/catalog/language/en-gb/extension/module/myparcelnl.php
+++ b/upload/catalog/language/en-gb/extension/module/myparcelnl.php
@@ -14,7 +14,10 @@
$_['entry_time_not_specified'] = 'Pickup';
$_['entry_edit_delivery_options'] = 'Click to edit delivery options';
$_['entry_home_address_only'] = 'Home address only';
+$_['entry_select_myparcel_delivery'] = 'Select MyParcel Delivery';
+$_['entry_select_myparcel_pickup'] = 'Select MyParcel Pickup';
$_['entry_signed'] = 'Signature on delivery';
+$_['entry_only_recipient'] = 'Recipient Only';
$_['entry_enabled_no'] = 'No';
$_['entry_enabled_yes'] = 'Yes';
$_['entry_pickup_address'] = 'Pickup address';
@@ -42,4 +45,18 @@
$_['error_address_3'] = 'Address 3 must be between 0 and 4 characters!';
$_['error_address_2'] = 'Address 2 cannot be empty!';
$_['error_address_3_need_edit'] = 'Address 3 must be between 0 and 4 characters! Please edit your address';
-$_['error_address_2_need_edit'] = 'Address 2 cannot be empty! Please edit your address';
\ No newline at end of file
+$_['error_address_2_need_edit'] = 'Address 2 cannot be empty! Please edit your address';
+$_['entry_additional_service'] = 'Additional Service';
+$_['error_external_validate'] = 'The MyParcel option is either not selected or it is past the allowed time to order! Please select the option again!';
+
+$_['entry_myparcel_delivery'] = 'MyParcel Delivery';
+$_['entry_myparcel_pickup'] = 'MyParcel Pickup';
+$_['entry_select'] = 'Select';
+$_['entry_date'] = 'Date';
+$_['entry_pickup_from'] = 'Pickup from';
+$_['entry_edit_myparcel_delivery'] = 'Edit Delivery Date';
+$_['entry_edit_myparcel_pickup'] = 'Edit Pickup Option';
+
+$_['entry_delivery_morning'] = 'Morning';
+$_['entry_delivery_standard'] = 'Standard';
+$_['entry_delivery_avond'] = 'Avond';
diff --git a/upload/catalog/language/nl-nl/extension/module/myparcelnl.php b/upload/catalog/language/nl-nl/extension/module/myparcelnl.php
new file mode 100755
index 0000000..9c9accc
--- /dev/null
+++ b/upload/catalog/language/nl-nl/extension/module/myparcelnl.php
@@ -0,0 +1,62 @@
+
+
+
+
+
+ {{ entry_delivery_date }}
+
+
+
+
+
+
+ {% for value in myparcel_delivery_option %}
+ {% if(value['date']| date('Y-m-d') == date_pick|date('Y-m-d')) %}
+
+ {% endif %}
+ {% endfor %}
+ {% else %}
+
+
+ {% for value in myparcel_delivery_option %}
+
+ {{ [value['location'] , ', ' ,value['street'] , ' ' , value['number'] , ', ' , value['city'] , '( ' , value['distance'] , value['distance_format'] ,' )'] |join }}
+
+ {% endfor %}
+
+
+
+ {% endif %}
+{% endif %}
\ No newline at end of file
diff --git a/upload/catalog/view/theme/default/template/extension/myparcelnl/myparcel_xtension_delivery_change.twig b/upload/catalog/view/theme/default/template/extension/myparcelnl/myparcel_xtension_delivery_change.twig
new file mode 100755
index 0000000..b93d0cd
--- /dev/null
+++ b/upload/catalog/view/theme/default/template/extension/myparcelnl/myparcel_xtension_delivery_change.twig
@@ -0,0 +1,41 @@
+
\ No newline at end of file
diff --git a/upload/catalog/view/theme/default/template/extension/myparcelnl/myparcel_xtension_pickup_change.twig b/upload/catalog/view/theme/default/template/extension/myparcelnl/myparcel_xtension_pickup_change.twig
new file mode 100755
index 0000000..a54048e
--- /dev/null
+++ b/upload/catalog/view/theme/default/template/extension/myparcelnl/myparcel_xtension_pickup_change.twig
@@ -0,0 +1,28 @@
+
\ No newline at end of file
diff --git a/upload/system/library/myparcelnl/assets/css/checkout.css b/upload/system/library/myparcelnl/assets/css/checkout.css
index 18ae547..31686f4 100755
--- a/upload/system/library/myparcelnl/assets/css/checkout.css
+++ b/upload/system/library/myparcelnl/assets/css/checkout.css
@@ -35,4 +35,51 @@
.text-right {
text-align: right;
+}
+.myparcel-delivery-table .myparcel_additional{
+ margin-right: 8px;
+}
+.myparceldatetime .group label {
+ background: transparent !important;
+ top: 0px !important;
+ font-size: 10px;
+}
+.group .myparceldate label {
+ left: 45px !important;
+}
+.group label {
+ color: #cecbe2;
+ font-size: 12px;
+ font-weight: 600;
+ position: absolute;
+ pointer-events: none;
+ left: 5px;
+ top: 12px;
+ transition: 0.2s ease all;
+ -moz-transition: 0.2s ease all;
+ -webkit-transition: 0.2s ease all;
+ z-index: 22;
+ padding: 0px 10px;
+}
+.bootstrap-datetimepicker-widget td.day{
+ font-weight: 600;
+ color: #333;
+}
+.bootstrap-datetimepicker-widget td.disabled, .bootstrap-datetimepicker-widget td.disabled:hover{
+ background: 0 0;
+ color: #777;
+ cursor: not-allowed;
+}
+.editmyparcel{
+ margin-left: 30px;
+ margin-top: 2px;
+ cursor: pointer;
+ color: orange;
+ font-size: 12px;
+}
+.myparceltext{
+ font-size: 11px;
+ font-weight: 600;
+ color: #777;
+ margin-left: 25px;
}
\ No newline at end of file
diff --git a/upload/system/library/myparcelnl/assets/css/myparcelnl.css b/upload/system/library/myparcelnl/assets/css/myparcelnl.css
index 54c63ee..06b1e70 100755
--- a/upload/system/library/myparcelnl/assets/css/myparcelnl.css
+++ b/upload/system/library/myparcelnl/assets/css/myparcelnl.css
@@ -82,4 +82,8 @@
.color-selector-custom-widget {
position: relative;
height: 36px;
+}
+#select_homenumber_suffix{
+ display: inherit;
+ width: auto;
}
\ No newline at end of file
diff --git a/upload/system/library/myparcelnl/assets/js/checkout.js b/upload/system/library/myparcelnl/assets/js/checkout.js
index 3895f39..edd6ec3 100755
--- a/upload/system/library/myparcelnl/assets/js/checkout.js
+++ b/upload/system/library/myparcelnl/assets/js/checkout.js
@@ -162,6 +162,7 @@ var MYPARCEL_CHECKOUT = MYPARCEL_CHECKOUT || {};
$(document).on('change', '#mypa-input', function() {
if ($(this).val()) {
$('#button-shipping-method').prop('disabled', false);
+ document.cookie = "myparcel_empty_results=0";
}
});
/**
diff --git a/upload/system/library/myparcelnl/assets/js/delivery-iframe/myparcel.js b/upload/system/library/myparcelnl/assets/js/delivery-iframe/myparcel.js
index f2e2be2..e3a69d4 100755
--- a/upload/system/library/myparcelnl/assets/js/delivery-iframe/myparcel.js
+++ b/upload/system/library/myparcelnl/assets/js/delivery-iframe/myparcel.js
@@ -421,8 +421,10 @@
if (response.data.message === 'No results') {
$('#mypa-no-options').html('Geen bezorgopties gevonden voor het opgegeven adres.');
$('.mypa-overlay').removeClass('mypa-hidden');
+ document.cookie = "myparcel_empty_results=1";
return;
}
+ document.cookie = "myparcel_empty_results=0";
$('.mypa-overlay').addClass('mypa-hidden');
if (window.mypa.settings.cc === NATIONAL) {
$('#mypa-delivery-option-check').bind('click', function() {
diff --git a/upload/system/library/myparcelnl/assets/js/order.js b/upload/system/library/myparcelnl/assets/js/order.js
index 2423a7f..7fe3f30 100755
--- a/upload/system/library/myparcelnl/assets/js/order.js
+++ b/upload/system/library/myparcelnl/assets/js/order.js
@@ -49,7 +49,9 @@ var MYPARCEL_SHIPMENT = MYPARCEL_SHIPMENT || {};
}
}
}
-
+ else{
+ alert(res.errors.join('.'));
+ }
MYPARCEL_SHIPMENT.helper.enableActionButtons(order_id);
},
complete: function() {
diff --git a/upload/system/library/myparcelnl/class_myparcel.php b/upload/system/library/myparcelnl/class_myparcel.php
index 98763f3..2f901c2 100755
--- a/upload/system/library/myparcelnl/class_myparcel.php
+++ b/upload/system/library/myparcelnl/class_myparcel.php
@@ -77,6 +77,14 @@ function getModulePath()
}
}
+ function getMyparcelXtensionViewPath(){
+ return 'extension/myparcelnl/';
+ }
+
+ function getMyparcelXtensionControllerPath(){
+ return 'extension/myparcelnl/myparcel_xtension_delivery';
+ }
+
function getModuleListPath()
{
if(version_compare(VERSION, '3.0.0.0', '>=')) {
diff --git a/upload/system/library/myparcelnl/includes/class_myparcel_helper.php b/upload/system/library/myparcelnl/includes/class_myparcel_helper.php
index d97c805..9cc7e9c 100755
--- a/upload/system/library/myparcelnl/includes/class_myparcel_helper.php
+++ b/upload/system/library/myparcelnl/includes/class_myparcel_helper.php
@@ -735,6 +735,18 @@ function set_module_text($language)
$data['entry_tab_3_label_belgium_pickup_fee'] = $language->get('entry_tab_3_label_belgium_pickup_fee');
$data['entry_tab_3_label_cut_off_weekday'] = $language->get('entry_tab_3_label_cut_off_weekday');
$data['error_cut_off_not_correct_format'] = $language->get('error_cut_off_not_correct_format');
+ $data['entry_tab_3_label_only_apply_for_xtension_checkout'] = $language->get('entry_tab_3_label_only_apply_for_xtension_checkout');
+ $data['entry_tab_3_label_time_format'] = $language->get('entry_tab_3_label_time_format');
+ $data['entry_tab_3_label_time_format_description'] = $language->get('entry_tab_3_label_time_format_description');
+ $data['entry_tab_3_label_distance'] = $language->get('entry_tab_3_label_distance');
+ $data['entry_tab_3_label_rounding_distance'] = $language->get('entry_tab_3_label_rounding_distance');
+ $data['entry_tab_3_label_rounding_distance_description'] = $language->get('entry_tab_3_label_rounding_distance_description');
+ $data['entry_tab_3_distance_format_kilometer'] = $language->get('entry_tab_3_distance_format_kilometer');
+ $data['entry_tab_3_distance_format_meter'] = $language->get('entry_tab_3_distance_format_meter');
+ $data['entry_tab_3_label_default_price_0_text'] = $language->get('entry_tab_3_label_default_price_0_text');
+ $data['entry_tab_3_label_default_price_0_text_description'] = $language->get('entry_tab_3_label_default_price_0_text_description');
+
+
$data['days_of_the_week'] = array(
'0' => $language->get('Sunday'),
@@ -752,7 +764,10 @@ function set_module_text($language)
'499' => $language->get('entry_tab_2_select_insured_up_to_500'),
'' => $language->get('entry_tab_2_select_insured_500'),
);
-
+ $data['distance_format'] = array(
+ 'm' => $language->get('entry_tab_3_distance_format_meter'),
+ 'km' => $language->get('entry_tab_3_distance_format_kilometer'),
+ );
$data['button_save'] = $language->get('button_save');
$data['button_cancel'] = $language->get('button_cancel');
@@ -795,7 +810,7 @@ function isModuleExist($module, $check_status = false)
if ($check_status) {
if ($result->num_rows) {
$config = $registry->get('config');
- if ($config->get($module . '_status')) {
+ if ($config->get('module_' . $module . '_status')) {
return true;
}
}
@@ -805,6 +820,331 @@ function isModuleExist($module, $check_status = false)
}
}
+ /**
+ * Get Address 2 or say address number if xtensions netherlands postcode module is installed!
+ **/
+ function getAddressNumberXNLPostcode($shipping_address, $prefix = ''){
+ $registry = $db = MyParcel::$registry;
+ if(version_compare(VERSION, '3.0.0.0')>=0){
+ $field = $registry->get('config')->get('module_xnlpostcode_nl_housenumber');
+ }else{
+ $field = $registry->get('config')->get('xnlpostcode_nl_housenumber');
+ }
+ if($field){
+ if(in_array($field, array('address_2','company'))){
+ return $shipping_address[$prefix . $field];
+ }else{
+ return $shipping_address[$prefix . 'custom_field'][$field];
+ }
+ }
+ return $shipping_address[$prefix . 'address_2'];
+ }
+
+ public function getAddressCustomFields(){
+ $registry = $db = MyParcel::$registry;
+ $db = $registry->get('db');
+ $query = $db->query("SELECT cfd.custom_field_id AS id, cfd.name FROM `" . DB_PREFIX . "custom_field` cf JOIN `" . DB_PREFIX . "custom_field_description` cfd ON cf.custom_field_id = cfd.custom_field_id WHERE cf.status = 1 AND cf.location = 'address' ");
+ return array_merge($query->rows);
+ }
+
+ public function getDeliveryParams($shipping_address, $prefix = ''){
+
+ $shipment_class = MyParcel()->shipment;
+ $registry = MyParcel::$registry;
+ $checkout_helper = $shipment_class->checkout;
+ $config = $registry->get('config');
+
+ $myparcelnl_checkout_settings = $config->get('module_myparcelnl_fields_checkout');
+ $myparcelnl_general_settings = $config->get('module_myparcelnl_fields_general');
+
+ $deliverydays_window = isset($myparcelnl_checkout_settings['delivery_days_window']) ? $myparcelnl_checkout_settings['delivery_days_window'] : 4;
+
+ $use_addition_address_as_number_suffix = MyParcel()->settings->general->use_addition_address_as_number_suffix;
+ if (!empty($shipping_address[$prefix.'address_2']) && !$use_addition_address_as_number_suffix) {
+ $shipping_address[$prefix.'address_1'] = $shipping_address[$prefix.'address_1'] . ' ' . $shipping_address[$prefix.'address_2'];
+ }
+ $address_parts = $this->getAddressComponents($shipping_address[$prefix.'address_1']);
+ if($this->isModuleExist('xnlpostcode', true)){
+ $house_number = $this->getAddressNumberXNLPostcode($shipping_address,$prefix);
+ }else{
+ $house_number = isset($address_parts['house_number']) ? $address_parts['house_number'] : '';
+ }
+
+ $exclude_delivery_types = array();
+ foreach ($checkout_helper::$delivery_types_as_value as $delivery_type => $key) {
+ // JS API correction
+ if ($delivery_type == 'standard' || $delivery_type == 'mailbox' || $delivery_type == 'avond') {
+ continue;
+ }
+ if (!isset($myparcelnl_checkout_settings[$delivery_type.'_enabled']) || (isset($myparcelnl_checkout_settings[$delivery_type.'_enabled']) && empty($myparcelnl_checkout_settings[$delivery_type.'_enabled']) ) ) {
+ $exclude_delivery_types[] = $key;
+ }
+ }
+ $exclude_delivery_types = implode(';', $exclude_delivery_types);
+ /**
+ * Get cut_off_time based on current day
+ **/
+ $cut_off_time = !empty($myparcelnl_checkout_settings['cut_off_time']) ? $myparcelnl_checkout_settings['cut_off_time'] : '';
+ // If cut_off_time by weekdays enabled
+ $cut_off_time_weekdays_enabled = !empty($myparcelnl_checkout_settings['cut_off_weekday']) ? $myparcelnl_checkout_settings['cut_off_weekday'] : '';
+ if ($cut_off_time_weekdays_enabled) {
+ $day_of_week = date('w');
+ $cut_off_time = (!empty($myparcelnl_checkout_settings['cut_off_time_weekdays'][$day_of_week]) ? $myparcelnl_checkout_settings['cut_off_time_weekdays'][$day_of_week] : '');
+ }
+ //get dropoff days
+ $dropoff_day = isset($myparcelnl_checkout_settings['dropoff_days']) ? $myparcelnl_checkout_settings['dropoff_days'] : '';
+
+ $delivery_params = array(
+ 'cc' => $shipping_address[$prefix.'iso_code_2'],
+ 'postal_code' => $shipping_address[$prefix.'postcode'],
+ 'street' => isset($address_parts['street']) ? $address_parts['street'] :"",
+ 'number' => $house_number,
+ 'carrier' => 1,
+ 'cutoff_time' => $cut_off_time,
+ 'exclude_delivery_type' => $exclude_delivery_types,
+ 'deliverydays_window' => $deliverydays_window,
+ 'monday_delivery' => '1',
+ 'dropoff_delay' => (isset($myparcelnl_checkout_settings['dropoff_delay']) && $myparcelnl_checkout_settings['dropoff_delay'] != '') ? $myparcelnl_checkout_settings['dropoff_delay'] : 0,
+
+ );
+ if(!empty($dropoff_day)){
+ $delivery_params['dropoff_days'] = implode(';',$dropoff_day);
+ }
+ if(isset($myparcelnl_general_settings['use_addition_address_as_number_suffix'])){
+ switch ((int)$myparcelnl_general_settings['use_addition_address_as_number_suffix']){
+ case 1:
+ if($house_number == ''){
+ $delivery_params['number'] = $shipping_address[$prefix.'address_2'];
+ }
+ break;
+ case 2:
+ if(isset($shipping_address[$prefix.'custom_field'][$myparcelnl_general_settings['general_custom_field_homenumber_suffix']])){
+ $delivery_params['number_suffix'] = $shipping_address[$prefix.'custom_field'][$myparcelnl_general_settings['general_custom_field_homenumber_suffix']];
+ }
+ if($house_number == ''){
+ $delivery_params['number'] = $shipping_address[$prefix.'address_2'];
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ return $delivery_params;
+ }
+
+ public function formatDeliveryParamsEditOrder($delivery_params, $order_id){
+ $registry = MyParcel::$registry;
+ $loader = $registry->get('load');
+ $loader->model(MyParcel()->getModelPath('shipment'));
+ $model_shipment = $registry->get('model_extension_myparcelnl_shipment');
+ $checkout_helper = MyParcel()->shipment->checkout;
+
+ // Load delivery options stored from Frontend Checkout
+ $myparcel_delivery_options = $model_shipment->getMyParcelDeliveryOptions($order_id);
+ if($myparcel_delivery_options != NULL){
+ $delivery_type = $checkout_helper->getDeliveryTypeFromSavedData($myparcel_delivery_options);
+ if(isset($delivery_params['exclude_delivery_type'])){
+ $delivery_params['exclude_delivery_type'] = explode(';',$delivery_params['exclude_delivery_type']);
+ if(in_array($delivery_type,$delivery_params['exclude_delivery_type'])){
+ $delivery_params['exclude_delivery_type'] = array_diff( $delivery_params['exclude_delivery_type'], [$delivery_type] );
+ }
+ $delivery_params['exclude_delivery_type'] = implode(';',$delivery_params['exclude_delivery_type']);
+ }
+ }
+ return $delivery_params;
+ }
+
+ public function getDeliveryOptionChange($myparcel_delivery,$order_data){
+ $registry = MyParcel::$registry;
+ $loader = $registry->get('load');
+ $loader->model(MyParcel()->getModelPath('shipment'));
+ $model_shipment = $registry->get('model_extension_myparcelnl_shipment');
+ $checkout_helper = MyParcel()->shipment->checkout;
+ $shipping_code = null;
+ // Load delivery options stored from Frontend Checkout
+ $myparcel_delivery_options = $model_shipment->getMyParcelDeliveryOptions($order_data['order_id']);
+ if(!empty($myparcel_delivery_options)){
+ $delivery_type = $checkout_helper->getDeliveryTypeFromSavedData($myparcel_delivery_options);
+
+ $is_next_day = false;
+ foreach ($myparcel_delivery as $key => $item ){
+ foreach ($item as $value){
+ foreach ($value['time'] as $time){
+ if($time['type'] == $delivery_type){
+ if((date('Y-m-d',strtotime($myparcel_delivery_options['date'])) <= date('Y-m-d'))){
+ $myparcel_delivery_options['date'] = $value['date'];
+ }
+ $is_next_day = true;
+ $shipping_code = $key;
+ break;
+ }
+ }
+ if($is_next_day){
+ break;
+ }
+ }
+ if($is_next_day){
+ break;
+ }
+ }
+ }
+ $myparcel_delivery_options['shipping_code'] = $shipping_code;
+ return $myparcel_delivery_options;
+ }
+
+ public function formatDeliveryPrice($myparcel_delivery,$shipping_address,$sub_total,$language, $current_currency_code){
+ $registry = MyParcel::$registry;
+ $config = $registry->get('config');
+ $myparcelnl_checkout_settings = $config->get('module_myparcelnl_fields_checkout');
+
+ $rounding_distance = (isset($myparcelnl_checkout_settings['rounding_distance']) && $myparcelnl_checkout_settings['rounding_distance']) ? $myparcelnl_checkout_settings['rounding_distance'] : 1;
+ $distance_format = (isset($myparcelnl_checkout_settings['distance_format']) && $myparcelnl_checkout_settings['distance_format']) ? $myparcelnl_checkout_settings['distance_format'] : "m";
+ $default_price_0_text = (isset($myparcelnl_checkout_settings['default_price_0_text'])&& $myparcelnl_checkout_settings['default_price_0_text']) ? $myparcelnl_checkout_settings['default_price_0_text'] : '';
+ $time_format = (isset($myparcelnl_checkout_settings['time_format']) && $myparcelnl_checkout_settings['time_format']) ? $myparcelnl_checkout_settings['time_format'] : "H:i:s";
+
+ $shipment_class = MyParcel()->shipment;
+ /** @var MyParcel_Shipment_Checkout $checkout_helper **/
+ $checkout_helper = $shipment_class->checkout;
+ $delivery_prices = $checkout_helper->getDeliveryPrices(false, true, '', false, 0,$sub_total);
+ $delivery_prices_format = $checkout_helper->getDeliveryPrices(false, true, '', true, 0,$sub_total);
+
+
+ $currency = $registry->get('currency');
+
+ if(isset($delivery_prices[$shipping_address['iso_code_2']])){
+ foreach($myparcel_delivery['body']['data'] as $key => $value){
+ if(count($value)){
+ foreach($value as $k => $v){
+ foreach($v['time'] as $index => $time){
+ $price = null;
+ $price_convert = null;
+ if(isset($time['price_comment'])){
+ switch($time['price_comment']){
+ case 'morning':
+ $price = isset($delivery_prices[$shipping_address['iso_code_2']]['morning']) ? $delivery_prices[$shipping_address['iso_code_2']]['morning'] : null;
+ $price_convert = isset($delivery_prices_format[$shipping_address['iso_code_2']]['morning']) ? $delivery_prices_format[$shipping_address['iso_code_2']]['morning'] : null;
+ break;
+ case 'standard':
+ $price = isset($delivery_prices[$shipping_address['iso_code_2']]['default']) ? $delivery_prices[$shipping_address['iso_code_2']]['default'] : null;
+ $price_convert = isset($delivery_prices_format[$shipping_address['iso_code_2']]['default']) ? $delivery_prices_format[$shipping_address['iso_code_2']]['default'] : null;
+ break;
+ case 'night':
+ case 'avond':
+ $price = isset($delivery_prices[$shipping_address['iso_code_2']]['night']) ? $delivery_prices[$shipping_address['iso_code_2']]['night'] : null;
+ $price_convert = isset($delivery_prices_format[$shipping_address['iso_code_2']]['night']) ? $delivery_prices_format[$shipping_address['iso_code_2']]['night'] : null;
+ break;
+ }
+ $myparcel_delivery['body']['data'][$key][$k]['time'][$index]['price_comment_text'] = $language->get('entry_delivery_' . $time['price_comment']);
+ }
+ else{
+ if(isset($v['price_comment'])){
+ switch($v['price_comment']){
+ case 'retail':
+ $price = isset($delivery_prices[$shipping_address['iso_code_2']]['pickup']) ? $delivery_prices[$shipping_address['iso_code_2']]['pickup'] : null;
+ $price_convert = isset($delivery_prices_format[$shipping_address['iso_code_2']]['pickup']) ? $delivery_prices_format[$shipping_address['iso_code_2']]['pickup'] : null;
+ break;
+ case 'retailexpress':
+ $price = isset($delivery_prices[$shipping_address['iso_code_2']]['pickup_express']) ? $delivery_prices[$shipping_address['iso_code_2']]['pickup_express'] : null;
+ $price_convert = isset($delivery_prices_format[$shipping_address['iso_code_2']]['pickup_express']) ? $delivery_prices_format[$shipping_address['iso_code_2']]['pickup_express'] : null;
+ break;
+ }
+ }
+ if(isset($v['location'])){
+ $myparcel_delivery['body']['data'][$key][$k]['location'] = htmlspecialchars($v['location']);
+ }
+ }
+ if($price !== null){
+ $myparcel_delivery['body']['data'][$key][$k]['time'][$index]['price']['amount'] = $price;
+ }
+ if($price_convert != null){
+ $price = $price_convert;
+ $myparcel_delivery['body']['data'][$key][$k]['time'][$index]['price']['amount_with_tax'] = $price_convert;
+ }
+ else{
+ $price = $myparcel_delivery['body']['data'][$key][$k]['time'][$index]['price']['amount'];
+ $myparcel_delivery['body']['data'][$key][$k]['time'][$index]['price']['amount_with_tax'] = $price;
+ }
+
+ //format price
+ $myparcel_delivery['body']['data'][$key][$k]['time'][$index]['price']['text_amount'] = ($price == 0 && $default_price_0_text != '') ? $default_price_0_text : $currency->format($currency->convert($price, $time['price']['currency'], $current_currency_code), $current_currency_code);
+ $myparcel_delivery['body']['data'][$key][$k]['time'][$index]['price']['current_currency_amount'] = round($currency->convert($price, $time['price']['currency'], $current_currency_code), 2);
+
+ //format time
+ if(isset($myparcel_delivery['body']['data'][$key][$k]['time'][$index]['start'])){
+ $myparcel_delivery['body']['data'][$key][$k]['time'][$index]['start'] = date($time_format,strtotime($myparcel_delivery['body']['data'][$key][$k]['time'][$index]['start']));
+ }
+ if(isset($myparcel_delivery['body']['data'][$key][$k]['time'][$index]['end'])){
+ $myparcel_delivery['body']['data'][$key][$k]['time'][$index]['end'] = date($time_format,strtotime($myparcel_delivery['body']['data'][$key][$k]['time'][$index]['end']));
+ }
+ }
+ //format distance
+ if(isset($v['distance'])){
+ switch ($distance_format){
+ case "km":
+ $myparcel_delivery['body']['data'][$key][$k]['distance'] = round($v['distance'] / 1000, $rounding_distance);
+ break;
+ case "m":
+ break;
+ }
+ $myparcel_delivery['body']['data'][$key][$k]['distance_format'] = $distance_format;
+ }
+ }
+ }
+ }
+ }
+
+ return $myparcel_delivery;
+ }
+
+ function getDisableDropoffDays($myparcel_delivery){
+// $registry = MyParcel::$registry;
+// $config = $registry->get('config');
+// $myparcelnl_checkout_settings = $config->get('module_myparcelnl_fields_checkout');
+//
+// if(!isset($myparcelnl_checkout_settings['dropoff_days'])){
+// return [0,6];
+// }
+// $dropoff_days = $myparcelnl_checkout_settings['dropoff_days'];
+
+ $enable_days = [];
+ if(isset($myparcel_delivery['delivery'])){
+ foreach ($myparcel_delivery['delivery'] as $delivery){
+ $day_num = date('w', strtotime($delivery['date']));
+ if(!in_array($day_num,$enable_days)){
+ $enable_days[] = $day_num;
+ }
+ }
+ }
+ return array_diff(range(0,6),$enable_days);
+ }
+
+ public function getDeliveryNextWorkingDate($delivery_type = MyParcel_Shipment_Checkout::DELIVERY_TYPE_STANDARD,$order_data , $is_pickup = false){
+ $disable_days = [0];
+ //if delivery option is not standard, explude Saturday when choose the next day working
+ if($delivery_type != MyParcel_Shipment_Checkout::DELIVERY_TYPE_STANDARD){
+ $disable_days[] = 6;
+ }
+ $next_working_date = null;
+
+ $key = ($is_pickup) ? 'pickup' : 'delivery';
+ $api = MyParcel()->api;
+ $delivery_params = $this->getDeliveryParams($order_data,'shipping_');
+ $myparcel_delivery = $api->getDeliveryOptions($delivery_params);
+ if(isset($myparcel_delivery['code']) && $myparcel_delivery['code'] == 200 && !isset($myparcel_delivery['body']['errors'])){
+ if(count($myparcel_delivery['body']['data'][$key])){
+ foreach ($myparcel_delivery['body']['data'][$key] as $delivery){
+ $day_num = date('w', strtotime($delivery['date']));
+ if(!in_array($day_num,$disable_days)){
+ $next_working_date = $delivery['date'];
+ break;
+ }
+ }
+ }
+ }
+ return $next_working_date;
+ }
+
+
function getCountryIsoCodeFromSession()
{
$registry = MyParcel::$registry;
diff --git a/upload/system/library/myparcelnl/includes/class_myparcel_shipment.php b/upload/system/library/myparcelnl/includes/class_myparcel_shipment.php
index db1da03..6b65488 100755
--- a/upload/system/library/myparcelnl/includes/class_myparcel_shipment.php
+++ b/upload/system/library/myparcelnl/includes/class_myparcel_shipment.php
@@ -117,7 +117,7 @@ function add($params, $process = false)
if (version_compare(VERSION, '2.0.0.0', '>=')) {
/** @var MyParcel_Api $api * */
$api = MyParcel()->api;
- $response = $api->getLocalRequest('myparcelnl/myparcel_order/updateorderstatus', array('order_id' => $order_id));
+ $response = $api->getLocalRequest('extension/myparcelnl/myparcel_order/updateorderstatus', array('order_id' => $order_id));
if (empty($response['body']['success'])) {
$this->errors[] = MyParcel()->lang->get('entry_update_order_status_error') . ' - Order #' . $order_id;
MyParcel()->log->add('Update status error - Order #' . $order_id);
@@ -244,6 +244,11 @@ function printPdf($order_ids, $label_response_type = NULL, $position = null)
$return = array();
/** @var MyParcel_Helper $helper **/
$helper = MyParcel()->helper;
+ /** @var ModelMyparcelnlShipment $model_shipment **/
+ $registry = MyParcel::$registry;
+ $loader = $registry->get('load');
+ $loader->model(MyParcel()->getModelPath('shipment'));
+ $model_shipment = $registry->get('model_extension_myparcelnl_shipment');
$shipment_ids = $shipment_helper->getShipmentIdsByOrderIds( $order_ids, array( 'only_last' => true ) );
@@ -280,7 +285,27 @@ function printPdf($order_ids, $label_response_type = NULL, $position = null)
$pdf_data = $response['body'];
$setting_download_display = MyParcel()->settings->general->pdf;
$output_mode = !empty($setting_download_display) ? 'download' : 'display';
+ foreach ( $order_ids as $order_id) {
+ $order_shipments = $model_shipment->getSavedMyParcelShipments($order_id);
+ $is_update_external_id = false;
+ $shipment_id = null;
+ foreach ( $order_shipments as $key => $shipment) {
+ if(isset($shipment['tracktrace']) && !empty($shipment['tracktrace'])) {
+ $model_shipment->update($order_id, 'external_id', $shipment['tracktrace']);
+ $is_update_external_id = true;
+ }
+ $shipment_id = $key;
+ }
+ if(!$is_update_external_id){
+ $shipment_info = $api->getShipments($shipment_id);
+ if(isset($shipment_info['code']) && $shipment_info['code'] == 200){
+ if(isset($shipment_info['body']['data']['shipments'][0]['external_identifier'])){
+ $model_shipment->update($order_id,'external_id',$shipment_info['body']['data']['shipments'][0]['external_identifier']);
+ }
+ }
+ }
+ }
if ( $output_mode == 'display' ) {
$shipment_helper->streamPdf( $pdf_data, $order_ids );
} else {
diff --git a/upload/system/library/myparcelnl/includes/class_myparcel_shipment_checkout.php b/upload/system/library/myparcelnl/includes/class_myparcel_shipment_checkout.php
index ff337eb..66fbc53 100755
--- a/upload/system/library/myparcelnl/includes/class_myparcel_shipment_checkout.php
+++ b/upload/system/library/myparcelnl/includes/class_myparcel_shipment_checkout.php
@@ -221,6 +221,9 @@ public function getDeliveryTypeFromSavedData( $myparcel_delivery_options )
if ( empty($myparcel_delivery_options['price_comment']) && !empty($myparcel_delivery_options['time']) ) {
// check if we have a price_comment in the time option
$delivery_time = ($myparcel_delivery_options['time']);
+ if(count($delivery_time) == 1){
+ $delivery_time = array_shift($myparcel_delivery_options['time']);
+ }
if (isset($delivery_time['price_comment'])) {
$delivery_type = $delivery_time['price_comment'];
}
@@ -257,6 +260,9 @@ public function getDeliveryDateFromSavedData($myparcel_delivery_options)
$delivery_type = $this->getDeliveryTypeFromSavedData( $myparcel_delivery_options );
if ( in_array($delivery_type, array(self::DELIVERY_TYPE_MORNING, self::DELIVERY_TYPE_NIGHT)) && !empty($myparcel_delivery_options['time']) ) {
$delivery_time_options = ($myparcel_delivery_options['time']);
+ if(count($delivery_time_options) == 1){
+ $delivery_time_options = array_shift($myparcel_delivery_options['time']);
+ }
$delivery_time = $delivery_time_options['start'];
} else {
$delivery_time = '00:00:00';
@@ -286,27 +292,27 @@ function getDeliveryPrices($price_format = true, $color_format = true, $prefix =
$checkout_settings = $config->get('module_myparcelnl_fields_checkout');
$price_options = array_merge( self::$delivery_extra_options, self::$delivery_types );
$prices = array();
-
- // default settings
+
+ // default settings
$price_type = 0;
- $subtotal1_min = isset($checkout_settings['subtotal1_min']) ? $checkout_settings['subtotal1_min'] : 0;
- $subtotal1_max = isset($checkout_settings['subtotal1_max']) ? $checkout_settings['subtotal1_max'] : 50;
- $subtotal2_min = isset($checkout_settings['subtotal2_min']) ? $checkout_settings['subtotal2_min'] : 50.01;
- $subtotal2_max = isset($checkout_settings['subtotal2_max']) ? $checkout_settings['subtotal2_max'] : 1000000;
+ $subtotal1_min = isset($checkout_settings['subtotal1_min']) ? $checkout_settings['subtotal1_min'] : 0;
+ $subtotal1_max = isset($checkout_settings['subtotal1_max']) ? $checkout_settings['subtotal1_max'] : 50;
+ $subtotal2_min = isset($checkout_settings['subtotal2_min']) ? $checkout_settings['subtotal2_min'] : 50.01;
+ $subtotal2_max = isset($checkout_settings['subtotal2_max']) ? $checkout_settings['subtotal2_max'] : 1000000;
if($order_id > 0) {
$loader = $registry->get('load');
- $loader->model('checkout/order');
- $model_order = $registry->get('model_checkout_order');
+ $loader->model('checkout/order');
+ $model_order = $registry->get('model_checkout_order');
$order = $model_order->getOrder($order_id);
$value = $order['total'];
-
+
if($subtotal2_min <= $value && $value < $subtotal2_max)
$price_type = 1;
}else{
if($subtotal2_min <= $value && $value < $subtotal2_max)
$price_type = 1;
- }
+ }
foreach ($price_options as $key => $option) {
// JS API correction
@@ -317,10 +323,10 @@ function getDeliveryPrices($price_format = true, $color_format = true, $prefix =
$option_enabled = (!empty($checkout_settings[$option.'_enabled'])) ? true : false;
if ($option_enabled) {
- if ($price_type == 0 && !empty($checkout_settings[$option . '_fee'])) {
- $fee = $checkout_settings[$option . '_fee'];
+ if ($price_type == 0 && (float)$checkout_settings[$option . '_fee'] >= 0) {
+ $fee = (float)$checkout_settings[$option . '_fee'];
- if($fee > 0) {
+ if($fee >= 0) {
$fee = $this->convertPriceToFloat($fee);
//$fee += $this->getMyParcelShippingCost();
@@ -339,11 +345,11 @@ function getDeliveryPrices($price_format = true, $color_format = true, $prefix =
$prices[$option] = $formatted_fee;
}
}
-
- if ($price_type == 1 && !empty($checkout_settings[$option . '_fee2'])) {
- $fee = $checkout_settings[$option . '_fee2'];
- if($fee > 0) {
+ if ($price_type == 1 && (float)($checkout_settings[$option . '_fee2']) >= 0 ) {
+ $fee = (float)$checkout_settings[$option . '_fee2'];
+
+ if($fee >= 0) {
$fee = $this->convertPriceToFloat($fee);
//$fee += $this->getMyParcelShippingCost();
@@ -384,8 +390,8 @@ function getDeliveryPrices($price_format = true, $color_format = true, $prefix =
$formatted_fee = '';
- if ($price_type == 0 && !empty($checkout_settings['belgium_' . $option . '_fee'])) {
- $fee = $checkout_settings['belgium_' . $option . '_fee'];
+ if ($price_type == 0 && (float)($checkout_settings['belgium_' . $option . '_fee']) >= 0) {
+ $fee = (float)$checkout_settings['belgium_' . $option . '_fee'];
$fee = $this->convertPriceToFloat($fee);
$fee_including_tax = $this->getTotalDeliveryTaxAmountFromCart($fee, $cart);
//$fee_including_tax = $fee;
@@ -396,8 +402,8 @@ function getDeliveryPrices($price_format = true, $color_format = true, $prefix =
}
}
- if ($price_type == 1 && !empty($checkout_settings['belgium_' . $option . '_fee2'])) {
- $fee = $checkout_settings['belgium_' . $option . '_fee2'];
+ if ($price_type == 1 && (float)($checkout_settings['belgium_' . $option . '_fee2']) >= 0) {
+ $fee = (float)$checkout_settings['belgium_' . $option . '_fee2'];
$fee = $this->convertPriceToFloat($fee);
$fee_including_tax = $this->getTotalDeliveryTaxAmountFromCart($fee, $cart);
//$fee_including_tax = $fee;
@@ -422,6 +428,26 @@ function getDeliveryPrices($price_format = true, $color_format = true, $prefix =
);
}
+ function getTaxFromCart(){
+ $registry = MyParcel::$registry;
+ /** @var \Cart\Cart $cart **/
+ $cart = $registry->get('cart');
+
+ /** @var Cart\Tax $tax **/
+ $tax = $cart->tax;
+ if (!$tax || !$cart) {
+ return '';
+ }
+
+ foreach ($cart->getProducts() as $product) {
+ if ($product['tax_class_id']) {
+ return $product['tax_class_id'];
+ }
+ }
+ return '';
+
+ }
+
/**
* Converts price string to float value, assuming no thousand-separators used
* @param float $price
diff --git a/upload/system/library/myparcelnl/includes/class_myparcel_shipment_helper.php b/upload/system/library/myparcelnl/includes/class_myparcel_shipment_helper.php
index 96218c4..c8921c3 100755
--- a/upload/system/library/myparcelnl/includes/class_myparcel_shipment_helper.php
+++ b/upload/system/library/myparcelnl/includes/class_myparcel_shipment_helper.php
@@ -14,7 +14,7 @@ public function getOrderShipmentData($order_id)
$shipment = array(
'recipient' => $this->getRecipient( $order_data ),
- 'options' => $this->getOptions( $order_data ),
+ 'options' => $this->getOptions( $order_data , false, true ),
'carrier' => 1, // default to POSTNL for now
);
@@ -32,7 +32,9 @@ public function getOrderShipmentData($order_id)
$shipment['pickup']['retail_network_id'] = $pickup['retail_network_id'];
}
}
-
+ if($shipment['options'] == null){
+ return null;
+ }
return $shipment;
}
@@ -51,7 +53,7 @@ public function getRecipient( $order )
);
$use_addition_address_as_number_suffix = MyParcel()->settings->general->use_addition_address_as_number_suffix;
-
+ $general_custom_field_homenumber_suffix = MyParcel()->settings->general->general_custom_field_homenumber_suffix;
// MyParcel_Helper $helper
$helper = MyParcel()->helper;
$iso_code = @ $order['shipping_iso_code_2'];
@@ -69,7 +71,8 @@ public function getRecipient( $order )
} elseif ($use_addition_address_as_number_suffix == 2) {
$address_parts['street'] = isset($order['shipping_address_1']) ? $order['shipping_address_1'] : '';
$address_parts['house_number'] = isset($order['shipping_address_2']) ? $order['shipping_address_2'] : '';
- $number_addition = isset($order['shipping_custom_field']['address_3']) ? $order['shipping_custom_field']['address_3'] : '';
+// $number_addition = isset($order['shipping_custom_field']['address_3']) ? $order['shipping_custom_field']['address_3'] : '';
+ $number_addition = isset($order['shipping_custom_field'][$general_custom_field_homenumber_suffix]) ? $order['shipping_custom_field'][$general_custom_field_homenumber_suffix] : '';
} else {
$number_addition = isset($address_parts['number_addition']) ? $address_parts['number_addition'] : '';
}
@@ -81,7 +84,11 @@ public function getRecipient( $order )
'postal_code' => $order['shipping_postcode'],
);
}
-
+ if($address_intl['number'] == ''){
+ if(MyParcel()->helper->isModuleExist('xnlpostcode', true)){
+ $address_intl['number'] = MyParcel()->helper->getAddressNumberXNLPostcode($order,'shipping_');
+ }
+ }
$address = array_merge($address, $address_intl);
return $address;
@@ -95,7 +102,7 @@ public function getRecipient( $order )
* @return array
*
**/
- public function getOptions( $order_data , $view = false )
+ public function getOptions( $order_data , $view = false , $export = false)
{
/** @var ModelMyparcelnlShipment $model_shipment **/
$registry = MyParcel::$registry;
@@ -268,7 +275,13 @@ public function getOptions( $order_data , $view = false )
// Load delivery options stored from Frontend Checkout
$myparcel_delivery_options = $model_shipment->getMyParcelDeliveryOptions($order_id);
-
+ //get myparcel shipment type
+ if(!empty($myparcel_delivery_options)){
+ $myparcel_shipment_type = $model_shipment->getData($order_id,'type');
+ if($myparcel_shipment_type != null && $myparcel_shipment_type != $order_data['shipping_code']){
+ $myparcel_delivery_options = array();
+ }
+ }
// Set delivery type
$options['delivery_type'] = $checkout_helper->getDeliveryTypeFromSavedData($myparcel_delivery_options);
@@ -281,6 +294,41 @@ public function getOptions( $order_data , $view = false )
// delivery date (postponed delivery & pickup)
if ($delivery_date = $checkout_helper->getDeliveryDateFromSavedData( $myparcel_delivery_options ) ) {
$date_time = explode(' ', $delivery_date); // split date and time
+ if($export){
+ if(date('Y-m-d') >= date('Y-m-d',strtotime($date_time[0]))){
+ //if date is outdate, will update it to next working date
+ $next_working_date = MyParcel()->helper->getDeliveryNextWorkingDate($options['delivery_type'],$order_data,$this->isPickup( $order_id ));
+ if($next_working_date == null){
+ return null;
+ }
+ $delivery_time = $date_time[1];
+// $time_end = '';
+// //check if the next working date is saturday, create only standard delivery
+// if(date('w', strtotime($next_working_date)) == 6){
+// $delivery_time = '12:00:00';
+// $time_end = '14:30:00';
+// }
+
+ //START update delivery_option in myparcel_shipment table
+ $myparcel_delivery_options['date'] = $next_working_date;
+// if(!empty($time_end)){
+// $time_detail_option = $myparcel_delivery_options['time'];
+// if(count($time_detail_option) == 1){
+// $time_detail_option = array_shift($myparcel_delivery_options['time']);
+// $time_detail_option['start'] = $delivery_time;
+// $time_detail_option['end'] = $time_end;
+// $time_detail_option['price_comment'] = 'standard';
+// }
+// $myparcel_delivery_options['time'][] = $time_detail_option;
+// }
+ $model_shipment->update($order_id,'delivery_options',$myparcel_delivery_options);
+ //END update delivery_option in myparcel_shipment table
+
+ $delivery_date = "{$next_working_date} {$delivery_time}";
+ $options['delivery_date'] = $delivery_date;
+ }
+
+ }
// only add if date is in the future
$timestamp = strtotime($date_time[0]);
if (time() < $timestamp) {
diff --git a/upload/system/library/myparcelnl/includes/class_myparcel_view.php b/upload/system/library/myparcelnl/includes/class_myparcel_view.php
index 1c22a21..e0893e1 100755
--- a/upload/system/library/myparcelnl/includes/class_myparcel_view.php
+++ b/upload/system/library/myparcelnl/includes/class_myparcel_view.php
@@ -195,7 +195,7 @@ function return_shipment_form($order_ids, $screen)
$html .= '' . MyParcel()->lang->get('entry_order') . ' #' . $order_id . ' ';
//TODO also render summary order table
$html .= $this->ship_to_myparcel($order_id, true, $screen);
- if (count($total) > 1) {
+ if (($total) > 1) {
$html .= ' ';
}
}
diff --git a/upload/system/library/myparcelnl/myparcel.ocmod.xml b/upload/system/library/myparcelnl/myparcel.ocmod.xml
index 1f7327b..387e1ff 100755
--- a/upload/system/library/myparcelnl/myparcel.ocmod.xml
+++ b/upload/system/library/myparcelnl/myparcel.ocmod.xml
@@ -5,7 +5,7 @@
-->
MyParcel NL
- 1.0.5
+ 1.1.0
MyParcelNL
MyParcel NL
https://www.myparcel.nl/
@@ -464,6 +464,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -506,6 +533,663 @@
+
+
+ request->get['showpayment'])) {]]>
+ cart->hasShipping() && isset($this->session->data['shipping_method']['code']) && ($this->session->data['shipping_method']['code'] == 'myparcel_delivery.myparcel_delivery' || $this->session->data['shipping_method']['code'] == 'myparcel_pickup.myparcel_pickup')){
+ if (!class_exists('MyParcel')) {
+ require_once DIR_SYSTEM . 'library/myparcelnl/class_myparcel.php';
+ MyParcel($this->registry);
+ }
+ $myparcel_error = $this->load->controller(MyParcel()->getMyparcelXtensionControllerPath().'/externalValidate');
+ if($myparcel_error){
+ $json['error'] = $myparcel_error;
+ }
+ }
+ //Myparcel plugin - end
+ ]]>
+
+
+ template = $this->config->get('xtensions_view_path').'xpayment_address';]]>
+ session->data['myparcel_api_errors'])){
+ $this->data['myparcel_api_errors'] = $this->session->data['myparcel_api_errors'];
+ }
+ ]]>
+
+
+
+
+
+ request->get['direct'])){]]>
+ cart->hasShipping() && isset($this->session->data['shipping_method']['code']) && ($this->session->data['shipping_method']['code'] == 'myparcel_delivery.myparcel_delivery' || $this->session->data['shipping_method']['code'] == 'myparcel_pickup.myparcel_pickup')){
+ if (!class_exists('MyParcel')) {
+ require_once DIR_SYSTEM . 'library/myparcelnl/class_myparcel.php';
+ MyParcel($this->registry);
+ }
+ $myparcel_error = $this->load->controller(MyParcel()->getMyparcelXtensionControllerPath().'/externalValidate');
+ if($myparcel_error){
+ $json['error'] = $myparcel_error;
+ }
+ }
+ //Myparcel plugin - end
+ ]]>
+
+
+
+
+
+ session->data['shipping_address'])){
+ $json['address_exit'] = 1;
+ }
+ ]]>
+
+
+
+
+
+
+
+
+ registry);
+ }
+ if(isset($this->session->data['shipping_method'])){
+ if(isset($this->session->data['myparcel_shipping_choosed'])){
+ $shipping_method = $this->session->data['shipping_method'];
+ $myparcel_shipping_choosed = $this->session->data['myparcel_shipping_choosed'];
+ if(explode('.',$shipping_method['code'])[0] != $myparcel_shipping_choosed['code']){
+ unset($this->session->data['myparcel_shipping_choosed']);
+ }
+ }
+ }
+ else{
+ if(isset($this->session->data['myparcel_shipping_choosed'])){
+ unset($this->session->data['myparcel_shipping_choosed']);
+ }
+ }
+ if (!empty($shipping_address) && ($shipping_address['iso_code_2'] == 'NL' || $shipping_address['iso_code_2'] == 'BE')) {
+ $api = MyParcel()->api;
+ $registry = MyParcel::$registry;
+ /** @var \Cart\Currency $currency **/
+ $currency = $registry->get('currency');
+ $current_currency_code = $this->session->data['currency'];
+ $shipment_class = MyParcel()->shipment;
+ /** @var MyParcel_Shipment_Checkout $checkout_helper **/
+ $checkout_helper = $shipment_class->checkout;
+ $config = $registry->get('config');
+ $myparcelnl_checkout_settings = $config->get('module_myparcelnl_fields_checkout');
+ $default_price_0_text = isset($myparcelnl_checkout_settings['default_price_0_text']) ? $myparcelnl_checkout_settings['default_price_0_text'] : '';
+ if(isset($myparcelnl_checkout_settings['enable_delivery']) && $myparcelnl_checkout_settings['enable_delivery'] == 1){
+ $delivery_params = MyParcel()->helper->getDeliveryParams($shipping_address);
+ $myparcel_delivery = $api->getDeliveryOptions($delivery_params);
+
+ if(isset($myparcel_delivery['code']) && $myparcel_delivery['code'] == 200 && !isset($myparcel_delivery['body']['errors'])){
+ $myparcel_delivery = MyParcel()->helper->formatDeliveryPrice($myparcel_delivery, $shipping_address ,$this->cart->getSubTotal(),$this->language,$current_currency_code);
+
+
+ $shipping_method_code = null;
+ $myparcel_option_title = [];
+ if (isset($this->session->data['shipping_method']['code'])){
+ $shipping_method_code = $this->session->data['shipping_method']['code'];
+ $shipping_method_code = explode('.',$shipping_method_code)[0];
+ }
+ $this->data['myparcel_option_title'] = array();
+ foreach ($myparcel_delivery['body']['data'] as $key => $value){
+ if(count($value)) {
+ $sort_order = count($quote_data);
+ $key_delivery = 'myparcel_' . $key;
+ $cost = 0;
+ $cost_with_tax = 0;
+ $price_key = 'myparcel_price_' . $key;
+ if (isset($this->session->data[$price_key])) {
+ $myparcel_price = $this->session->data[$price_key];
+ $text_price_detail = explode(' - ',$myparcel_price['text_myparcel_price_'.$key]);
+ //recalculate price choose
+ switch ($myparcel_price['shipping_method_code']){
+ case 'delivery':
+ foreach ($value as $k => $v){
+ if(date('Y-m-d',strtotime($v['date'])) == date('Y-m-d',strtotime($text_price_detail[0]))){
+ foreach ($v['time'] as $time){
+ if(date('H:i',strtotime($time['start'])) == date('H:i',strtotime($text_price_detail[1])) && date('H:i',strtotime($time['end'])) == date('H:i',strtotime($text_price_detail[2]))){
+ $myparcel_price['amount'] = $time['price']['amount'];
+ $myparcel_price['amount_with_tax'] = $time['price']['amount_with_tax'];
+ break;
+ }
+ }
+ }
+ }
+ break;
+ case 'pickup':
+ foreach ($value as $k => $v){
+ if($v['location'] == trim($text_price_detail[0])){
+ foreach ($v['time'] as $time){
+ if(date('H:i',strtotime($time['start'])) == date('H:i',strtotime($text_price_detail[2])) ){
+ $myparcel_price['amount'] = $time['price']['amount'];
+ $myparcel_price['amount_with_tax'] = $time['price']['amount_with_tax'];
+ break;
+ }
+ }
+ }
+ }
+ break;
+ } // end recalculate price choose
+
+ if ($myparcel_price['shipping_method_code'] == $key) {
+ $cost = $currency->convert($myparcel_price['amount'], $myparcel_price['currency'], $current_currency_code);
+ $cost_with_tax = $currency->convert($myparcel_price['amount_with_tax'], $myparcel_price['currency'], $current_currency_code);
+ };
+ if ($shipping_address['iso_code_2'] == 'NL' && isset($this->session->data['additional_service_checked'][$key])) {
+ if (isset($this->session->data['additional_service'])) {
+ $additional_service = $this->session->data['additional_service'];
+
+ $delivery_prices = $checkout_helper->getDeliveryPrices(false, true, '', false, 0,$this->cart->getSubTotal());
+ $delivery_prices_format = $checkout_helper->getDeliveryPrices(false, true, '', true, 0,$this->cart->getSubTotal());
+ foreach ($additional_service as $service_name => $service_value) {
+ if(isset($delivery_prices[$shipping_address['iso_code_2']][$service_name]) && $delivery_prices[$shipping_address['iso_code_2']][$service_name] !== 'disable'){
+ $additional_service[$service_name]['amount'] = round($currency->convert($delivery_prices[$shipping_address['iso_code_2']][$service_name],'EUR',$current_currency_code),2);
+ $additional_service[$service_name]['amount_with_tax'] = round($currency->convert($delivery_prices_format[$shipping_address['iso_code_2']][$service_name],'EUR',$current_currency_code),2);
+ $additional_service[$service_name]['text_amount'] = $currency->format($delivery_prices_format[$shipping_address['iso_code_2']][$service_name],$current_currency_code);
+ }
+ }
+ $additional_service_checked = $this->session->data['additional_service_checked'][$key];
+ foreach ($additional_service_checked as $service_name => $service_value) {
+ if ($service_value) {
+ $cost += $additional_service[$service_name]['amount'];
+ $cost_with_tax += $additional_service[$service_name]['amount_with_tax'];
+ }
+ }
+ }
+ }
+ }
+ else{
+ //delivery default select standard for delivery or first location for pickup if not selected
+ switch ($key){
+ case 'delivery':
+ foreach ($value as $k => $v){
+ foreach ($v['time'] as $k => $time){
+ if($time['price_comment'] == 'standard'){
+ $cost = $time['price']['amount'];
+ $cost_with_tax = $time['price']['amount_with_tax'];
+ break;
+ }
+ }
+ }
+ break;
+ case 'pickup':
+ $pickup = $value[0];
+ $time = $pickup['time'][0];
+ $cost = $time['price']['amount'];
+ $cost_with_tax = $time['price']['amount_with_tax'];
+ break;
+ }
+
+ }
+
+ $arrQuote = array(
+ 'code' => $key_delivery . '.' . $key_delivery,
+ 'title' => $this->language->get('entry_myparcel_' . $key),
+ 'cost' => $cost,
+ 'tax_class_id' => $checkout_helper->getTaxFromCart(),
+ 'text' => ($cost_with_tax == 0 && $default_price_0_text != '') ? $default_price_0_text :$currency->format($cost_with_tax, $current_currency_code),
+ );
+ $arrShipping = array(
+ 'title' => $this->language->get('entry_myparcel_' . $key),
+ 'sort_order' => $sort_order,
+ 'error' => ''
+ );
+ if ($shipping_method_code == $key_delivery) {
+ $arrQuote['headingtitle'] = $this->language->get('entry_select_myparcel_' . $key);
+ }
+ $myparcel_option_title['title_heading_myparcel_' . $key] = $this->language->get('entry_select_myparcel_' . $key);
+ $myparcel_option_title['text_edit_myparcel_' . $key] = (isset($myparcel_price['text_myparcel_price_'.$key])) ? $myparcel_price['text_myparcel_price_'.$key] : $this->language->get('entry_edit_myparcel_' . $key);
+ $arrShipping['quote'][$key_delivery] = $arrQuote;
+ $quote_data[$key_delivery] = $arrShipping;
+ }
+ }
+ $this->session->data['myparcel_option_title'] = $myparcel_option_title;
+ $this->session->data['myparcel_delivery'] = $myparcel_delivery['body']['data'];
+ if(isset($this->session->data['myparcel_api_errors'])){
+ unset($this->session->data['myparcel_api_errors']);
+ }
+ }
+ else{
+ $myparcel_errors = $myparcel_delivery['body']['errors'];
+ $error_message = [];
+ foreach($myparcel_errors as $error){
+ $error_message[] = $error['message'];
+ }
+ $this->session->data['myparcel_api_errors'] = htmlspecialchars(implode('.',$error_message), ENT_QUOTES);
+ }}
+ else{
+ if(isset($this->session->data['myparcel_api_errors'])){
+ unset($this->session->data['myparcel_api_errors']);
+ }
+ }
+ }
+ else{
+ if(isset($this->session->data['myparcel_api_errors'])){
+ unset($this->session->data['myparcel_api_errors']);
+ }
+ }
+ ]]>
+
+
+ template = $this->config->get('xtensions_view_path').'xshipping_method';]]>
+ registry);
+ }
+ if(isset($this->session->data['myparcel_api_errors'])){
+ $this->data['myparcel_api_errors'] = $this->session->data['myparcel_api_errors'];
+ }
+ if(isset($this->session->data['myparcel_option_title'])){
+ $this->data['myparcel_option_title'] = $this->session->data['myparcel_option_title'];
+ }
+ ($_SERVER['HTTPS'] && defined(HTTPS_SERVER)) ? $url_server = HTTPS_SERVER : $url_server = HTTP_SERVER;
+ $this->data['myparcel_action'] = $url_server . 'index.php?route=' . MyParcel()->getMyparcelXtensionControllerPath();
+ ]]>
+
+
+
+
+
+
+ '+json['error']['date']+'× ');
+ }
+ if(json['error']['timeslot']){
+ loadSlots();
+ $('#xdeltimeslots').before(''+json['error']['timeslot']+'×
');
+ }
+ }else if(json['success']){
+ $('.myparcel-pickup-table').html(json['html']);
+ loadShippingMethods(true);
+ }
+ hideLoader();
+ }
+ });
+ });
+ function changeAdditionalService(obj,name) {
+ var element = obj;
+ var id = obj.id.toString();
+ console.log(id);
+ $.ajax({
+ url: 'index.php?route='+$(obj).attr('action')+'/save',
+ type: 'post',
+ data: {
+ 'addition_name' : name,
+ 'addition_value': obj.checked
+ },
+ dataType: 'json',
+ beforeSend: function() {
+ $('.xdeldateandtimeslots .alert').remove();
+ $('.xdelslotselected').removeClass('xdelslotselected');
+ $(element).closest('tr').addClass('xdelslotselected');
+ },
+ success: function(json) {
+ if(json['error']){
+ if(json['error']['date']){
+ $('#xdeltimeslots').before(''+json['error']['date']+'×
');
+ }
+ if(json['error']['timeslot']){
+ loadSlots();
+ $('#xdeltimeslots').before(''+json['error']['timeslot']+'×
');
+ }
+ }else if(json['success']){
+ loadShippingMethods(true);
+ }
+
+ }
+ });
+ };
+ function loadMyparcelDelivery(action,headingtitle){
+ $('#modal-shipping-dependancy').remove();
+ $('.bootstrap-datetimepicker-widget').remove();
+ $.ajax({
+ url: action,
+ type: 'post',
+ data: $('#shipping_method input[type=\'radio\']:checked'),
+ dataType: 'html',
+ beforeSend: function() {
+
+ },
+ success: function(data) {
+ html = '';
+ html += '
';
+ html += '
';
+ html += ' ';
+ html += '
'+ data +'
';
+ html += '
';
+ html += '
';
+ $('body').append(html);
+ $('#modal-shipping-dependancy').modal('show');
+ }
+ });
+ }
+ ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -1){
+ clickEl = $(elementAddress[i]);
+ }
+ }
+ clickEl.click();
+ }
+ ]]>
+
+
+
+ -1){
+ clickEl = $(elementAddress[i]);
+ }
+ }
+ clickEl.click();
+ }
+ ]]>
+
+
+
+ -1){
+ clickEl = $(elementAddress[i]);
+ }
+ }
+ clickEl.click();
+ }
+ else{
+ toggleElement('#guestPanel, #guest_payment_panel');
+ $('.col-md-3.lborder').addClass('xblur');
+ }
+ }
+ ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(document).ready(function() {
+ {% if myparcel_api_errors %}
+ var eleError = $('#myparcel_api_errors');
+ if(eleError.length == 0){
+ $('body').append(' ');
+ }
+ {% else %}
+ var eleError = $('#myparcel_api_errors');
+ if(eleError.length){
+ $(eleError).remove();
+ }
+ {% endif %}
+
+ var elms = $("input[id^='myparcel_']");
+ var myparcel_action = '{{ myparcel_action }}';
+ for(var i=0; i < elms.length; i++){
+ var id = elms[i].id;
+ if(id != 'myparcel_shipping.myparcel_shipping' && id != 'myparcel_api_errors'){
+ id = id.split('.');
+ var title = $('#title_heading_' + id[0]).val();
+ var textEdit = $('#text_edit_' + id[0]).val();
+ $(elms[i]).attr('onClick',"loadMyparcelDelivery('"+ myparcel_action +"','"+ title + "' )");
+ $(elms[i]).parent().parent().parent().addClass('myparcel');
+ var divEle = ''+ textEdit +'
';
+ $(elms[i]).parent().append(divEle);
+ }
+ }
+ });
+
+ {% if myparcel_option_title %}
+ {% for key , value in myparcel_option_title %}
+
+ {% endfor %}
+ {% endif %}
+ ]]>
+
+
+
+
+
+
+ $(document).ready(function () {
+ {% if myparcel_api_errors %}
+ var eleError = $('#myparcel_api_errors');
+ if(eleError.length == 0){
+ $('body').append(' ');
+ }
+ {% else %}
+ var eleError = $('#myparcel_api_errors');
+ if(eleError.length){
+ $(eleError).remove();
+ }
+ {% endif %}
+ });
+
+ ]]>
+
+
+
+
+ session->data['shipping_method']);]]>
+ session->data['myparcel_shipping_choosed'])){
+ if (!class_exists('MyParcel')) {
+ require_once DIR_SYSTEM . 'library/myparcelnl/class_myparcel.php';
+ MyParcel($this->registry);
+ }
+ $registry = MyParcel::$registry;
+ $loader = $registry->get('load');
+ $loader->model(MyParcel()->getModelPath('shipment'));
+ $model_shipment = $registry->get('model_extension_myparcelnl_shipment');
+ $myparcel_shipping_choosed = $this->session->data['myparcel_shipping_choosed'];
+ $additional_service = $myparcel_shipping_choosed['additional_service'];
+ $myparcel_shipping_code = $myparcel_shipping_choosed['code'];
+ unset($myparcel_shipping_choosed['code']);
+ unset($myparcel_shipping_choosed['additional_service']);
+ $signed = (isset($additional_service['signed']) && $additional_service['signed'] ) ? 1: 0;
+ $recipient_only = (isset($additional_service['only_recipient']) && $additional_service['only_recipient'] ) ? 1: 0;
+ $current_prices = null;
+ if(isset($this->session->data['additional_service'])){
+ $current_prices = array(
+ 'NL' => $this->session->data['additional_service']
+ );
+ }
+ $model_shipment->saveDeliveryOptions($this->session->data['order_id'], $myparcel_shipping_choosed, $signed, $recipient_only, $current_prices);
+ $model_shipment->update($this->session->data['order_id'],'type',$myparcel_shipping_code . '.' . $myparcel_shipping_code);
+ if(isset($this->session->data['myparcel_shipping_choosed'])){
+ unset($this->session->data['myparcel_shipping_choosed']);
+ }
+ if(isset($this->session->data['additional_service'])){
+ unset($this->session->data['additional_service']);
+ }
+ if(isset($this->session->data['pickup_time_start'])){
+ unset($this->session->data['pickup_time_start']);
+ }
+ if(isset($this->session->data['additional_service_checked'])){
+ unset($this->session->data['additional_service_checked']);
+ }
+ if(isset($this->session->data['pickup_time_start'])){
+ unset($this->session->data['pickup_time_start']);
+ }
+ if(isset($this->session->data['myparcel_price_pickup'])){
+ unset($this->session->data['myparcel_price_pickup']);
+ }
+ if(isset($this->session->data['myparcel_price_delivery'])){
+ unset($this->session->data['myparcel_price_delivery']);
+ }
+ if(isset($this->session->data['delivery_time_start'])){
+ unset($this->session->data['delivery_time_start']);
+ }
+ if(isset($this->session->data['delivery_time_end'])){
+ unset($this->session->data['delivery_time_end']);
+ }
+ if(isset($this->session->data['delivery_date'])){
+ unset($this->session->data['delivery_date']);
+ }
+ if(isset($this->session->data['pickup_location'])){
+ unset($this->session->data['pickup_location']);
+ }
+
+ }
+ ]]>
+
+
+
+
+
@@ -769,7 +1453,45 @@
-
+
+
+
+
+
+ session->data['shipping_method'] = $this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]];]]>
+ session->data['shipping_method'];
+ if(isset($shipping_method['main_title'])){
+ $shipping_method['title'] = $shipping_method['main_title'];
+ $this->session->data['shipping_method'] = $shipping_method;
+ }
+ ]]>
+
+
+ model_checkout_order->editOrder($order_id, $order_data);]]>
+ session->data['myparcel_delivery_option']) ){
+ $myparcel_delivery_option = $this->session->data['myparcel_delivery_option'];
+ if (!class_exists('MyParcel')) {
+ require_once DIR_SYSTEM . 'library/myparcelnl/class_myparcel.php';
+ MyParcel($this->registry);
+ }
+ $registry = MyParcel::$registry;
+ $loader = $registry->get('load');
+ $loader->model(MyParcel()->getModelPath('shipment'));
+ $model_shipment = $registry->get('model_extension_myparcelnl_shipment');
+ if($order_data['shipping_code'] == $myparcel_delivery_option){
+ $model_shipment->update($order_id,'delivery_options',$myparcel_delivery_option);
+ }
+ $model_shipment->update($order_id,'type',$myparcel_delivery_option['shipping_code']);
+
+ }
+ ]]>
+
+
+
+
@@ -793,6 +1515,76 @@
}
]]>
+
+ model_setting_extension->getExtensions('shipping');]]>
+ load->model('checkout/order');
+ $order_data = $this->model_checkout_order->getOrder($this->request->get['order_id']);
+ $myparcel_key = null;
+ if($this->request->get['order_id']){
+ if (!class_exists('MyParcel')) {
+ require_once DIR_SYSTEM . 'library/myparcelnl/class_myparcel.php';
+ MyParcel($this->registry);
+ }
+
+ $api = MyParcel()->api;
+ $registry = MyParcel::$registry;
+ /** @var \Cart\Currency $currency **/
+ $currency = $registry->get('currency');
+ $current_currency_code = $this->session->data['currency'];
+ $shipping_address = $this->session->data['shipping_address'];
+ $delivery_params = MyParcel()->helper->getDeliveryParams($shipping_address);
+ $delivery_params = MyParcel()->helper->formatDeliveryParamsEditOrder($delivery_params, $this->request->get['order_id']);
+ $myparcel_delivery = $api->getDeliveryOptions($delivery_params);
+ if(isset($myparcel_delivery['code']) && $myparcel_delivery['code'] == 200 && !isset($myparcel_delivery['body']['errors'])){
+ $next_delivery_option = MyParcel()->helper->getDeliveryOptionChange($myparcel_delivery['body']['data'],$order_data);
+ if(!empty($next_delivery_option) && $next_delivery_option['shipping_code'] != null){
+ $shipping_code = $next_delivery_option['shipping_code'];
+ $myparcel_key = 'myparcel_'. $next_delivery_option['shipping_code'];
+ $next_delivery_option['shipping_code'] = $myparcel_key . '.' . $myparcel_key;
+ $this->session->data['myparcel_delivery_option'] = $next_delivery_option;
+ $myparcel_quote = array(
+ 'title' => 'MyParcel ' . ucfirst($shipping_code),
+ 'sort_order' => 1,
+ 'error' => ''
+ );
+ $time_delivery = $next_delivery_option['time'];
+ if(count($time_delivery) == 1){
+ $time_delivery = array_shift($next_delivery_option['time']);
+ }
+ $title = 'MyParcel ' . ucfirst($shipping_code). ' ' . date('Y-m-d',strtotime($next_delivery_option['date']));
+ if(!isset($time_delivery['price'])){
+ $time_delivery = $time_delivery[0];
+ }
+ switch ($shipping_code){
+ case "delivery":
+ $title .= ' ( ' .ucfirst($time_delivery['price_comment']) . ' )';
+ break;
+ case "pickup":
+ $title .= ' ( ' . $next_delivery_option['location'] . ')';
+ break;
+ }
+ $myparcel_quote['quote'][$myparcel_key] = array(
+ 'code' => $myparcel_key . '.' . $myparcel_key,
+ 'title' => $title,
+ 'cost' => $time_delivery['price']['amount'],
+ 'tax_class_id' => '',
+ 'text' => isset($time_delivery['price']['text_amount']) ? $time_delivery['price']['text_amount'] : $currency->format($currency->convert($time_delivery['price']['amount'], $time_delivery['price']['currency'], $current_currency_code), $current_currency_code),
+ 'main_title' => $myparcel_quote['title']
+ );
+ }
+ }
+ }
+ ]]>
+
+
+
+
+
@@ -814,6 +1606,78 @@
/* MyParcel Ocmod End */
]]>
+
+
+ request->get['order_id'])) {
+ $this->session->data['myparcel_order_id'] = $this->request->get['order_id'];
+ }
+ ]]>
+
+
+ model_setting_extension->getExtensions('shipping');]]>
+ load->model('checkout/order');
+ $order_data = $this->model_checkout_order->getOrder($this->request->get['order_id']);
+ if (!class_exists('MyParcel')) {
+ require_once DIR_SYSTEM . 'library/myparcelnl/class_myparcel.php';
+ MyParcel($this->registry);
+ }
+ $myparcel_key = null;
+ $api = MyParcel()->api;
+ $shipping_address = $this->session->data['shipping_address'];
+ $delivery_params = MyParcel()->helper->getDeliveryParams($shipping_address);
+ $delivery_params = MyParcel()->helper->formatDeliveryParamsEditOrder($delivery_params, $this->request->get['order_id']);
+ $myparcel_delivery = $api->getDeliveryOptions($delivery_params);
+ if(isset($myparcel_delivery['code']) && $myparcel_delivery['code'] == 200 && !isset($myparcel_delivery['body']['errors'])){
+ $next_delivery_option = MyParcel()->helper->getDeliveryOptionChange($myparcel_delivery['body']['data'],$order_data);
+ if(!empty($next_delivery_option) && $next_delivery_option['shipping_code'] != null){
+ $myparcel_key = 'myparcel_'. $next_delivery_option['shipping_code'];
+ $myparcel_quote = array(
+ 'title' => 'MyParcel ' . ucfirst($next_delivery_option['shipping_code']),
+ 'sort_order' => 1,
+ 'error' => ''
+ );
+ $time_delivery = $next_delivery_option['time'];
+ if(count($time_delivery) == 1){
+ $time_delivery = array_shift($next_delivery_option['time']);
+ }
+ $title = 'MyParcel ' . ucfirst($next_delivery_option['shipping_code']). ' ' . date('Y-m-d',strtotime($next_delivery_option['date']));
+
+ switch ($next_delivery_option['shipping_code']){
+ case "delivery":
+ $title .= ' ( ' .ucfirst($time_delivery['price_comment']) . ' )';
+ break;
+ case "pickup":
+ $title .= ' ( ' . $next_delivery_option['location'] . ')';
+ break;
+ }
+
+ if(!isset($time_delivery['price'])){
+ $time_delivery = $time_delivery[0];
+ }
+ $myparcel_quote['quote'][$myparcel_key] = array(
+ 'code' => $myparcel_key . '.' . $myparcel_key,
+ 'title' => $title,
+ 'cost' => $time_delivery['price']['amount'],
+ 'tax_class_id' => '',
+ 'text' => $time_delivery['price']['text_amount'],
+ 'main_title' => $myparcel_quote['title']
+ );
+ $next_delivery_option['shipping_code'] = $myparcel_key . '.' . $myparcel_key;
+ $this->session->data['myparcel_delivery_option'] = $next_delivery_option;
+ }
+ }
+ ]]>
+
+
+
+
+