Trigger a JavaScript function based on the data fetched from Woo commerce hook

After going through a lot of articles and solutions I finally figured it out: Directory Structure for the plugin (Boilerplate directory structure used from here) First step: Register a js script which would track the event/ user activity and pass it the ajax URL through which it would fetch the product details via ajax. // … Read more

Suitable hook when creating, updating and deleting posts programmatically

Hooks are not for deleting or creating posts, they are kind of event listeners. For example ‘delete_post’: “Fires immediately before a post is deleted from the database.” [https://developer.wordpress.org/reference/hooks/delete_post/] You need to use the WordPress REST API: https://developer.wordpress.org/rest-api/reference/posts/ This article by Misha Rudrastyh gives a good intro: https://rudrastyh.com/wordpress/rest-api-create-delete-posts.html

Can’t use updated variables in handle function

A huge thanks to @JacobPeattie We should pass the url to data function and retrieve it using _POST so the main file will be: <?php /* Plugin info… */ class Example_Background_Processing { protected $process_single; public function __construct() { add_action( ‘plugins_loaded’, array( $this, ‘init’ ) ); add_action( ‘woocommerce_add_to_cart’, array($this, ‘add_to_cart_callback’), 10, 2); } public function init() … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)