Bestellungen mit Produktvarianten (z. B. Deocreme MINI) wurden im Versand nicht automatisch zugeordnet und mussten manuell nachgepflegt werden. Zwei zusammenwirkende Fehler: 1. Connector (partnercenter-api v1.6.0): compose_cart_content() las per get_product_id() das Elternprodukt und sendete dessen SKU — nie die eigene Artikel-Nr. der Variation. Jetzt liest get_product() (variations-aware) die Variations-SKU, Fallback auf Eltern-SKU nur wenn leer. Plugin muss neu in den Shop ausgerollt werden. 2. Importer (ShoppingUserController::prepareOrder): matchte nur den Teil vor dem ersten „-" gegen wp_number. In der Live-DB ist jede Variante eine eigene products-Zeile mit eigener wp_number (kein main_product_id, keine „-"-Suffixe). Jetzt Zuordnung primär über die VOLLE SKU gegen wp_number; der „-"-Split bleibt nur Legacy-Fallback für alte Variations-SKUs „basisnr-suffix". Tests: neue AP-34-Prüfung (MINI 100026 landet beim MINI-Produkt, nicht beim 50-ml-Basisprodukt 100006) + Legacy-Fallback-Test. Suite 327 grün. Co-Authored-By: Claude Opus 4.8 <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.6.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';
|
|
|
|
}
|