Trying to run Javascript on AJAX call

Going by your method I would suggest hooking into wp_footer as well, so that your script would be near the end of the body, that way it will be loaded after all DOM was loaded. add_action(‘woocommerce_ajax_added_to_cart’, ‘set_button_classes’); function set_button_classes () { add_action(‘wp_footer’, function () { echo “<script>document.getElementByClassName(‘added_to_cart wc-forward’).classList.add(‘ct-cart-item’, ‘ct-offcanvas-trigger’);</script>”; }); } You could also close … Read more

How to automatically change the status of product from draft to published when stock qty change from 0 > 1

Does this help? add_action( ‘save_post_product’, ‘sew_chg_status’, 10,2 ); function sew_chg_status( $post_id, $post ){ $product = new WC_Product( $post_id ); //create a WC product with post data if ( 0 < $_POST[‘_stock’] ){ // if data sent about stock by WC is strictly superior to 0 $product->set_status( ‘publish’ ); // change the product status } }

How to add woocommerce products header title in woocommerce_breadcrumb hook to function.php

I am supprised that this question still accepts answers once woocommerce is a plugin and out of the scope of this chat. Anyhow for what I have understood you want to show the product title on the woocommerce breadcrumb, Woocommerce breadcrumb already does that by default, there is no need of any changes, just remove … Read more