Partnercenter-API: WooCommerce-Plugin (v1.3.3) als Referenz eingecheckt
Der in den Partner-Shops installierte WooCommerce-Connector, der Bestellungen per REST an /api/wp/* uebertraegt (Kunde anlegen, Warenkorb, Status-Abgleich). Grundlage fuer AP-13 (Shop-Bestandsabzug beim Versand). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
a14751ed10
commit
592b03ace5
13 changed files with 2023 additions and 0 deletions
135
dev/partnercenter-api/admin/post-list.php
Normal file
135
dev/partnercenter-api/admin/post-list.php
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
<?php
|
||||
/*
|
||||
* Add to Post List Class
|
||||
*/
|
||||
|
||||
if (! defined('ABSPATH')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class PARTNERCENTER_API_Order_Post_List_Class
|
||||
{
|
||||
/**
|
||||
* PARTNERCENTER_API_Order_Post_List_Class constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
// Add custom column
|
||||
add_filter('manage_edit-shop_order_columns', [$this, 'manage_edit_shop_order_columns'], 20);
|
||||
|
||||
// Fill the column
|
||||
add_action('manage_shop_order_posts_custom_column', [
|
||||
$this,
|
||||
'manage_shop_order_posts_custom_column',
|
||||
], 20, 2);
|
||||
|
||||
// Style custom column
|
||||
add_action('admin_print_styles', [$this, 'admin_print_styles'], 20);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add custom column.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function manage_edit_shop_order_columns(array $columns)
|
||||
{
|
||||
|
||||
$new_columns = [];
|
||||
|
||||
foreach ($columns as $column_name => $column_info) {
|
||||
|
||||
$new_columns[$column_name] = $column_info;
|
||||
|
||||
if ($column_name === 'order_status') {
|
||||
$new_columns['partnercenter-status'] = __('PARTNERCENTER Status', 'partnercenter-api');
|
||||
}
|
||||
}
|
||||
|
||||
return $new_columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add content to custom column.
|
||||
*
|
||||
* @param int $order_id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function manage_shop_order_posts_custom_column(string $column, $order_id)
|
||||
{
|
||||
|
||||
// Check if our column is worked on
|
||||
if ($column !== 'partnercenter-status') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if order was send to PARTNERCENTER
|
||||
$forwarded = intval(get_post_meta($order_id, '_partnercenter_api_order_fulfillment_forwarded', true));
|
||||
if ($forwarded === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Display the status from DB?>
|
||||
<?php
|
||||
switch (get_post_meta($order_id, '_partnercenter_api_order_status', true)) {
|
||||
case 'free':
|
||||
break;
|
||||
case 'sent':
|
||||
case 'close': ?>
|
||||
<div class="partnercenter-status-circle green"></div>
|
||||
<?php
|
||||
break;
|
||||
case 'open':
|
||||
case 'process': ?>
|
||||
<div class="partnercenter-status-circle orange"></div>
|
||||
<?php
|
||||
break;
|
||||
default: ?>
|
||||
<span style="font-size: 200%">
|
||||
<?php _e('⚠️', 'partnercenter-api'); ?>
|
||||
</span>
|
||||
<?php break;
|
||||
} ?>
|
||||
|
||||
<?php }
|
||||
|
||||
/**
|
||||
* Style custom column.
|
||||
*/
|
||||
public function admin_print_styles()
|
||||
{
|
||||
|
||||
// Get the screen
|
||||
if (get_current_screen()->id !== 'edit-shop_order') {
|
||||
return;
|
||||
} ?>
|
||||
|
||||
<style type="text/css">
|
||||
th.column-partnercenter-status {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.partnercenter-status-circle {
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
border-radius: 100%;
|
||||
background: darkorange;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.partnercenter-status-circle.green {
|
||||
background: limegreen;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<?php }
|
||||
}
|
||||
|
||||
new PARTNERCENTER_API_Order_Post_List_Class;
|
||||
Loading…
Add table
Add a link
Reference in a new issue