Skip to content

Commit

Permalink
fix: international shipments
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardPerdaan committed Feb 1, 2023
1 parent 0f2f12f commit dde4546
Show file tree
Hide file tree
Showing 22 changed files with 980 additions and 466 deletions.
67 changes: 63 additions & 4 deletions install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
-->
<modification>
<name>MyParcel NL</name>
<version>1.1.3</version>
<version>1.1.8</version>
<code>MyParcelNL</code>
<author>MyParcel NL</author>
<link>https://www.myparcel.nl/</link>
Expand Down Expand Up @@ -167,7 +167,9 @@
<add position="after"><![CDATA[
$this->load->model('extension/myparcelnl/helper');
$this->document->addStyle($this->model_extension_myparcelnl_helper->getCssUrl() . 'order.css');
$this->document->addStyle($this->model_extension_myparcelnl_helper->getCssUrl() . 'sweetalert.min.css');
$this->document->addScript($this->model_extension_myparcelnl_helper->getJsUrl() . 'order.js');
$this->document->addScript($this->model_extension_myparcelnl_helper->getJsUrl() . 'sweetalert.min.js');
]]></add>
</operation>

Expand All @@ -178,7 +180,9 @@
<add position="after"><![CDATA[
$this->load->model('extension/myparcelnl/helper');
$this->document->addStyle($this->model_extension_myparcelnl_helper->getCssUrl() . 'order.css');
$this->document->addStyle($this->model_extension_myparcelnl_helper->getCssUrl() . 'sweetalert.min.css');
$this->document->addScript($this->model_extension_myparcelnl_helper->getJsUrl() . 'order.js');
$this->document->addScript($this->model_extension_myparcelnl_helper->getJsUrl() . 'sweetalert.min.js');
$data['use_addition_address'] = Myparcel($this->registry)->settings->general->use_addition_address_as_number_suffix;
]]></add>
</operation>
Expand Down Expand Up @@ -1231,10 +1235,10 @@
]]></add>
</operation>
</file>
<file path="catalog/controller/checkout/success.php">
<file path="catalog/controller/checkout/confirm.php">
<operation>
<search><![CDATA[unset($this->session->data['shipping_method']);]]></search>
<add position="before"><![CDATA[
<search><![CDATA[$this->session->data['order_id'] = $this->model_checkout_order->addOrder($order_data);]]></search>
<add position="after"><![CDATA[
if(isset($this->session->data['myparcel_shipping_choosed']) && isset($this->session->data['shipping_method']['code'])
&& ($this->session->data['shipping_method']['code'] == ($this->session->data['myparcel_shipping_choosed']['code'] . '.' . $this->session->data['myparcel_shipping_choosed']['code']))){
if (!class_exists('MyParcel')) {
Expand All @@ -1261,6 +1265,14 @@
$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);
}
]]></add>
</operation>
</file>
<file path="catalog/controller/checkout/success.php">
<operation>
<search><![CDATA[unset($this->session->data['shipping_method']);]]></search>
<add position="before"><![CDATA[
if(isset($this->session->data['myparcel_shipping_choosed'])){
unset($this->session->data['myparcel_shipping_choosed']);
}
Expand Down Expand Up @@ -1862,5 +1874,52 @@
]]></add>
</operation>
</file>
<file path="admin/view/template/catalog/product_form.twig">
<operation><!-- yes -->
<search><![CDATA[<li><a href="#tab-data" data-toggle="tab">{{ tab_data }}</a></li>]]></search>
<add position="after"><![CDATA[
<li><a href="#tab-myparcel" data-toggle="tab">My parcel</a></li>
]]></add>
</operation>
<operation>
<search><![CDATA[<div class="tab-pane" id="tab-links">]]></search>
<add position="before"><![CDATA[
{{ myparcel_product_fields }}
]]></add>
</operation>
</file>

<!-- ****** PRODUCT CONTROLLER ADMIN/CATALOG/PRODUCT.PHP ****** -->
<!-- *************************************************** -->

<file path="admin/controller/catalog/product.php"><!-- checked -->
<operation><!-- yes -->
<search><![CDATA[$this->response->setOutput($this->load->view('catalog/product_form', $data));]]></search>
<add position="before"><![CDATA[
$this->load->model('extension/myparcelnl/helper');
$product_id = (isset($this->request->get['product_id'])) ? $this->request->get['product_id'] : 0;
$data['myparcel_product_fields'] = $this->model_extension_myparcelnl_helper->getContent('edit_product_myparcel_fields', array('product_id' => $product_id));
]]></add>
</operation>
</file>

<!-- ****** PRODUCT MODEL ADMIN/MODEL/CATALOG/PRODUCT.PHP ****** -->
<!-- *************************************************** -->

<file path="admin/model/catalog/product.php"><!-- checked -->
<operation><!-- yes -->
<search><![CDATA[$this->db->query("DELETE FROM `" . DB_PREFIX . "product_recurring` WHERE product_id = " . (int)$product_id);]]></search>
<add position="before"><![CDATA[
if(isset($data['myparcel_hs_code']))
$this->db->query("UPDATE " . DB_PREFIX . "product SET myparcel_hs_code = '" . $this->db->escape($data['myparcel_hs_code']) . "', myparcel_country = '" . $this->db->escape($data['myparcel_country']) . "' WHERE product_id = '" . (int)$product_id . "'");
]]></add>
</operation>
<operation><!-- yes -->
<search><![CDATA[return $product_id;]]></search>
<add position="before"><![CDATA[
if(isset($data['myparcel_hs_code']))
$this->db->query("UPDATE " . DB_PREFIX . "product SET myparcel_hs_code = '" . $this->db->escape($data['myparcel_hs_code']) . "', myparcel_country = '" . $this->db->escape($data['myparcel_country']) . "' WHERE product_id = '" . (int)$product_id . "'");
]]></add>
</operation>
</file>
</modification>
Binary file removed upload/.DS_Store
Binary file not shown.
Binary file removed upload/admin/.DS_Store
Binary file not shown.
8 changes: 7 additions & 1 deletion upload/admin/language/en-gb/extension/module/myparcelnl.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
// Heading
$heading_title = 'Myparcel NL v1.1.3';
$heading_title = 'Myparcel NL v1.1.10';
$_['heading_title'] = $heading_title;
// Text
$_['text_module'] = 'Modules';
Expand Down Expand Up @@ -57,10 +57,13 @@
$_['entry_tab_1_log_api_communication'] = 'Log API communication';
$_['entry_tab_1_checkbox_log_api_communication'] = 'Only enable this option when debugging!';
$_['entry_tab_1_download_log_file'] = 'Download log file';
$_['entry_tab_1_title_paper_format'] = 'Paper format';


$_['entry_tab_2_title_export_settings'] = 'Default export settings';
$_['entry_tab_2_title_package_types'] = 'Package Types';
$_['entry_tab_2_title_default_hs_code'] = 'Default HS code';
$_['entry_tab_2_title_default_country_of_origin'] = 'The country of origin';
$_['entry_tab_2_select_package_types'] = 'Select one or more shipping methods for each MyParcel package type';
$_['entry_tab_2_title_connect_customer_email'] = 'Connect customer email';
$_['entry_tab_2_checkbox_connect_customer_email'] = 'When you connect the customer email, MyParcel can send a Track&Trace email to this address. In your %s you can enable or disable this email and format it in your own style.';
Expand Down Expand Up @@ -183,6 +186,9 @@
$_['Friday'] = 'Friday';
$_['Saturday'] = 'Saturday';

$_['label_hs_code'] = 'HS Code';
$_['label_country'] = 'Country Code';

$_['button_save'] = 'Save';
$_['button_send_to_customer'] = 'Send to customer';
$_['email_track_trace'] = 'You can track your order with the following PostNL track&trace code:';
Expand Down
8 changes: 7 additions & 1 deletion upload/admin/language/nl-nl/extension/module/myparcelnl.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
// Heading
$heading_title = 'Myparcel NL v1.1.3';
$heading_title = 'Myparcel NL v1.1.10';
$_['heading_title'] = $heading_title;
// Text
$_['text_module'] = 'Modules';
Expand Down Expand Up @@ -57,10 +57,13 @@
$_['entry_tab_1_log_api_communication'] = 'Log API communication';
$_['entry_tab_1_checkbox_log_api_communication'] = 'Only enable this option when debugging!';
$_['entry_tab_1_download_log_file'] = 'Download log file';
$_['entry_tab_1_title_paper_format'] = 'Paper format';


$_['entry_tab_2_title_export_settings'] = 'Default export settings';
$_['entry_tab_2_title_package_types'] = 'Package Types';
$_['entry_tab_2_title_default_hs_code'] = 'Default HS code';
$_['entry_tab_2_title_default_country_of_origin'] = 'The country of origin';
$_['entry_tab_2_select_package_types'] = 'Select one or more shipping methods for each MyParcel package type';
$_['entry_tab_2_title_connect_customer_email'] = 'Connect customer email';
$_['entry_tab_2_checkbox_connect_customer_email'] = 'When you connect the customer email, MyParcel can send a Track&Trace email to this address. In your %s you can enable or disable this email and format it in your own style.';
Expand Down Expand Up @@ -183,6 +186,9 @@
$_['Friday'] = 'Friday';
$_['Saturday'] = 'Saturday';

$_['label_hs_code'] = 'HS Code';
$_['label_country'] = 'Country Code';

$_['button_save'] = 'Save';
$_['button_send_to_customer'] = 'Send to customer';
$_['email_track_trace'] = 'You can track your order with the following PostNL track&trace code:';
Expand Down
5 changes: 5 additions & 0 deletions upload/admin/model/extension/myparcelnl/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ function getJsUrl()
{
return MyParcel($this->registry)->getJsUrl();
}

function addDeliveryDataIntoOrder($order_info)
{
return MyParcel($this->registry)->shipment->checkout->addDeliveryDataIntoOrder($order_info);
}
}
12 changes: 12 additions & 0 deletions upload/admin/model/extension/myparcelnl/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ function installDatabase()
if(count($query->row) == 0 ){
$this->db->query("ALTER TABLE `" .DB_PREFIX. "myparcel_shipment` ADD COLUMN `type` VARCHAR(50) NULL DEFAULT NULL;");
}

//add custom field myparcel_hs_code
$query = $this->db->query("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = '". DB_PREFIX ."product' AND table_schema = '". DB_DATABASE ."' AND column_name = 'myparcel_hs_code'");
if(count($query->row) == 0 ){
$this->db->query("ALTER TABLE `" .DB_PREFIX. "product` ADD COLUMN `myparcel_hs_code` VARCHAR(50) NULL DEFAULT NULL;");
}

//add custom field myparcel_country
$query = $this->db->query("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = '". DB_PREFIX ."product' AND table_schema = '". DB_DATABASE ."' AND column_name = 'myparcel_country'");
if(count($query->row) == 0 ){
$this->db->query("ALTER TABLE `" .DB_PREFIX. "product` ADD COLUMN `myparcel_country` VARCHAR(50) NULL DEFAULT NULL;");
}
}

function installMyParcelTotal()
Expand Down
Loading

0 comments on commit dde4546

Please sign in to comment.