Skip to content

Commit

Permalink
Remove bundled items in shipments in case the item is hidden within t…
Browse files Browse the repository at this point in the history
…he order.
  • Loading branch information
dennisnissle committed Sep 19, 2024
1 parent 430ac4a commit 5eb1e96
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Compatibility/Bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,23 @@ function() {
add_filter( 'woocommerce_shiptastic_order_item_product', array( __CLASS__, 'get_product_from_item' ), 10, 2 );
add_filter( 'woocommerce_shiptastic_cart_item', array( __CLASS__, 'adjust_cart_item' ), 10, 2 );
add_action( 'woocommerce_shiptastic_shipment_items_synced', array( __CLASS__, 'apply_bundle_hierarchy' ), 10, 3 );
add_filter( 'woocommerce_shiptastic_order_item_quantity_left_for_shipping', array( __CLASS__, 'maybe_remove_children' ), 10, 2 );
}

/**
* @param integer $quantity_left
* @param \WC_Order_Item $order_item
*
* @return integer
*/
public static function maybe_remove_children( $quantity_left, $order_item ) {
if ( wc_pb_is_bundled_order_item( $order_item ) ) {
if ( apply_filters( 'woocommerce_shiptastic_remove_hidden_bundled_items', 'yes' === $order_item->get_meta( '_bundled_item_hidden' ), $order_item ) ) {
$quantity_left = 0;
}
}

return $quantity_left;
}

/**
Expand Down

0 comments on commit 5eb1e96

Please sign in to comment.