skip to Main Content

Restocking Form Not Appearing on Product Page

You install a fresh copy of Product Alerts for WooCommerce, activate the alerts, but find no restocking form on the page of sold out products. Why is that? This all too common problem happens with many themes written for WooCommerce. This plugin must rely on hooks and filters provided by WooCommerce in order to add content to the middle of an existing page. However, these hooks are found in the template files for WooCommerce, files which can be overwritten by your active theme.  This gives developers the opportunity to remove such hooks and cause issues like this. It is not a recommended approach for removing content from the page, but it is the easiest method and thus used too often.

Fixing this issue is not impossible, but will require some modification of your theme. Please note that the following instructions will work in MOST situations, but not all. If any issues arise, or if this does not resolve the problem, it would be best to contact your theme’s developer who will have a better understanding of the template files you are altering.

Copying the Template Files

If you have not done so already, it is best to be running a child theme before making your changes. If you are using a stock theme, one purchased that is still being maintained, a child theme will allow you to update your current theme without losing the changes you are about to make. You can find instructions for making a child theme on WordPress.org:
https://codex.wordpress.org/Child_Themes

When your child theme is complete, create a new directory inside titled ‘woocommerce’. This is where we will copy the necessary files to be edited.

The restocking form appears on the product details page, somewhere between the price, category, and description. All of these features are printed to the screen through one hook in the single product template. Simply adding the hook back in may cause further issues with your theme as it was removed for a reason. Generally it would cause images and product details to appear twice, which is not ideal. Instead, we will add code specific to this plugin to create a new instance.

Navigate to the folder on your computer that contains your theme files. Open the ‘woocommerce’ directory, and copy the file ‘content-single-product.php’ to the ‘woocommerce’ folder in your child theme. Generally this file only contains a few hooks, but if you are going through these steps, you will likely find a lot of code handling how the product data is put out. Determine where you would like the restocking form to appear and paste the following code in its location.

If you are not familiar with PHP or HTML, it may be helpful to speak with the developer or someone else who can understand the code a little better. 

  • Was this article helpful ?
  • yesno
0 out of 0 visitors found this article helpful
Views: 54
Back To Top