Hide parent bundle products but keep child products
-
Hello, I am surprised that this is not offered natively with the “Woocommerce Bundle” plugin but I would like to avoid order preparation errors to hide the lines of the parent products on the picking-list and invoices.
I started a code but it does the opposite of what I want, namely that it hides the child products but leaves the parent product.
Can you help me?
add_filter('wpo_wcpdf_order_items_data', 'wpo_wcpdf_remove_bundle', 10, 3);
function wpo_wcpdf_remove_bundle($items, $order, $document_type) {
// Types de document où les produits en bundle doivent être supprimés
$remove_from = ['invoice', 'packing-slip'];
if (in_array($document_type, $remove_from)) {
foreach ($items as $item_id => $item) {
// Vérifiez si l'article est un produit bundle
if (isset($item['data']) && $item['data'] instanceof WC_Product_Bundle) {
// Si c'est un produit bundle, supprimez-le
unset($items[$item_id]);
}
}
}
return array_values($items); // Réindexez les clés du tableau après la suppression
}
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.