redmorgane
Forum Replies Created
-
Yes, that work !
Thank you so much ??I don’t really see how installing Code Snippets can help ? Would you mind explaining why this would be useful ?
Here is all the code related to the PDFs I have in my functions.php file.
I also made a custom template by following the guidelines in the plugin documentation.// Change PDF names add_filter( 'wpo_wcpdf_invoice_title', 'wpo_wcpdf_invoice_title', 10, 2 ); function wpo_wcpdf_invoice_title ( $title, $document ) { $title = 'Carte cadeau'; return $title; } add_filter( 'wpo_wcpdf_filename', 'wpo_wcpdf_custom_filename', 10, 4 ); function wpo_wcpdf_custom_filename( $filename, $template_type, $order_ids, $context ) { $invoice_string = _n( 'invoice', 'invoices', count($order_ids), 'woocommerce-pdf-invoices-packing-slips' ); $new_prefix = _n( 'carte-cadeau', 'cartes-cadeaux', count($order_ids), 'woocommerce-pdf-invoices-packing-slips' ); $new_filename = str_replace($invoice_string, $new_prefix, $filename); return $new_filename; } // Allow PDF only for "cartes cadeaux" add_filter('wpo_wcpdf_document_is_allowed', function( $allowed, $document ) { if ( $document->get_type() == 'invoice' ) { if ( $document->exists() ) { return $allowed; } $allowed = false; // disabled by default $products_ids = array(185747); // Enter here all the allowed product IDs if ( ! empty( $order = $document->order) && $document->get_type() == 'invoice' ) { foreach( $order->get_items() as $item_id => $item ) { $product_id = $item['variation_id'] != 0 ? $item['variation_id'] : $item['product_id']; if( in_array($product_id, $products_ids) ) { $allowed = true; // enable if the product ID match break; } } } } return $allowed; }, 10, 2);
The last part is the exact code you send me, but I changed the ID to the product I want to target.
I just tested it again, and it is defintely not working for me.
It result in no PDF being sent at all, for any product.The product I’m trying to target is a variable product, if this change anything ?
I use my own custom made WordPress theme made on a _s basis, with very minimal plugin, so I don’t think there could be any incompatibility. Everything is up to date too.
Anything I’m doing wrong ?
Sorry for double message, just to let you know that changing “invoice” with “carte-cadeau” in your code result in the PDF being send with all product (so basically cancelling the code).
So I don’t think it has anything to do with it. I’m going to try again with invoice and check if I can tweak it myself, but would be super grateful for your help again ??
Thank you for your reply !
I just gave your code a try, but unfortunately it doesn’t seems to work.
No PDF is being sent at all, for any product.
I change the $products_ids value to put my product ID, but had no luck whatsoever.I need the PDF to be sent ONLY for one particular product (which ID is 185747).
I’m really confused because your code seems logical to me. Could it be bothered by the fact I rename “Invoice” with the following filter ?
add_filter( 'wpo_wcpdf_filename', 'wpo_wcpdf_custom_filename', 10, 4 );
My new prefix is “carte-cadeau”.
Forum: Plugins
In reply to: [ACF: Better Search] No ACF fields retrieve in search result for imported CPTNevermind, I just tried another setting (I onky checked them all separetly, never in combinaison), and it seems that checking “Lite mode” in addition with “Incorrect Mode” does work for me !
I’ll give it a try in the long term and hope this will do !Thank you again,
MorganeForum: Plugins
In reply to: [ACF: Better Search] No ACF fields retrieve in search result for imported CPTHey Mateusz,
Thank you for your reply !
I did try the Lite mode (as well as all other checkboxes on the plugin) but it doesn’t seems to help ??
I wouldn’t honestly care if search is “slower”, as long as it is simply working.
Saving the post manually doesn’t seems to do anything much either.I know this is quite a long reach, but do you happen to know if there is any way to configure the import to the order of wp_postmeta table as WordPress intended ?
Would importing fields as “custom fields” instead of ACF fields change anything ?I realise you’re not the developper of both those plugin, but it looks like the issue has been quite often brought up in this forum, so maybe you have an idea.
Thank you again for your help,
MorganeI don’t really get how I can do all that. Would you have some example for me ?
This part of code I give is part of other things I have on the same options for my plugin, so If I move something just for this one (the coming soon checkbox), I’ll have to consider the rest as well.
Like I said, it’s first time I do something like that and unfortunately I don’t have anyone to refer in case of trouble.
I spend hours on forum and codex tro try to get it but just can’t ??- This reply was modified 6 years, 4 months ago by redmorgane. Reason: typo