Woocommerce inventory [closed]

The woocommerce_checkout_order_processed hook is too late. The order has already been created. You’d probably want to hook into woocommerce_after_checkout_validation so that you can check for the inventory before the order is even triggered and set an error that will be displayed at checkout. By hooking in here, you will be able to short circuit the … Read more

Empty Pdf file generated with FPDF library in WordPress plugin [closed]

This might not solve the problem, but what you’re currently doing looks unnecessarily convoluted (ajax request, fake link, serve PDF via link click etc.) Why not just a link styled as a button… <a class=”button” href=”<?= admin_url( ‘admin-post.php?action=wpse_212972_pdf’ ) ?>”>Download</a> …and then serve the PDF as a download directly from the server (using WP’s generic … Read more

Translate javascript with WordPress built-in localization API for static strings

wp_localize_script() defines a variable in the global JS scope – in the case of your code, the object is placed in a globally-scoped variable with the identifier MediaFolders. In your load event callback you are also defining a variable with the identifier MediaFolders scoped to it’s encapsulating function body – so when you use the … Read more