compose_label_data() liest das Meta-Feld _pr_shipment_dhl_label_tracking (DHL for WooCommerce); write_order_items() schickt Label-URL + Sendungsnummer beim wp/order-Transfer mit. Neuer Listener auf pr_save_dhl_label_tracking reicht Labels nach, die erst nach der Übertragung erstellt werden (nur bei bereits übertragenen Bestellungen, via neuem wp/label-Endpoint). Connector-Doku auf die konkrete Umsetzung aktualisiert. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
105 lines
2.4 KiB
PHP
105 lines
2.4 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Plugin Name: PARTNERCENTER API Connector
|
|
* Description: Connect WooCommerce to PARTNERCENTER API
|
|
* Version: 1.4.0
|
|
* Author: Cross Media Cloud
|
|
* Author URI: https://www.cross-media-cloud.de
|
|
* License: GNU General Public License v2 or later
|
|
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
|
* Text Domain: partnercenter-api
|
|
* Domain Path: /languages/
|
|
*/
|
|
if (! defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
/**
|
|
* Load plugin text domain
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
function partnercenter_api_load_textdomain()
|
|
{
|
|
|
|
load_plugin_textdomain('partnercenter-api', false, plugin_basename(dirname(__FILE__)).'/languages');
|
|
|
|
}
|
|
add_action('plugins_loaded', 'partnercenter_api_load_textdomain');
|
|
|
|
/**
|
|
* Function to run after plugin activation
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
function partnercenter_api_activate()
|
|
{
|
|
|
|
// Add event to wp cron
|
|
wp_schedule_event(time(), 'hourly', 'partnercenter_api_fetch_orders_status');
|
|
|
|
}
|
|
register_activation_hook(__FILE__, 'partnercenter_api_activate');
|
|
|
|
/**
|
|
* Function to run after plugin deactivation
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
function partnercenter_api_deactivate()
|
|
{
|
|
|
|
/*
|
|
* Remove order status check from wp cron
|
|
*/
|
|
$timestamp = wp_next_scheduled('partnercenter_api_fetch_orders_status');
|
|
wp_unschedule_event($timestamp, 'partnercenter_api_fetch_orders_status');
|
|
// Clean hook
|
|
wp_clear_scheduled_hook('partnercenter_api_fetch_orders_status');
|
|
|
|
}
|
|
register_deactivation_hook(__FILE__, 'partnercenter_api_deactivate');
|
|
|
|
/**
|
|
* Load API class if needed
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
function partnercenter_api_init()
|
|
{
|
|
|
|
/**
|
|
* Load the API class.
|
|
*/
|
|
require_once plugin_dir_path(__FILE__).'public/partnercenter-api/partnercenter-api.php';
|
|
|
|
return new PARTNERCENTER_API_Requests;
|
|
|
|
}
|
|
add_filter('PARTNERCENTER_API', 'partnercenter_api_init');
|
|
|
|
/*
|
|
* Load all public features.
|
|
*/
|
|
// Load testing short code
|
|
require_once 'public/shortcode.php';
|
|
// Load WooCommerce status related features
|
|
require_once 'public/woocommerce/order-status.php';
|
|
// Load DHL label forwarding ("DHL for WooCommerce" integration)
|
|
require_once 'public/woocommerce/dhl-label.php';
|
|
// Load endpoint
|
|
require_once 'public/end-point.php';
|
|
|
|
/*
|
|
* Load admin features.
|
|
*/
|
|
if (is_admin()) {
|
|
|
|
// Load post list features
|
|
require_once 'admin/post-list.php';
|
|
|
|
// Load button to forward order to fulfilment by PARTNERCENTER
|
|
require_once 'admin/order-forwarding-button-metabox.php';
|
|
|
|
}
|