Skip to content

Commit

Permalink
fix: order notes stock calculation with variable product, in vendor d…
Browse files Browse the repository at this point in the history
…ashboard
  • Loading branch information
kapilpaul committed Dec 15, 2020
1 parent 82ef636 commit 0697665
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 4 additions & 2 deletions includes/Order/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ public function handle_order_notes_for_suborder( $order ) {
$has_sub_order = wp_get_post_parent_id( $order->get_id() );

//return if it has suborder. only continue if this is a suborder
if ( $order->get_meta( 'has_sub_order' ) && ! $has_sub_order ) {
if ( ! $has_sub_order ) {
return;
}

Expand All @@ -423,7 +423,9 @@ public function handle_order_notes_for_suborder( $order ) {

//adding stock level notes in order
foreach ( $order->get_items( 'line_item' ) as $key => $line_item ) {
$product = wc_get_product( $line_item->get_product_id() );
$item_id = $line_item->get_variation_id() ? $line_item->get_variation_id() : $line_item->get_product_id();

$product = wc_get_product( $item_id );

if ( $product->get_manage_stock() ) {
$stock_quantity = $product->get_stock_quantity();
Expand Down
7 changes: 4 additions & 3 deletions templates/orders/details.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,12 @@
<div class="dokan-panel-heading"><strong><?php esc_html_e( 'Order Notes', 'dokan-lite' ); ?></strong></div>
<div class="dokan-panel-body" id="dokan-order-notes">
<?php
$args = array(
$args = [
'post_id' => $order_id,
'approve' => 'approve',
'type' => 'order_note'
);
'type' => 'order_note',
'status' => 1,
];

remove_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 );
$notes = get_comments( $args );
Expand Down

0 comments on commit 0697665

Please sign in to comment.