Plugin Contributor
Ewout
(@pomegranate)
Hello Sasha,
We support the Product Bundles plugin from WooCommerce.com out of the box without any customizations, but if you want support for WPC Product Bundles too, you need some custom code. You can do this the same way we do this for the aforementioned plugin (source)
Looking at the WPC code, it seems that they mark the bundled products with an item meta value _woosb_parent_id. So you can adapt the filter from the link above like so:
add_filter( 'wpo_wcpdf_item_row_class', 'wpo_wcpdf_add_wpc_product_bundles_classes', 10, 4 );
function wpo_wcpdf_add_wpc_product_bundles_classes( $classes, $document_type, $order, $item_id = '' ) {
if ( $bundled_by = wc_get_order_item_meta( $item_id, '_woosb_parent_id', true ) ) {
$classes = $classes . ' bundled-item';
} elseif ( $bundled_items = wc_get_order_item_meta( $item_id, '_woosb_ids', true ) ) {
$classes = $classes . ' product-bundle';
}
return $classes;
}
If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters
This will give the rows for bundled items a class bundled-item. You can then hide that item with CSS:
.bundled-item { display: none; }
More information about using custom styles/CSS: Using custom styles
Hope that helps!
Thread Starter
salac
(@salac)
Hi
Thanks for the quick feedback.
I’m not so good at php so this script you sent I unfortunately can’t understand completely 🙂 Sorry
I have once received a script from their developer but it just can’t be used anymore as it is not compatible with your plugin. Here is the code.
add_filter( ‘wpo_wcpdf_order_items_data’, ‘woosb_wcpdf_order_items_data’ );
function woosb_wcpdf_order_items_data( $data_list ) {
foreach ( $data_list as $key => $data ) {
if ( $data[‘product’]->is_type( ‘woosb’ ) ) {
unset( $data_list[ $key ] );
}
}
return $data_list;
}
And then I should also delete this line from their plugin https://prnt.sc/n8ifse
Since wordpress and all plugins are updated quite often, i can’t see meaning to do it, otherwise i have to do this every time with every updates.
I hope you can see here if you can use any of their code that can make it easier
for you to give me a fix. Sorry but right now you are the only one who can help. I will definitely buy your pro version for my next customer, I promise you.
Sorry for my poor english
Thanks
Plugin Contributor
Ewout
(@pomegranate)
Hi! If you add the filter I sent you, you don’t need the wpo_wcpdf_order_items_data filter they sent (although I think that should work too!). What is the output you’re getting with the filter in combination with the CSS?
If you follow the instructions linked in my previous response, you don’t need to worry about plugin updates: How to use filters
Thread Starter
salac
(@salac)
Hi.
Thanks for your quick response.
add_filter( ‘wpo_wcpdf_item_row_class’, ‘wpo_wcpdf_add_wpc_product_bundles_classes’, 10, 4 );
function wpo_wcpdf_add_wpc_product_bundles_classes( $classes, $document_type, $order, $item_id = ” ) {
if ( $bundled_by = wc_get_order_item_meta( $item_id, ‘_woosb_parent_id’, true ) ) {
$classes = $classes . ‘ bundled-item’;
} elseif ( $bundled_items = wc_get_order_item_meta( $item_id, ‘_woosb_ids’, true ) ) {
$classes = $classes . ‘ product-bundle’;
}
return $classes;
}
I just copied the code ind functions.php in child theme and has hide .bundled-item { display: none!importent; } in stylesheet and clear cache in backend and on frontend.It doesn’t work and bundled items are still visible on the invoice and delivery note.
Is there something I doing wrong?
Thanks
Sasha
Plugin Contributor
Ewout
(@pomegranate)
Where exactly did you put that .bundled-item { display: none; } code? Did you follow instructions from the link? (there’s also a typo importent) – Using custom styles
CSS in the PDF are completely separate from your site styles!
Thread Starter
salac
(@salac)
I am so sorry.
I made a minor error in the code. Now it works and I’m super happy. Thank you.
I will definitely buy the pro version for our next customer. Really good support.
Thanks