- 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>
117 lines
3.7 KiB
PHP
117 lines
3.7 KiB
PHP
<?php
|
|
|
|
/**
|
|
* PR_DHL_WC_Product_Editor class file.
|
|
*/
|
|
if (! defined('ABSPATH')) {
|
|
exit; // Exit if accessed directly
|
|
}
|
|
|
|
use Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface;
|
|
|
|
if (! class_exists('PR_DHL_WC_Product_Editor')) {
|
|
/**
|
|
* PR_DHL_WC_Product_Editor Class.
|
|
*/
|
|
abstract class PR_DHL_WC_Product_Editor
|
|
{
|
|
/**
|
|
* Manufacture country tooltip.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $manufacture_tooltip = '';
|
|
|
|
/**
|
|
* Manufacture country label.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $manufacture_country_label = '';
|
|
|
|
/**
|
|
* HS Code label.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $hs_code_label = '';
|
|
|
|
/**
|
|
* HS Code description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $hs_code_description = '';
|
|
|
|
/**
|
|
* Class constructor.
|
|
*/
|
|
public function __construct()
|
|
{
|
|
add_action('woocommerce_block_template_area_product-form_after_add_block_product-shipping-dimensions', [$this, 'add_product_shipping_fields']);
|
|
add_action('woocommerce_block_template_area_product-form_after_add_block_product-variation-shipping-dimensions', [$this, 'add_product_shipping_fields']);
|
|
}
|
|
|
|
/**
|
|
* Add additional product fields.
|
|
*/
|
|
abstract public function additional_product_fields($parent): void;
|
|
|
|
/**
|
|
* Add DHL product fields.
|
|
*/
|
|
public function add_product_shipping_fields(BlockInterface $shipping_dimensions_block): void
|
|
{
|
|
if (! method_exists($shipping_dimensions_block, 'get_parent')) {
|
|
return;
|
|
}
|
|
|
|
$parent = $shipping_dimensions_block->get_parent();
|
|
|
|
// Add Country of Origin Select Block.
|
|
$countries = WC()->countries->get_countries();
|
|
$parent->add_block(
|
|
[
|
|
'id' => '_dhl_manufacture_country',
|
|
'blockName' => 'woocommerce/product-select-field',
|
|
'attributes' => [
|
|
'label' => $this->manufacture_country_label,
|
|
'property' => 'meta_data._dhl_manufacture_country',
|
|
'options' => array_merge(
|
|
[
|
|
[
|
|
'value' => '0',
|
|
'label' => __('- select country -', 'dhl-for-woocommerce'),
|
|
],
|
|
],
|
|
array_map(function ($key, $value) {
|
|
return [
|
|
'value' => $key,
|
|
'label' => $value,
|
|
];
|
|
}, array_keys($countries), $countries)
|
|
),
|
|
'tooltip' => $this->manufacture_tooltip,
|
|
],
|
|
]
|
|
);
|
|
|
|
// Add HS Tariff Code Text Block.
|
|
$parent->add_block(
|
|
[
|
|
'id' => '_dhl_hs_code',
|
|
'blockName' => 'woocommerce/product-text-field',
|
|
'attributes' => [
|
|
'label' => $this->hs_code_label,
|
|
'property' => 'meta_data._dhl_hs_code',
|
|
'placeholder' => esc_html__('HS Code', 'dhl-for-woocommerce'),
|
|
'tooltip' => $this->hs_code_description,
|
|
],
|
|
]
|
|
);
|
|
|
|
$this->additional_product_fields($parent);
|
|
}
|
|
}
|
|
|
|
}
|