I am trying to customise add_to_cart_with_quantity_ajax.php in woocommerce-views/custom_shortcode_templates by copying the file into my theme folder then editing.
I have tried placing the edited version in themefolder/woocommerce-views/custom_shortcode_templates and in themefolder/woocommerce-views/ but neither has worked.
Can you advise on how to customise this file without loosing changes when updating my plugins?
The best thing to do for this is to use a hook to overwrite the default function.
I would suggest letting me know which function you want to overwrite exactly, there may be a woocommerce hook that can be used to overwrite the default function in a hook.
I had originally been attempting to add a hidden input field as outlined at hidden link but I then realised that this hook doesn’t exist in the template file for this short code.
The bigger picture is that I need to get a number specified in a URL parameter on the page where the short code is output and add this to the cart_item array so it can be displayed in the cart and checkout.
Because of that I could bypass the hidden field idea but I’d still need a way to get that variable when the Add to Cart button is clicked.
I'm well versed in adding custom code and using hooks - the problem is that the toolset WooCommerce views shortcode template add_to_cart_with_quantity_ajax.php does not contain the WooCommerce hook that I need to use (woocommerce_before_add_to_cart_button) and furthermore it does not appear to contain any hooks that would allow me to add content within the <form> tags.
Because of this, I need to know how I can make changes to the template without loosing them when I update the plugin.
The hook (woocommerce_before_add_to_cart_button) should still function given that woocommerce is enabled.
I see what you mean tho since it isn't using the default templating for woocommerce thats why it doesn't work. In this case you will need to add it directly to the template file itself.
Changes made to the file itself will get overwritten when an update is performed.