- Sidebar-Menü „Bestellungen" in „Versand" umbenannt (layout-sidenav), sonst nur Blade-Formatierung. - Entwicklungspläne in ISO-Datumsformat umbenannt (entwicklungsplan-aktualisiert-*). - dev/dhl-for-woocommerce/ (DHL-Plugin) + dev/partnercenter-api.zip + PastedGraphic hinzugefügt. - .claude/ bewusst NICHT eingecheckt (lokale Claude-Code-Konfiguration). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1311 lines
70 KiB
PHP
1311 lines
70 KiB
PHP
<?php
|
||
|
||
use PR\DHL\Utils\API_Utils;
|
||
|
||
if (! defined('ABSPATH')) {
|
||
exit; // Exit if accessed directly
|
||
}
|
||
|
||
/**
|
||
* DHL Shipping Method.
|
||
*
|
||
* @category Shipping Method
|
||
*
|
||
* @author Shadi Manna
|
||
*/
|
||
if (! class_exists('PR_DHL_WC_Method_Paket')) {
|
||
|
||
class PR_DHL_WC_Method_Paket extends WC_Shipping_Method
|
||
{
|
||
/**
|
||
* Init and hook in the integration.
|
||
*/
|
||
public function __construct($instance_id = 0)
|
||
{
|
||
$this->id = 'pr_dhl_paket';
|
||
$this->instance_id = absint($instance_id);
|
||
$this->method_title = esc_html__('DHL Paket', 'dhl-for-woocommerce');
|
||
|
||
/* translators: %s: link to request a quote for becoming a DHL business customer */
|
||
$this->method_description = sprintf(esc_html__('Below you will find all functions for controlling, preparing and processing your shipment with DHL Paket. Prerequisite is a valid DHL business customer contract. If you are not yet a DHL business customer, you can request a quote %1$shere%2$s.', 'dhl-for-woocommerce'), '<a href="https://www.dhl.de/en/geschaeftskunden/paket/kunde-werden/angebot-dhl-geschaeftskunden-online/onlinevertrag.html?source=woocommerce" target="_blank">', '</a>');
|
||
|
||
$this->init();
|
||
}
|
||
|
||
/**
|
||
* init function.
|
||
*/
|
||
public function init()
|
||
{
|
||
// Load the settings.
|
||
$this->init_form_fields();
|
||
$this->init_settings();
|
||
|
||
add_action('woocommerce_update_options_shipping_'.$this->id, [$this, 'process_admin_options']);
|
||
|
||
add_filter('woocommerce_settings_api_form_fields_'.$this->id, [$this, 'after_init_set_field_options']);
|
||
|
||
if (API_Utils::is_new_merchant()) {
|
||
new PR_DHL_WC_Wizard_Paket;
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Get message
|
||
*
|
||
* @return string Error
|
||
*/
|
||
private function get_message($message, $type = 'notice notice-error is-dismissible')
|
||
{
|
||
|
||
ob_start();
|
||
?>
|
||
<div class="<?php echo $type; ?>" >
|
||
<p><?php echo $message; ?></p>
|
||
</div>
|
||
<?php
|
||
return ob_get_clean();
|
||
}
|
||
|
||
public function excluded_order_statuses()
|
||
{
|
||
|
||
return [
|
||
'wc-failed',
|
||
'wc-refunded',
|
||
'wc-cancelled',
|
||
];
|
||
}
|
||
|
||
public function get_order_statuses()
|
||
{
|
||
|
||
$wc_order_statuses = wc_get_order_statuses();
|
||
|
||
foreach ($this->excluded_order_statuses() as $status) {
|
||
unset($wc_order_statuses[$status]);
|
||
}
|
||
|
||
return $wc_order_statuses;
|
||
}
|
||
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public function get_admin_options_html()
|
||
{
|
||
return '<div id="dhlpaket_shipping_method_settings"><div class="dhlpaket_tab_menu"></div><div class="dhlpaket_tab_content">'.parent::get_admin_options_html().'</div></div>';
|
||
}
|
||
|
||
/**
|
||
* Initialize integration settings form fields.
|
||
*
|
||
* @return void
|
||
*/
|
||
public function init_form_fields()
|
||
{
|
||
$wc_shipping_methods = WC()->shipping->get_shipping_methods();
|
||
$wc_shipping_titles = wp_list_pluck($wc_shipping_methods, 'method_title', 'id');
|
||
$order_status_options = [
|
||
'none' => esc_html__('None', 'dhl-for-woocommerce'),
|
||
];
|
||
|
||
$order_status_options = array_merge($order_status_options, $this->get_order_statuses());
|
||
|
||
$log_path = PR_DHL()->get_log_url();
|
||
|
||
$select_dhl_product = ['0' => esc_html__('- Select DHL Product -', 'dhl-for-woocommerce')];
|
||
|
||
$select_dhl_desc_default = [
|
||
'product_name' => esc_html__('Product Name', 'dhl-for-woocommerce'),
|
||
'product_cat' => esc_html__('Product Categories', 'dhl-for-woocommerce'),
|
||
'product_tag' => esc_html__('Product Tags', 'dhl-for-woocommerce'),
|
||
];
|
||
|
||
try {
|
||
$dhl_obj = PR_DHL()->get_dhl_factory();
|
||
$select_dhl_product_int = $dhl_obj->get_dhl_products_international();
|
||
$select_dhl_product_dom = $dhl_obj->get_dhl_products_domestic();
|
||
$select_dhl_visual_age = $dhl_obj->get_dhl_visual_age();
|
||
$myaccount_pwd_expiration = $dhl_obj->get_dhl_myaccount_pwd_expiration();
|
||
} catch (Exception $e) {
|
||
PR_DHL()->log_msg(esc_html__('DHL Products not displaying - ', 'dhl-for-woocommerce').esc_html($e->getMessage()));
|
||
}
|
||
|
||
$weight_units = get_option('woocommerce_weight_unit');
|
||
|
||
$portal_link_open = '<a href="'.esc_url(PR_DHL_PAKET_BUSSINESS_PORTAL_LOGIN).'" target="_blank">';
|
||
$portal_link_close = '</a>';
|
||
|
||
if ($myaccount_pwd_expiration == '7days') {
|
||
$password_expiration_message = '<p style="color: red;">'.sprintf(
|
||
/* translators: %1$s: opening anchor tag to the DHL business portal, %2$s: closing anchor tag. */
|
||
esc_html__('Your password will expire in less than 7 days, please go to your %1$sbusiness portal%2$s and reset your password then click the "Get Account Settings" button below.', 'dhl-for-woocommerce'),
|
||
$portal_link_open,
|
||
$portal_link_close
|
||
).'</p>';
|
||
} elseif ($myaccount_pwd_expiration == '30days') {
|
||
$password_expiration_message = '<p style="color: red;">'.sprintf(
|
||
/* translators: %1$s: opening anchor tag to the DHL business portal, %2$s: closing anchor tag. */
|
||
esc_html__('Your password will expire in less than 30 days, please go to your %1$sbusiness portal%2$s and reset your password then click the "Get Account Settings" button below.', 'dhl-for-woocommerce'),
|
||
$portal_link_open,
|
||
$portal_link_close
|
||
).'</p>';
|
||
} else {
|
||
$password_expiration_message = '';
|
||
}
|
||
|
||
$this->form_fields = [
|
||
'dhl_pickup_api_dist' => [
|
||
'title' => esc_html__('Account and API Settings', 'dhl-for-woocommerce'),
|
||
'type' => 'title',
|
||
'description' => esc_html__('Please configure your shipping parameters and your access towards the DHL Paket APIs by means of authentication.', 'dhl-for-woocommerce'),
|
||
],
|
||
'dhl_api_user' => [
|
||
'title' => esc_html__('Username', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
'description' => sprintf(
|
||
/* Translators: %s is the URL for the DHL business customer portal. */
|
||
esc_html__('Your username for the DHL business customer portal. Please note the lower case and test your access data in advance at %1$shere%2$s.', 'dhl-for-woocommerce'),
|
||
'<a href="'.esc_url(PR_DHL_PAKET_BUSSINESS_PORTAL).'" target="_blank">',
|
||
'</a>'
|
||
),
|
||
'desc_tip' => false,
|
||
'default' => '',
|
||
],
|
||
'dhl_api_pwd' => [
|
||
'title' => esc_html__('Password', 'dhl-for-woocommerce'),
|
||
'type' => 'password',
|
||
'description' => sprintf(
|
||
/* Translators: %s is the URL for the DHL business customer portal. */
|
||
esc_html__('Your password for the DHL business customer portal. Please note the new assignment of the password to 3 (Standard User) or 12 (System User) months and test your access data in advance at %1$shere%2$s.', 'dhl-for-woocommerce'),
|
||
'<a href="'.esc_url(PR_DHL_PAKET_BUSSINESS_PORTAL).'" target="_blank">', // Use esc_url() for security
|
||
'</a>'
|
||
).$password_expiration_message,
|
||
'desc_tip' => false,
|
||
'default' => '',
|
||
],
|
||
'dhl_my_account_button' => [
|
||
'title' => PR_DHL_BUTTON_MY_ACCOUNT,
|
||
'type' => 'button',
|
||
'custom_attributes' => [
|
||
'onclick' => "dhlMyAccount('#woocommerce_pr_dhl_paket_dhl_my_account_button');",
|
||
],
|
||
'description' => esc_html__('Press the button to read your DHL Business Account settings into the DHL for WooCommerce plugin.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => false,
|
||
],
|
||
'dhl_account_num' => [
|
||
'title' => esc_html__('Account Number (EKP)', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
'description' => esc_html__('Your DHL account number (10 digits - numerical), also called "EKP“. This will be provided by your local DHL sales organization.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'default' => '',
|
||
'placeholder' => '1234567890',
|
||
'custom_attributes' => ['maxlength' => '10'],
|
||
],
|
||
'dhl_sandbox' => [
|
||
'title' => esc_html__('Sandbox Mode', 'dhl-for-woocommerce'),
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Enable Sandbox Mode', 'dhl-for-woocommerce'),
|
||
'default' => 'no',
|
||
'description' => esc_html__('Please, tick here if you want to test the plug-in installation against the DHL Sandbox Environment. Labels generated via Sandbox cannot be used for shipping and you need to enter your client ID and client secret for the Sandbox environment instead of the ones for production!', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
],
|
||
'dhl_debug' => [
|
||
'title' => esc_html__('Debug Log', 'dhl-for-woocommerce'),
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Enable logging', 'dhl-for-woocommerce'),
|
||
'default' => 'no',
|
||
'description' => sprintf(
|
||
/* Translators: %s is the URL to the log file. */
|
||
esc_html__('A log file containing the communication to the DHL server will be maintained if this option is checked. This can be used in case of technical issues and can be found %1$shere%2$s.', 'dhl-for-woocommerce'),
|
||
'<a href="'.esc_url($log_path).'" target="_blank">',
|
||
'</a>'
|
||
),
|
||
],
|
||
'internetmarke_api_title' => [
|
||
'title' => esc_html__('Internetmarke account and API', 'dhl-for-woocommerce'),
|
||
'type' => 'title',
|
||
'description' => wp_kses(
|
||
__('Enter your Portokasse account credentials to enable Deutsche Post Internetmarke label generation. For development and testing, use a developer Portokasse — simulated payments are applied and generated stamps cannot be used for real postage. If you see authentication errors, confirm in your Portokasse account under My data → Business applications that the business application has been activated.', 'dhl-for-woocommerce'),
|
||
['rarr' => []]
|
||
),
|
||
],
|
||
'internetmarke_api_user' => [
|
||
'title' => esc_html__('Username', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
'description' => esc_html__('Your Portokasse account username.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'default' => '',
|
||
],
|
||
'internetmarke_api_password' => [
|
||
'title' => esc_html__('Portokasse password', 'dhl-for-woocommerce'),
|
||
'type' => 'password',
|
||
'description' => esc_html__('Your Portokasse account password.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'default' => '',
|
||
],
|
||
'internetmarke_portokasse_id' => [
|
||
'title' => esc_html__('Portokasse ID (optional)', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
'description' => esc_html__('Optional. The Portokasse account ID, used to cross-check the account profile after authentication. Not required for token retrieval.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'default' => '',
|
||
],
|
||
'internetmarke_test_connection_button' => [
|
||
'title' => esc_html__('Test account connection', 'dhl-for-woocommerce'),
|
||
'type' => 'button',
|
||
'custom_attributes' => [
|
||
'onclick' => "dhlInternetmarkeTestConnection('#woocommerce_pr_dhl_paket_internetmarke_test_connection_button');",
|
||
],
|
||
'description' => esc_html__('Saves the Internetmarke credentials above and tests the connection to Deutsche Post in one step.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => false,
|
||
],
|
||
'dhl_participation_title' => [
|
||
'title' => esc_html__('DHL Products and Participation Number', 'dhl-for-woocommerce'),
|
||
'type' => 'title',
|
||
'description' => esc_html__('For each DHL product that you would like to use, please enter your participation number here. The participation number consists of the last two characters of the respective accounting number, which you will find in your DHL contract data (for example, 01).', 'dhl-for-woocommerce'),
|
||
],
|
||
'dhl_my_account_button_prod' => [
|
||
'title' => PR_DHL_BUTTON_MY_ACCOUNT,
|
||
'type' => 'button',
|
||
'custom_attributes' => [
|
||
'onclick' => "dhlMyAccount('#woocommerce_pr_dhl_paket_dhl_my_account_button_prod');",
|
||
],
|
||
'description' => esc_html__('Press the button to read your DHL Business Account settings into the DHL for WooCommerce plugin.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => false,
|
||
],
|
||
];
|
||
|
||
// $booking_text_array = unserialize(get_option('booking_text_option'));
|
||
$booking_text_array = $dhl_obj->get_dhl_booking_text();
|
||
|
||
foreach ($select_dhl_product_dom as $key => $value) {
|
||
$description = '';
|
||
|
||
// Check if the product key exists in the booking_text array
|
||
if (isset($booking_text_array[$key])) {
|
||
$description = $booking_text_array[$key];
|
||
}
|
||
|
||
$this->form_fields += [
|
||
'dhl_participation_'.$key => [
|
||
'title' => $value,
|
||
'type' => 'text',
|
||
'placeholder' => '',
|
||
'custom_attributes' => ['maxlength' => '2'],
|
||
'description' => $description, // Set the description
|
||
],
|
||
];
|
||
}
|
||
|
||
foreach ($select_dhl_product_int as $key => $value) {
|
||
$description = '';
|
||
|
||
// Check if the product key exists in the booking_text array
|
||
if (isset($booking_text_array[$key])) {
|
||
$description = $booking_text_array[$key];
|
||
}
|
||
|
||
$this->form_fields += [
|
||
'dhl_participation_'.$key => [
|
||
'title' => $value,
|
||
'type' => 'text',
|
||
'placeholder' => '',
|
||
'custom_attributes' => ['maxlength' => '2'],
|
||
'description' => $description, // Set the description
|
||
],
|
||
];
|
||
}
|
||
|
||
$this->form_fields += [
|
||
'dhl_participation_return' => [
|
||
'title' => esc_html__('DHL Retoure', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
'placeholder' => '',
|
||
'custom_attributes' => ['maxlength' => '2'],
|
||
],
|
||
'dhl_general' => [
|
||
'title' => esc_html__('Shipping Label Settings', 'dhl-for-woocommerce'),
|
||
'type' => 'title',
|
||
/* translators: %1$s: link to upload logo; %2$s: closing tag for link */
|
||
'description' => sprintf(esc_html__('Would you like to customize the DHL shipment notification? You can now add your online shop’s name and logo and we will display it in the DHL shipment notification. To upload your logo please use the following %1$slink%2$s.', 'dhl-for-woocommerce'), '<a href="'.esc_attr(PR_DHL_PAKET_NOTIFICATION_EMAIL).'" target = "_blank">', '</a>'),
|
||
],
|
||
'dhl_default_product_dom' => [
|
||
'title' => esc_html__('Domestic Default Service', 'dhl-for-woocommerce'),
|
||
'type' => 'select',
|
||
'description' => esc_html__('Please select your default DHL Paket shipping service for domestic shippments that you want to offer to your customers (you can always change this within each individual order afterwards)', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'options' => $select_dhl_product_dom,
|
||
'class' => 'wc-enhanced-select',
|
||
],
|
||
'dhl_default_product_int' => [
|
||
'title' => esc_html__('International Default Service', 'dhl-for-woocommerce'),
|
||
'type' => 'select',
|
||
'description' => esc_html__('Please select your default DHL Paket shipping service for cross-border shippments that you want to offer to your customers (you can always change this within each individual order afterwards).', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'options' => $select_dhl_product_int,
|
||
'class' => 'wc-enhanced-select',
|
||
],
|
||
'dhl_email_notification' => [
|
||
'title' => esc_html__('Send Customer Email', 'dhl-for-woocommerce'),
|
||
'type' => 'select',
|
||
'description' => esc_html__('Please select whether to send the customer\'s email to DHL or not. "Customer Confirmation" displays a confirmation on the checkout page and "Confirmed via terms & condition" assumes confirmation via the website terms & conditions.', 'dhl-for-woocommerce'),
|
||
'options' => [
|
||
'no' => esc_html__('Do not send', 'dhl-for-woocommerce'),
|
||
'yes' => esc_html__('Customer confirmation', 'dhl-for-woocommerce'),
|
||
'sendviatc' => esc_html__('Confirmed via terms & condition', 'dhl-for-woocommerce'),
|
||
],
|
||
'default' => 'sendviatc',
|
||
'desc_tip' => true,
|
||
],
|
||
'dhl_phone_notification' => [
|
||
'title' => esc_html__('Send Customer Phone', 'dhl-for-woocommerce'),
|
||
'type' => 'select',
|
||
'description' => esc_html__('Please select whether to send the customer\'s phone to DHL or not. "Confirmed via terms & condition" assumes confirmation via the website terms & conditions.', 'dhl-for-woocommerce'),
|
||
'options' => [
|
||
'no' => esc_html__('Do not send', 'dhl-for-woocommerce'),
|
||
'sendviatc' => esc_html__('Confirmed via terms & condition', 'dhl-for-woocommerce'),
|
||
],
|
||
'default' => 'sendviatc',
|
||
'desc_tip' => true,
|
||
],
|
||
'dhl_default_age_visual' => [
|
||
'title' => esc_html__('Visual Age Check default', 'dhl-for-woocommerce'),
|
||
'type' => 'select',
|
||
'options' => $select_dhl_visual_age,
|
||
'description' => esc_html__('Please, tick here if you want the "Visual Age Check" option to be checked in the "Edit Order" before printing a label.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'class' => 'wc-enhanced-select',
|
||
],
|
||
'dhl_default_additional_insurance' => [
|
||
'title' => esc_html__('Additional Insurance default', 'dhl-for-woocommerce'),
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Checked', 'dhl-for-woocommerce'),
|
||
'default' => 'no',
|
||
'description' => esc_html__('Please, tick here if you want the "Additional Insurance" option to be checked in the "Edit Order" before printing a label.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
],
|
||
'dhl_default_no_neighbor' => [
|
||
'title' => esc_html__('No Neighbor Delivery default', 'dhl-for-woocommerce'),
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Checked', 'dhl-for-woocommerce'),
|
||
'default' => 'no',
|
||
'description' => esc_html__('Please, tick here if you want the "No Neighbor Delivery" option to be checked in the "Edit Order" before printing a label.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
],
|
||
'dhl_default_named_person' => [
|
||
'title' => esc_html__('Named Person Only default', 'dhl-for-woocommerce'),
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Checked', 'dhl-for-woocommerce'),
|
||
'default' => 'no',
|
||
'description' => esc_html__('Please, tick here if you want the "Named Person Only" option to be checked in the "Edit Order" before printing a label.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
],
|
||
'dhl_default_premium' => [
|
||
'title' => esc_html__('Premium default', 'dhl-for-woocommerce'),
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Checked', 'dhl-for-woocommerce'),
|
||
'default' => 'no',
|
||
'description' => esc_html__('Please, tick here if you want the "Premium" option to be checked in the "Edit Order" before printing a label.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
],
|
||
'dhl_default_bulky_goods' => [
|
||
'title' => esc_html__('Bulky Goods default', 'dhl-for-woocommerce'),
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Checked', 'dhl-for-woocommerce'),
|
||
'default' => 'no',
|
||
'description' => esc_html__('Please, tick here if you want the "Bulky Goods" option to be checked in the "Edit Order" before printing a label.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
],
|
||
'dhl_default_identcheck' => [
|
||
'title' => esc_html__('Ident Check default', 'dhl-for-woocommerce'),
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Checked', 'dhl-for-woocommerce'),
|
||
'default' => 'no',
|
||
'description' => esc_html__('Please, tick here if you want the "Ident Check" option to be checked in the "Edit Order" before printing a label.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
],
|
||
'dhl_default_signature_service' => [
|
||
'title' => esc_html__('Signed for by recipient default', 'dhl-for-woocommerce'),
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Checked', 'dhl-for-woocommerce'),
|
||
'default' => 'no',
|
||
'description' => esc_html__('Please, tick here if you want the "Signed for by recipient" option to be checked in the "Edit Order" before printing a label.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
],
|
||
'dhl_default_identcheck_age' => [
|
||
'title' => esc_html__('Ident Check Age default', 'dhl-for-woocommerce'),
|
||
'type' => 'select',
|
||
'label' => esc_html__('Checked', 'dhl-for-woocommerce'),
|
||
'default' => '',
|
||
'options' => $select_dhl_visual_age,
|
||
'description' => esc_html__('Please, tick here if you want the "Ident Check" option to be checked in the "Edit Order" before printing a label.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
],
|
||
'dhl_default_endorsement' => [
|
||
'title' => esc_html__('Endorsement type', 'dhl-for-woocommerce'),
|
||
'type' => 'select',
|
||
'default' => '',
|
||
'options' => [
|
||
'IMMEDIATE' => esc_html__('Sending back to sender', 'dhl-for-woocommerce'),
|
||
'ABANDONMENT' => esc_html__('Abandonment of parcel', 'dhl-for-woocommerce'),
|
||
],
|
||
'description' => esc_html__('Please, tick here if you want the "Endorsement value" to be selected in the "Edit Order" before printing a label.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
],
|
||
'dhl_default_is_codeable' => [
|
||
'title' => esc_html__('Print Only If Codeable default', 'dhl-for-woocommerce'),
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Checked', 'dhl-for-woocommerce'),
|
||
'default' => 'no',
|
||
'description' => esc_html__('Please, tick here if you want the "Print Only If Codeable" option to be checked in the "Edit Order" before printing a label.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
],
|
||
'dhl_default_routing' => [
|
||
'title' => esc_html__('Parcel Outlet Routing default', 'dhl-for-woocommerce'),
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Checked', 'dhl-for-woocommerce'),
|
||
'default' => 'no',
|
||
'description' => esc_html__('Please, tick here if you want the "Parcel Outlet Routing" option to be checked in the "Edit Order" before printing a label.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
],
|
||
'dhl_default_go_green_plus' => [
|
||
'title' => esc_html__('GoGreen Plus default', 'dhl-for-woocommerce'),
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Checked', 'dhl-for-woocommerce'),
|
||
'default' => 'no',
|
||
'description' => esc_html__('Check to request GoGreen Plus for every domestic shipment unless you turn it off per order.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
],
|
||
'dhl_add_weight_type' => [
|
||
'title' => esc_html__('Additional Weight Type', 'dhl-for-woocommerce'),
|
||
'type' => 'select',
|
||
'description' => esc_html__('Select whether to add an absolute weight amount or percentage amount to the total product weight.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'options' => [
|
||
'absolute' => 'Absolute',
|
||
'percentage' => 'Percentage',
|
||
],
|
||
'class' => 'wc-enhanced-select',
|
||
],
|
||
'dhl_add_weight' => [
|
||
'title' => sprintf(
|
||
/* Translators: %s represents the weight unit (e.g., kg, lbs, %). */
|
||
esc_html__('Additional Weight (%s or %%)', 'dhl-for-woocommerce'),
|
||
esc_html($weight_units) // Escaped for security
|
||
),
|
||
'type' => 'text',
|
||
'description' => esc_html__('Add extra weight in addition to the products. Either an absolute amount or percentage (e.g. 10 for 10%).', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'default' => '',
|
||
'placeholder' => '',
|
||
'class' => 'wc_input_decimal',
|
||
],
|
||
'dhl_desc_default' => [
|
||
'title' => esc_html__('Package Description', 'dhl-for-woocommerce'),
|
||
'type' => 'select',
|
||
'description' => esc_html__('Prefill the customs package description with one of the options for cross-border packages.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'default' => 'product_cat',
|
||
'options' => $select_dhl_desc_default,
|
||
'class' => 'wc-enhanced-select',
|
||
],
|
||
'dhl_label_format' => [
|
||
'title' => esc_html__('Label Format', 'dhl-for-woocommerce'),
|
||
'type' => 'select',
|
||
'description' => esc_html__('Select one of the formats to generate the shipping label in.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'options' => [
|
||
'A4' => 'A4',
|
||
'910-300-700' => 'Laser printer 105 x 205 mm',
|
||
'910-300-700-oZ' => 'Laser printer 105 x 205 mm (no info)',
|
||
'910-300-600' => 'Thermo printer 103 x 199 mm',
|
||
'910-300-610' => 'Thermo printer 103 x 202 mm',
|
||
'910-300-710' => 'Laser printer 105 x 208 mm',
|
||
'910-300-410' => 'Laser printer 103 x 150 mm',
|
||
'910-300-300' => 'Laser printer 105 x 148 mm',
|
||
'910-300-300-oZ' => 'Laser printer 105 x 148 mm (without additional labels)',
|
||
'100x70mm' => '100 x 70 mm (only for Kleinpaket)',
|
||
],
|
||
'default' => '910-300-700',
|
||
'class' => 'wc-enhanced-select',
|
||
],
|
||
'dhl_split_return_label' => [
|
||
'title' => esc_html__('Separate Return Label', 'dhl-for-woocommerce'),
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Save the return label as a separate PDF', 'dhl-for-woocommerce'),
|
||
'default' => 'no',
|
||
'description' => esc_html__('When enabled, the return label is saved as its own PDF file instead of being combined with the shipping label, so it can be downloaded on its own from the order.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
],
|
||
'dhl_email_return_label' => [
|
||
'title' => esc_html__('Email Return Label', 'dhl-for-woocommerce'),
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Attach the return label to a customer order email', 'dhl-for-woocommerce'),
|
||
'default' => 'no',
|
||
'description' => esc_html__('When enabled, the separate return label PDF is attached to the selected customer email once the label has been created. Requires the "Separate Return Label" option above.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
],
|
||
'dhl_email_return_label_email' => [
|
||
'title' => esc_html__('Attach Return Label To Email', 'dhl-for-woocommerce'),
|
||
'type' => 'select',
|
||
'description' => esc_html__('Choose which customer email the return label is attached to. The label must already exist when the email is sent. "Order note" is sent the moment the label is created, but only reaches the customer if the "Make Private" tracking-note setting is off; the order-status emails only carry the label if it was created before they were sent. The order note always carries the label once it exists, so any customer note you add afterwards will include it too.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'default' => 'customer_note',
|
||
'options' => [
|
||
'customer_note' => esc_html__('Order note (sent when the label is created, recommended)', 'dhl-for-woocommerce'),
|
||
'customer_completed_order' => esc_html__('Completed order', 'dhl-for-woocommerce'),
|
||
'customer_processing_order' => esc_html__('Processing order', 'dhl-for-woocommerce'),
|
||
'customer_invoice' => esc_html__('Order details / invoice', 'dhl-for-woocommerce'),
|
||
],
|
||
'class' => 'wc-enhanced-select',
|
||
],
|
||
'dhl_add_logo' => [
|
||
'title' => esc_html__('Logo', 'dhl-for-woocommerce'),
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Add Logo', 'dhl-for-woocommerce'),
|
||
'default' => 'no',
|
||
'description' => esc_html__('The logo will be added from your DHL dashboard settings.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
],
|
||
'dhl_shipper_reference' => [
|
||
'title' => sprintf(esc_html__('Shipper Reference', 'dhl-for-woocommerce'), esc_html($weight_units)),
|
||
'type' => 'text',
|
||
'description' => esc_html__('Add shipper reference.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => false,
|
||
'default' => '',
|
||
'placeholder' => '',
|
||
],
|
||
'dhl_tracking_note' => [
|
||
'title' => esc_html__('Tracking Note', 'dhl-for-woocommerce'),
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Make Private', 'dhl-for-woocommerce'),
|
||
'default' => 'no',
|
||
'description' => esc_html__('Please, tick here to not send an email to the customer when the tracking number is added to the order.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
],
|
||
'dhl_tracking_note_txt' => [
|
||
'title' => esc_html__('Tracking Text', 'dhl-for-woocommerce'),
|
||
'type' => 'textarea',
|
||
'description' => esc_html__('Set the custom text when adding the tracking number to the order notes or completed email. {tracking-link} is where the tracking number will be set.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => false,
|
||
'default' => esc_html__('DHL Tracking Number: {tracking-link}', 'dhl-for-woocommerce'),
|
||
],
|
||
'dhl_add_tracking_info_completed' => [
|
||
'title' => esc_html__('Tracking Email', 'dhl-for-woocommerce'),
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Add tracking text in completed email', 'dhl-for-woocommerce'),
|
||
'description' => esc_html__('Please, tick here to add tracking text when completed email is sent.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'default' => 'no',
|
||
'class' => '',
|
||
],
|
||
'dhl_tracking_url_language' => [
|
||
'title' => esc_html__('Tracking URL Language', 'dhl-for-woocommerce'),
|
||
'type' => 'select',
|
||
'label' => esc_html__('Select the tracking link language.', 'dhl-for-woocommerce'),
|
||
'description' => esc_html__('Select language of the tracking link page.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'options' => [
|
||
'de' => 'German',
|
||
'en' => 'English',
|
||
],
|
||
'class' => 'wc-enhanced-select',
|
||
'default' => 'de',
|
||
],
|
||
'dhl_create_label_on_status' => [
|
||
'title' => esc_html__('Create Label on Status', 'dhl-for-woocommerce'),
|
||
'type' => 'select',
|
||
'label' => esc_html__('Create label on specific status.', 'dhl-for-woocommerce'),
|
||
'description' => esc_html__('Select the order status.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'options' => $order_status_options,
|
||
'class' => 'wc-enhanced-select',
|
||
'default' => 'no',
|
||
],
|
||
'dhl_change_order_status_completed' => [
|
||
'title' => esc_html__('Order Status', 'dhl-for-woocommerce'),
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Change to Completed', 'dhl-for-woocommerce'),
|
||
'description' => esc_html__('Please, tick here to change the order status when label is generated.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'default' => 'no',
|
||
'class' => '',
|
||
],
|
||
];
|
||
|
||
$base_country_code = PR_DHL()->get_base_country();
|
||
// Preferred options for Germany only
|
||
// IF USING PREFERRED OPTIONS AND COD IS ENABLED DISPALY A WARNING MESSAGE OR DON'T ALLOW IT TO BE USED?
|
||
if ($base_country_code == 'DE') {
|
||
$this->form_fields += [
|
||
'dhl_preferred' => [
|
||
'title' => esc_html__('Preferred Service', 'dhl-for-woocommerce'),
|
||
'type' => 'title',
|
||
'description' => esc_html__('Preferred service options.', 'dhl-for-woocommerce'),
|
||
],
|
||
'dhl_closest_drop_point' => [
|
||
'title' => esc_html__('Closest Drop Point', 'dhl-for-woocommerce'),
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Enable Closest Drop Point', 'dhl-for-woocommerce'),
|
||
'description' => esc_html__('Enabling this will display a front-end option for the user to select delivery option (Home address or CDP delivery).', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
],
|
||
'dhl_preferred_day' => [
|
||
'title' => esc_html__('Delivery Day', 'dhl-for-woocommerce'),
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Enable Delivery Day', 'dhl-for-woocommerce'),
|
||
'description' => esc_html__('Enabling this will display a front-end option for the user to select their preferred day of delivery.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
],
|
||
'dhl_preferred_day_cost' => [
|
||
'title' => esc_html__('Delivery Day Price', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
'description' => esc_html__('Insert gross value as surcharge for the preferred day. Insert 0 to offer service for free.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'default' => '1.2',
|
||
'class' => 'wc_input_decimal', // adds JS to validate input is in price format
|
||
],
|
||
'dhl_preferred_day_cutoff' => [
|
||
'title' => esc_html__('Cut Off Time', 'dhl-for-woocommerce'),
|
||
'type' => 'time',
|
||
'description' => esc_html__('The cut-off time is the latest possible order time up to which the minimum preferred day (day of order + 2 working days) can be guaranteed. As soon as the time is exceeded, the earliest preferred day displayed in the frontend will be shifted to one day later (day of order + 3 working days).', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'default' => '12:00',
|
||
],
|
||
'dhl_preferred_exclusion_mon' => [
|
||
'title' => esc_html__('Exclusion of transfer days', 'dhl-for-woocommerce'),
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Monday', 'dhl-for-woocommerce'),
|
||
'description' => esc_html__('Exclude days to transfer packages to DHL.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
],
|
||
'dhl_preferred_exclusion_tue' => [
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Tuesday', 'dhl-for-woocommerce'),
|
||
],
|
||
'dhl_preferred_exclusion_wed' => [
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Wednesday', 'dhl-for-woocommerce'),
|
||
],
|
||
'dhl_preferred_exclusion_thu' => [
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Thursday', 'dhl-for-woocommerce'),
|
||
],
|
||
'dhl_preferred_exclusion_fri' => [
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Friday', 'dhl-for-woocommerce'),
|
||
],
|
||
'dhl_preferred_exclusion_sat' => [
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Saturday', 'dhl-for-woocommerce'),
|
||
],
|
||
'dhl_preferred_location' => [
|
||
'title' => esc_html__('Preferred Location', 'dhl-for-woocommerce'),
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Enable Preferred Location', 'dhl-for-woocommerce'),
|
||
'description' => esc_html__('Enabling this will display a front-end option for the user to select their preferred location.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
],
|
||
'dhl_preferred_neighbour' => [
|
||
'title' => esc_html__('Preferred Neighbour', 'dhl-for-woocommerce'),
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Enable Preferred Neighbour', 'dhl-for-woocommerce'),
|
||
'description' => esc_html__('Enabling this will display a front-end option for the user to select their preferred neighbour.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
],
|
||
'dhl_shipping_methods' => [
|
||
'title' => esc_html__('Shipping Methods', 'dhl-for-woocommerce'),
|
||
'type' => 'multiselect',
|
||
'description' => esc_html__('Select the Shipping Methods to display the enabled DHL Paket preferred services and Location Finder below. You can press "ctrl" to select multiple options or click on a selected option to deselect it.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'options' => $wc_shipping_titles,
|
||
'class' => 'wc-enhanced-select',
|
||
],
|
||
'dhl_payment_gateway' => [
|
||
'title' => esc_html__('Exclude Payment Gateways', 'dhl-for-woocommerce'),
|
||
'type' => 'multiselect',
|
||
'default' => 'cod',
|
||
'description' => esc_html__('Select the Payment Gateways to hide the enabled DHL Paket preferred services and Location Finder below. You can press "ctrl" to select multiple options or click on a selected option to deselect it.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'options' => [],
|
||
'class' => 'wc-enhanced-select',
|
||
],
|
||
'dhl_cod_payment_methods' => [
|
||
'title' => esc_html__('COD Payment Gateways', 'dhl-for-woocommerce'),
|
||
'type' => 'multiselect',
|
||
'default' => 'cod',
|
||
'description' => esc_html__('Select the Payment Gateways to use with DHL COD services. You can press "ctrl" to select multiple options or click on a selected option to deselect it.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'options' => [],
|
||
'class' => 'wc-enhanced-select',
|
||
],
|
||
'dhl_parcel_finder' => [
|
||
'title' => esc_html__('Location Finder', 'dhl-for-woocommerce'),
|
||
'type' => 'title',
|
||
'description' => esc_html__('Please define the parameters for the display of dhl locations in the shop frontend.', 'dhl-for-woocommerce'),
|
||
],
|
||
'dhl_display_packstation' => [
|
||
'title' => esc_html__('Packstation', 'dhl-for-woocommerce'),
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Enable Packstation', 'dhl-for-woocommerce'),
|
||
'description' => esc_html__('Enabling this will display Packstation locations on Google Maps when searching for drop off locations on the front-end.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
],
|
||
'dhl_display_parcelshop' => [
|
||
'title' => esc_html__('Parcelshop', 'dhl-for-woocommerce'),
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Enable Parcelshop', 'dhl-for-woocommerce'),
|
||
'description' => esc_html__('Enabling this will display Parcelshop locations on Google Maps when searching for drop off locations on the front-end.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
],
|
||
'dhl_display_post_office' => [
|
||
'title' => esc_html__('Post Office', 'dhl-for-woocommerce'),
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Enable Post Office', 'dhl-for-woocommerce'),
|
||
'description' => esc_html__('Enabling this will display Post Office locations on Google Maps when searching for drop off locations on the front-end.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
],
|
||
'dhl_display_google_maps' => [
|
||
'title' => __('Map', 'dhl-for-woocommerce'),
|
||
'type' => 'checkbox',
|
||
'label' => __('Enable Map', 'dhl-for-woocommerce'),
|
||
'description' => __('Enabling this will display the Map on the front-end.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
],
|
||
'dhl_map_type' => [
|
||
'title' => __('Map type', 'dhl-for-woocommerce'),
|
||
'type' => 'select',
|
||
'description' => __('Select the map type to show parcels shops.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'options' => ['gmaps' => 'Google Maps', 'osm' => 'Open Street Map'],
|
||
'class' => 'wc-enhanced-select',
|
||
'default' => 'gmaps',
|
||
],
|
||
'dhl_parcel_limit' => [
|
||
'title' => esc_html__('Limit Results', 'dhl-for-woocommerce'),
|
||
'type' => 'number',
|
||
'description' => esc_html__('Limit displayed results, from 1 to at most 50.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'class' => '',
|
||
'default' => '20',
|
||
'custom_attributes' => [
|
||
'min' => '1',
|
||
'max' => '50',
|
||
],
|
||
],
|
||
'dhl_google_maps_api_key' => [
|
||
'title' => esc_html__('API Key', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
/* Translators: %s represents a link to obtain a Google Maps API key. */
|
||
'description' => wp_kses(
|
||
sprintf(
|
||
esc_html__('The Google Maps API Key is necessary to display the DHL Locations on a Google map.%1$sGet a free Google Maps API key %2$shere%3$s.', 'dhl-for-woocommerce'),
|
||
'<br/>',
|
||
'<a href="'.esc_url('https://developers.google.com/maps/documentation/javascript/get-api-key').'" target="_blank">',
|
||
'</a>'
|
||
),
|
||
[
|
||
'br' => [],
|
||
'a' => [
|
||
'href' => [],
|
||
'target' => [],
|
||
],
|
||
]
|
||
),
|
||
'desc_tip' => false,
|
||
'class' => '',
|
||
],
|
||
];
|
||
}
|
||
|
||
$this->form_fields += [
|
||
'dhl_shipper' => [
|
||
'title' => esc_html__('Shipper Address / Pickup Request Address', 'dhl-for-woocommerce'),
|
||
'type' => 'title',
|
||
'description' => esc_html__('Enter Shipper Address. This address is also used for Pickup Requests.<br/>Note: For pickup requests to be accepted, this address must match a pickup address saved to your DHL Portal.', 'dhl-for-woocommerce'),
|
||
],
|
||
'dhl_shipper_name' => [
|
||
'title' => esc_html__('Name', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
'description' => esc_html__('Enter Shipper Name.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'default' => '',
|
||
],
|
||
'dhl_shipper_company' => [
|
||
'title' => esc_html__('Company', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
'description' => esc_html__('Enter Shipper Company.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'default' => '',
|
||
],
|
||
'dhl_shipper_address' => [
|
||
'title' => esc_html__('Street Address', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
'description' => esc_html__('Enter Shipper Street Address.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'default' => '',
|
||
],
|
||
'dhl_shipper_address_no' => [
|
||
'title' => esc_html__('Street Address Number', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
'description' => esc_html__('Enter Shipper Street Address Number.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'default' => '',
|
||
],
|
||
'dhl_shipper_address_city' => [
|
||
'title' => esc_html__('City', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
'description' => esc_html__('Enter Shipper City.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'default' => '',
|
||
],
|
||
'dhl_shipper_address_state' => [
|
||
'title' => esc_html__('State', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
'description' => esc_html__('Enter Shipper County.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'default' => '',
|
||
],
|
||
'dhl_shipper_address_zip' => [
|
||
'title' => esc_html__('Postcode', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
'description' => esc_html__('Enter Shipper Postcode.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'default' => '',
|
||
],
|
||
'dhl_shipper_phone' => [
|
||
'title' => esc_html__('Phone Number', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
'description' => esc_html__('Enter Phone Number.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'default' => '',
|
||
],
|
||
'dhl_shipper_email' => [
|
||
'title' => esc_html__('Email', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
'description' => esc_html__('Enter Email.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'default' => '',
|
||
],
|
||
'dhl_return' => [
|
||
'title' => esc_html__('Return Address', 'dhl-for-woocommerce'),
|
||
'type' => 'title',
|
||
'description' => esc_html__('Enter Return Address below.', 'dhl-for-woocommerce'),
|
||
],
|
||
'dhl_default_return_address_enabled' => [
|
||
'title' => esc_html__('Create Return Label default', 'dhl-for-woocommerce'),
|
||
'type' => 'checkbox',
|
||
'label' => esc_html__('Checked', 'dhl-for-woocommerce'),
|
||
'default' => 'no',
|
||
'description' => esc_html__('Please, tick here if you want the "Create Return Label" option to be checked in the "Edit Order" before printing a label.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
],
|
||
'dhl_return_name' => [
|
||
'title' => esc_html__('Name', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
'description' => esc_html__('Enter Return Name.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'default' => '',
|
||
],
|
||
'dhl_return_company' => [
|
||
'title' => esc_html__('Company', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
'description' => esc_html__('Enter Return Company.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'default' => '',
|
||
],
|
||
'dhl_return_address' => [
|
||
'title' => esc_html__('Street Address', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
'description' => esc_html__('Enter Return Street Address.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'default' => '',
|
||
],
|
||
'dhl_return_address_no' => [
|
||
'title' => esc_html__('Street Address Number', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
'description' => esc_html__('Enter Return Street Address Number.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'default' => '',
|
||
],
|
||
'dhl_return_address_city' => [
|
||
'title' => esc_html__('City', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
'description' => esc_html__('Enter Return City.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'default' => '',
|
||
],
|
||
'dhl_return_address_state' => [
|
||
'title' => esc_html__('State', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
'description' => esc_html__('Enter Return County.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'default' => '',
|
||
],
|
||
'dhl_return_address_zip' => [
|
||
'title' => esc_html__('Postcode', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
'description' => esc_html__('Enter Return Postcode.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'default' => '',
|
||
],
|
||
'dhl_return_phone' => [
|
||
'title' => esc_html__('Phone Number', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
'description' => esc_html__('Enter Phone Number.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'default' => '',
|
||
],
|
||
'dhl_return_email' => [
|
||
'title' => esc_html__('Email', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
'description' => esc_html__('Enter Email.', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
'default' => '',
|
||
],
|
||
'dhl_bank' => [
|
||
'title' => esc_html__('Bank Details', 'dhl-for-woocommerce'),
|
||
'type' => 'title',
|
||
'description' => esc_html__('Enter your bank details needed for services that use COD.', 'dhl-for-woocommerce'),
|
||
],
|
||
'dhl_bank_holder' => [
|
||
'title' => esc_html__('Account Owner', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
],
|
||
'dhl_bank_name' => [
|
||
'title' => esc_html__('Bank Name', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
],
|
||
'dhl_bank_iban' => [
|
||
'title' => esc_html__('IBAN', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
],
|
||
'dhl_bank_bic' => [
|
||
'title' => esc_html__('BIC', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
'default' => '',
|
||
],
|
||
'dhl_bank_ref' => [
|
||
'title' => esc_html__('Payment Reference', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
'custom_attributes' => ['maxlength' => '35'],
|
||
/* translators: %1$s: order ID placeholder, %2$s: customer email placeholder */
|
||
'description' => sprintf(esc_html__('Use "%1$s" to send the order id as a bank reference and "%2$s" to send the customer email. This text is limited to 35 characters.', 'dhl-for-woocommerce'), '{order_id}', '{email}'),
|
||
'desc_tip' => true,
|
||
'default' => '{order_id}',
|
||
],
|
||
'dhl_bank_ref_2' => [
|
||
'title' => esc_html__('Payment Reference 2', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
'custom_attributes' => ['maxlength' => '35'],
|
||
/* translators: %1$s: order ID placeholder, %2$s: customer email placeholder */
|
||
'description' => sprintf(esc_html__('Use "%1$s" to send the order id as a bank reference and "%2$s" to send the customer email. This text is limited to 35 characters.', 'dhl-for-woocommerce'), '{order_id}', '{email}'),
|
||
'desc_tip' => true,
|
||
'default' => '{email}',
|
||
],
|
||
/*
|
||
'dhl_cod_fee' => array(
|
||
'title' => esc_html__( 'Add COD Fee', 'dhl-for-woocommerce' ),
|
||
'type' => 'checkbox',
|
||
'description' => esc_html__( 'Add €2 fee for users using COD.', 'dhl-for-woocommerce' ),
|
||
'desc_tip' => true,
|
||
'default' => '',
|
||
'custom_attributes' => array( 'maxlength' => '35' )
|
||
),*/
|
||
];
|
||
|
||
// Business Hours for DHL Pickkup Request
|
||
$this->form_fields += [
|
||
'dhl_business_hours' => [
|
||
'title' => esc_html__('Business Hours (for DHL Pickup Request)', 'dhl-for-woocommerce'),
|
||
'type' => 'title',
|
||
'description' => esc_html__('The business hours available for DHL Pickup.', 'dhl-for-woocommerce'),
|
||
],
|
||
'dhl_business_hours_1_start' => [
|
||
'title' => esc_html__('From: ', 'dhl-for-woocommerce'),
|
||
'type' => 'time',
|
||
'default' => '08:00',
|
||
],
|
||
'dhl_business_hours_1_end' => [
|
||
'title' => esc_html__('To: ', 'dhl-for-woocommerce'),
|
||
'type' => 'time',
|
||
'default' => '17:00',
|
||
],
|
||
'dhl_business_hours_2_start' => [
|
||
'title' => esc_html__('(Additional Business Hours) From: ', 'dhl-for-woocommerce'),
|
||
'type' => 'time',
|
||
'description' => esc_html__('Optional, if additional business hours are needed.', 'dhl-for-woocommerce'),
|
||
'default' => '',
|
||
],
|
||
'dhl_business_hours_2_end' => [
|
||
'title' => esc_html__('(Additional Business Hours) To: ', 'dhl-for-woocommerce'),
|
||
'type' => 'time',
|
||
'description' => esc_html__('Optional, if additional business hours are needed.', 'dhl-for-woocommerce'),
|
||
'default' => '',
|
||
],
|
||
];
|
||
}
|
||
|
||
// Set specific field options after initialization
|
||
public function after_init_set_field_options($fields)
|
||
{
|
||
if (isset($fields['dhl_payment_gateway']) || isset($fields['dhl_cod_payment_methods'])) {
|
||
$payment_gateway_titles = [];
|
||
if (WC()->payment_gateways) {
|
||
$wc_payment_gateways = WC()->payment_gateways->payment_gateways();
|
||
foreach ($wc_payment_gateways as $gatekey => $gateway) {
|
||
$payment_gateway_titles[$gatekey] = $gateway->get_method_title();
|
||
}
|
||
if (isset($fields['dhl_payment_gateway'])) {
|
||
$fields['dhl_payment_gateway']['options'] = $payment_gateway_titles;
|
||
}
|
||
if (isset($fields['dhl_cod_payment_methods'])) {
|
||
$fields['dhl_cod_payment_methods']['options'] = $payment_gateway_titles;
|
||
}
|
||
}
|
||
}
|
||
|
||
return $fields;
|
||
}
|
||
|
||
/**
|
||
* Generate Button HTML.
|
||
*
|
||
* @param mixed $key
|
||
* @param mixed $data
|
||
*
|
||
* @since 1.0.0
|
||
*
|
||
* @return string
|
||
*/
|
||
public function generate_button_html($key, $data)
|
||
{
|
||
$field = $this->plugin_id.$this->id.'_'.$key;
|
||
$defaults = [
|
||
'class' => 'button-secondary',
|
||
'css' => '',
|
||
'custom_attributes' => [],
|
||
'desc_tip' => false,
|
||
'description' => '',
|
||
'title' => '',
|
||
];
|
||
|
||
$data = wp_parse_args($data, $defaults);
|
||
|
||
ob_start();
|
||
?>
|
||
<tr valign="top">
|
||
<th scope="row" class="titledesc">
|
||
<label for="<?php echo esc_attr($field); ?>"><?php echo esc_html($data['title']); ?></label>
|
||
<?php echo $this->get_tooltip_html($data); ?>
|
||
</th>
|
||
<td class="forminp">
|
||
<fieldset>
|
||
<legend class="screen-reader-text"><span><?php echo esc_html($data['title']); ?></span></legend>
|
||
<button class="<?php echo esc_attr($data['class']); ?>" type="button" name="<?php echo esc_attr($field); ?>" id="<?php echo esc_attr($field); ?>" style="<?php echo esc_attr($data['css']); ?>" <?php echo $this->get_custom_attribute_html($data); ?>><?php echo esc_html($data['title']); ?></button>
|
||
<?php echo $this->get_description_html($data); ?>
|
||
</fieldset>
|
||
</td>
|
||
</tr>
|
||
<?php
|
||
return ob_get_clean();
|
||
}
|
||
|
||
public function init_instance_form_fields()
|
||
{
|
||
$this->instance_form_fields = [
|
||
'title' => [
|
||
'title' => esc_html__('Method Title', 'dhl-for-woocommerce'),
|
||
'type' => 'text',
|
||
'description' => esc_html__('This controls the title which the user sees during checkout.', 'dhl-for-woocommerce'),
|
||
'default' => esc_html__('DHL Paket', 'dhl-for-woocommerce'),
|
||
'desc_tip' => true,
|
||
],
|
||
];
|
||
}
|
||
|
||
/**
|
||
* Validate the API key
|
||
*
|
||
* @see validate_settings_fields()
|
||
*/
|
||
public function validate_dhl_pickup_field($key)
|
||
{
|
||
$value = wc_clean($_POST[$this->plugin_id.$this->id.'_'.$key]);
|
||
|
||
try {
|
||
$dhl_obj = PR_DHL()->get_dhl_factory();
|
||
$dhl_obj->dhl_validate_field('pickup', $value);
|
||
|
||
} catch (Exception $e) {
|
||
echo $this->get_message(esc_html__('Pickup Account Number: ', 'dhl-for-woocommerce').esc_html($e->getMessage()));
|
||
throw $e;
|
||
}
|
||
|
||
return $value;
|
||
}
|
||
|
||
/**
|
||
* Validate the API secret
|
||
*
|
||
* @see validate_settings_fields()
|
||
*/
|
||
public function validate_dhl_distribution_field($key)
|
||
{
|
||
$value = wc_clean($_POST[$this->plugin_id.$this->id.'_'.$key]);
|
||
|
||
try {
|
||
|
||
$dhl_obj = PR_DHL()->get_dhl_factory();
|
||
$dhl_obj->dhl_validate_field('distribution', $value);
|
||
|
||
} catch (Exception $e) {
|
||
|
||
echo $this->get_message(esc_html__('Distribution Center: ', 'dhl-for-woocommerce').esc_html($e->getMessage()));
|
||
throw $e;
|
||
}
|
||
|
||
return $value;
|
||
}
|
||
|
||
/**
|
||
* Validate the Google API Key
|
||
*
|
||
* @see validate_settings_fields()
|
||
*/
|
||
/*
|
||
public function validate_dhl_google_maps_api_key_field( $key ) {
|
||
$google_maps_api = wc_clean( $_POST[ $this->plugin_id . $this->id . '_' . $key ] );
|
||
|
||
if ( empty( $google_maps_api ) ) {
|
||
|
||
if ( isset( $_POST[ $this->plugin_id . $this->id . '_dhl_display_packstation' ] ) ||
|
||
isset( $_POST[ $this->plugin_id . $this->id . '_dhl_display_parcelshop' ] ) ||
|
||
isset( $_POST[ $this->plugin_id . $this->id . '_dhl_display_post_office' ] ) ) {
|
||
|
||
$error_message = esc_html__( 'In order to show the dhl locations on a map, you need to insert a Google API Key. Otherwise, please deactivate the locations.', 'dhl-for-woocommerce' );
|
||
echo $this->get_message( $error_message );
|
||
throw new Exception( $error_message );
|
||
|
||
}
|
||
}
|
||
|
||
return $google_maps_api;
|
||
}*/
|
||
|
||
/**
|
||
* Validate the Packstation enabled field
|
||
*
|
||
* @see validate_settings_fields()
|
||
*/
|
||
public function validate_dhl_display_packstation_field($key)
|
||
{
|
||
return $this->validate_location_enabled_field($key, PR_DHL_PACKSTATION);
|
||
}
|
||
|
||
/**
|
||
* Validate the Parcelshop enabled field
|
||
*
|
||
* @see validate_settings_fields()
|
||
*/
|
||
public function validate_dhl_display_parcelshop_field($key)
|
||
{
|
||
return $this->validate_location_enabled_field($key, esc_html__('Parcelshop', 'dhl-for-woocommerce'));
|
||
}
|
||
|
||
/**
|
||
* Validate the Post Office enabled field
|
||
*
|
||
* @see validate_settings_fields()
|
||
*/
|
||
public function validate_dhl_display_post_office_field($key)
|
||
{
|
||
return $this->validate_location_enabled_field($key, esc_html__('Post Office', 'dhl-for-woocommerce'));
|
||
}
|
||
|
||
/**
|
||
* Validate the Google Maps enabled field
|
||
*
|
||
* @see validate_settings_fields()
|
||
*/
|
||
public function validate_dhl_display_google_maps_field($key)
|
||
{
|
||
return $this->validate_location_enabled_field($key, esc_html__('Google Maps', 'dhl-for-woocommerce'));
|
||
}
|
||
|
||
/**
|
||
* Validate the logo enabled field
|
||
*
|
||
* @see validate_settings_fields()
|
||
*/
|
||
public function validate_dhl_add_logo_field($key)
|
||
{
|
||
|
||
if (! isset($_POST[$this->plugin_id.$this->id.'_'.$key])) {
|
||
return 'no';
|
||
}
|
||
|
||
// Verify shipper reference set
|
||
$shipper_reference = $_POST[$this->plugin_id.$this->id.'_dhl_shipper_reference'];
|
||
|
||
if (empty($shipper_reference)) {
|
||
$error_message = esc_html__('In order to use logo, you need to set a shipper reference first.', 'dhl-for-woocommerce');
|
||
echo $this->get_message($error_message);
|
||
|
||
return 'no';
|
||
}
|
||
|
||
return 'yes';
|
||
}
|
||
|
||
/**
|
||
* Validate the any location enabled field
|
||
*
|
||
* @see validate_settings_fields()
|
||
*
|
||
* @return string 'no' or 'yes' (not exception) to 'disable' locations as opposed to NOT save them
|
||
*/
|
||
protected function validate_location_enabled_field($key, $location_type)
|
||
{
|
||
if (! isset($_POST[$this->plugin_id.$this->id.'_'.$key])) {
|
||
return 'no';
|
||
}
|
||
|
||
// Verify whether Google API key set
|
||
$google_maps_api_key = $_POST[$this->plugin_id.$this->id.'_dhl_google_maps_api_key'];
|
||
|
||
// If Open Street Map is selected no API key is necessary.
|
||
$map_type_key = $this->plugin_id.$this->id.'_dhl_map_type';
|
||
if (isset($_POST[$map_type_key])) {
|
||
$map_type = wc_clean(wp_unslash($_POST[$map_type_key]));
|
||
} else {
|
||
$map_type = $this->get_option('dhl_map_type', 'gmaps');
|
||
}
|
||
|
||
if ($map_type !== 'gmaps') {
|
||
return 'yes';
|
||
}
|
||
|
||
// If not return 'no'
|
||
if (empty($google_maps_api_key)) {
|
||
|
||
if ($key == 'dhl_display_google_maps') {
|
||
/* translators: %s: type of location (e.g., DHL locations) */
|
||
$error_message = sprintf(esc_html__('In order to show %s, you need to set a Google API Key first.', 'dhl-for-woocommerce'), $location_type);
|
||
} else {
|
||
/* translators: %s: type of location (e.g., DHL locations on a map) */
|
||
$error_message = sprintf(esc_html__('In order to show %s on a map, you need to set a Google API Key first.', 'dhl-for-woocommerce'), $location_type);
|
||
}
|
||
|
||
echo $this->get_message($error_message);
|
||
|
||
return 'no';
|
||
}
|
||
|
||
return 'yes';
|
||
}
|
||
}
|
||
|
||
}
|