Skip to content

Commit 0afcb03

Browse files
authored
Merge pull request #198 from TycheSoftwares/revert-190-issue-150
Revert "issue-150"
2 parents b6b1f6c + 9b177f2 commit 0afcb03

File tree

2 files changed

+28
-53
lines changed

2 files changed

+28
-53
lines changed

woocommerce-delivery-notes/includes/wcdn-template-functions.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,4 +640,28 @@ function wcdn_print_extra_fields( $item ) {
640640
}
641641

642642
}
643+
644+
/**
645+
* Function to show the correct quantity on the frontend when Composite/Bundle products are there.
646+
*
647+
* @param int $count Total Quantity.
648+
* @param string $type Item Type.
649+
* @param WC_Order $order Order object.
650+
*/
651+
function wcdn_order_item_count( $count, $type, $order ) {
652+
global $wp;
653+
// Check that print button is been clicked or not.
654+
if ( ! empty( $wp->query_vars['print-order'] ) ) {
655+
if ( in_array( 'woocommerce-composite-products/woocommerce-composite-products.php', apply_filters( 'active_plugins', get_option( 'active_plugins', array() ) ), true ) || in_array( 'woocommerce-product-bundles/woocommerce-product-bundles.php', apply_filters( 'active_plugins', get_option( 'active_plugins', array() ) ), true ) ) {
656+
if ( function_exists( 'is_account_page' ) && is_account_page() ) {
657+
$count = 0;
658+
foreach ( $order->get_items() as $item ) {
659+
$count += $item->get_quantity();
660+
}
661+
}
662+
}
663+
}
664+
return $count;
665+
}
666+
add_filter( 'woocommerce_get_item_count', 'wcdn_order_item_count', 20, 3 );
643667
?>

woocommerce-delivery-notes/templates/print-order/print-content.php

Lines changed: 4 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -228,62 +228,13 @@
228228
<?php do_action( 'wcdn_order_item_after', $product, $order, $item ); ?>
229229
</td>
230230
<td class="product-item-price">
231-
<span>
232-
<?php
233-
$product_meta_datas = $item->get_meta_data();
234-
$price_individually = '';
235-
$no_price = false;
236-
if ( is_array( $product_meta_datas ) ) {
237-
foreach ( $product_meta_datas as $product_meta_data ) {
238-
if ( isset( $product_meta_data->key ) ) {
239-
if ( '_bundled_items' === $product_meta_data->key || '_composite_children' === $product_meta_data->key ) {
240-
$no_price = true;
241-
}
242-
if ( '_bundled_item_priced_individually' === $product_meta_data->key || '_component_priced_individually' === $product_meta_data->key ) {
243-
$price_individually = $product_meta_data->value;
244-
}
245-
}
246-
}
247-
}
248-
if ( 'no' === $price_individually ) {
249-
echo '';
250-
} elseif ( true === $no_price ) {
251-
echo wp_kses_post( $order->get_formatted_line_subtotal( $item ) );
252-
} else {
253-
echo wp_kses_post( wcdn_get_formatted_item_price( $order, $item ) );
254-
}
255-
?>
256-
</span>
231+
<span><?php echo wp_kses_post( wcdn_get_formatted_item_price( $order, $item ) ); ?></span>
257232
</td>
258233
<td class="product-quantity">
259-
<span>
260-
<?php
261-
$product_meta_datas = $item->get_meta_data();
262-
if ( is_array( $product_meta_datas ) ) {
263-
foreach ( $product_meta_datas as $product_meta_data ) {
264-
if ( isset( $product_meta_data->key ) ) {
265-
if ( '_composite_children' === $product_meta_data->key || '_bundled_items' === $product_meta_data->key ) {
266-
$item['qty'] = 0;
267-
} else {
268-
continue;
269-
}
270-
}
271-
}
272-
}
273-
if ( 0 === $item['qty'] ) {
274-
echo '';
275-
} else {
276-
echo esc_attr( apply_filters( 'wcdn_order_item_quantity', $item['qty'], $item ) );
277-
}
278-
?>
279-
</span>
234+
<span><?php echo esc_attr( apply_filters( 'wcdn_order_item_quantity', $item['qty'], $item ) ); ?></span>
280235
</td>
281236
<td class="product-price">
282-
<span>
283-
<?php
284-
echo wp_kses_post( $order->get_formatted_line_subtotal( $item ) );
285-
?>
286-
</span>
237+
<span><?php echo wp_kses_post( $order->get_formatted_line_subtotal( $item ) ); ?></span>
287238
</td>
288239
</tr>
289240
<?php endforeach; ?>
@@ -302,7 +253,7 @@
302253
<td class="total-item-price"></td>
303254
<?php if ( 'Total' === $total['label'] ) { ?>
304255
<td class="total-quantity"><?php echo wp_kses_post( $order->get_item_count() ); ?></td>
305-
<?php } else { ?>
256+
<?php } else { ?>
306257
<td class="total-quantity"></td>
307258
<?php } ?>
308259
<td class="total-price"><span><?php echo wp_kses_post( $total['value'] ); ?></span></td>

0 commit comments

Comments
 (0)