Too few arguments to function woocommerce_update_product_acf_save_post(), 1 pass
-
Hi,
I have an action in my functions.php to inform subscribers of an product update. I have a working function that accepts 2 arguments ($product_id and $product). However when I
press update on a product an e-mail goes out with the old values of my ACFs.I found a topic here from someone with the same issue, but this solution won’t accept 2 arguments (or my syntax is wrong).
So this works (with 1 argument)
add_action('acf/save_post', 'woocommerce_update_product_acf_save_post', 1000, 1); function woocommerce_update_product_acf_save_post( $product_id ) { if (get_post_type($product_id) == "product") { remove_action('acf/save_post', 'woocommerce_update_product_acf_save_post'); update_on_product_save( $product_id ); } } function update_on_product_save($product_id) {
when I add the second argument however
add_action('acf/save_post', 'woocommerce_update_product_acf_save_post', 1000, 2); function woocommerce_update_product_acf_save_post( $product_id, $product ) { if (get_post_type($product_id) == "product") { remove_action('acf/save_post', 'woocommerce_update_product_acf_save_post'); update_on_product_save( $product_id, $product ); } } function update_on_product_save($product_id, $product ) {
I get an error;
Uncaught ArgumentCountError: Too few arguments to function woocommerce_update_product_acf_save_post(), 1 passed in /home/domain/public_html/wp-includes/class-wp-hook.php on line 307 and exactly 2 expected in /home/domain/public_html/wp-content/themes/hello-elementor-child/functions.php:50, referer: https://www.domain.com/wp-admin/post.php?post=7398&action=edit
Any tips in resolving this?
- The topic ‘Too few arguments to function woocommerce_update_product_acf_save_post(), 1 pass’ is closed to new replies.