Skip to content

Commit

Permalink
Work in progress: Initiating work around invoice number meta box for …
Browse files Browse the repository at this point in the history
…orders
  • Loading branch information
aldavigdis committed Aug 5, 2024
1 parent 3b2d2c4 commit 7f11105
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Hooks/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ public function __construct() {
2
);

add_action(
'add_meta_boxes',
array( __CLASS__, 'add_dk_invoice_metabox' )
);

if ( Config::get_product_convertion_to_variation_enabled() ) {
add_filter(
'bulk_actions-edit-product',
Expand All @@ -88,6 +93,21 @@ public function __construct() {
}
}

public static function add_dk_invoice_metabox() {
add_meta_box(
'1984-dk-woo-dk-invoice-metabox',
__( 'DK Invoice', '1984-dk-woo' ),
array( __CLASS__, 'render_dk_invoice_metabox' ),
'shop_order',
context: 'side',
priority: 'high'
);
}

public static function render_dk_invoice_metabox() {
require dirname( __DIR__, 2 ) . '/views/dk_invoice_metabox.php';
}

/**
* Filter for adding the DK invoice column to the orders table
*
Expand Down
41 changes: 41 additions & 0 deletions views/dk_invoice_metabox.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

declare(strict_types = 1);

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

$wc_order = wc_get_order( $_GET['post'] );

$invoice_number = $wc_order->get_meta( '1984_woo_dk_invoice_number', true, 'edit' );
$credit_invoice_number = $wc_order->get_meta( '1984_woo_dk_credit_invoice_number', true, 'edit' );

?>

<div>
<div>
<label>Invoice Number</label>
<input
name="1984_woo_dk_invoice_number"
type="text"
value="<?php echo esc_attr( $invoice_number ); ?>"
/>
</div>
<div>
<button class="button button-small button-secondary">Set Invoice Number</button>
<button class="button button-small button-primary">Create in DK</button>
</div>
</div>

<div>
<label>Credit Invoice Number</label>
<input
name="1984_woo_dk_credit_invoice_number"
type="text"
value="<?php echo esc_attr( $credit_invoice_number ); ?>"
/>
<div>
<button class="button button-small button-secondary">Set Credit Invoice Number</button>
</div>
</div>

0 comments on commit 7f11105

Please sign in to comment.