I use the WooCommerce mobile app on my Android phone to print receipts. I have modified this file to update the printed receipt to show fields that I need.
\wp-content\plugins\woocommerce\src\Internal\ReceiptRendering\Templates\order-receipt.php
But I guess whenever WooCommerce updates, it overwrites the changes I make to this file.
My question is, is there a file structure I can make in my child theme so that this file does not get modified during updates?
I have tried changing the permissions on the file via FTP but yet it still gets overwritten.
I do have a WooCommerce directory in my child theme for other woocommerce custom changes I have made to things like email templates ect and they do work. But I don't know the structure or if there is a file structure that I can create for this particular item so it doesnt get overwritten by updates?
For other custom updates I have made I have folders like:
\woocommerce\checkout
\woocommerce\emails
\woocommerce\pdf
For this file I tried:
\woocommerce\src
\woocommerce\templates
\woocommerce\src\Internal\ReceiptRendering\Templates\
But the file still gets overwritten by the system during updates.
Or does anybody have another idea how to stop the file from changing? Can any file be placed in a child theme so that it is not changed during updates?
to customise this template, you can put the file in the child theme in woocommerce/template-receipt/order-receipt.php
e.g.
and then use this code in functions.php
:
add_filter("wc_get_template", function ($template, $template_name, $args, $template_path, $default_path) {
if ("ReceiptRendering/order-receipt.php" === $template_name) {
$template = __DIR__ . "/woocommerce/template-receipt/order-receipt.php";
}
return $template;
}, 10, 5);