Hi @chosendaone
I change the attribute color of the product to black through the API, then on the product edit page and on the product page these changes are visible, but WP Gridbuilder filters will not notice this change. The same is true for ACF fields. Clicking update solves the problem.
It seems like the issue might be related to the caching mechanism of the plugins you’re using, not updating immediately after a change is made via the API.
This is a third-party plugin, and we don’t provide help & support for 3rd-party plugins or themes as they’re outside our support scope. It would be best to reach out to the WP Gridbuilder and ACF plugin developer for further assistance.
Additionally, the code snippet you’ve shared seems correct. It’s trying to manually update the product and clear the cache after a product is updated via the REST API. However, the issue might be related to the sequence of actions or the specific actions you’re trying to use. You can try the following:
add_action('woocommerce_rest_insert_product', 'handle_product_update', 10, 3);
function handle_product_update($product, $request, $creating) {
$product_id = $product->get_id();
wp_update_post(array('ID' => $product_id));
wc_delete_product_transients($product_id);
if (function_exists('acf_save_post')) {
acf_save_post($product_id);
}
do_action('woocommerce_update_product', $product_id);
$attributes = $product->get_attributes();
if (!empty($attributes)) {
foreach ($attributes as $attribute) {
if (is_object($attribute) && method_exists($attribute, 'get_id')) {
wp_update_term($attribute->get_id(), $attribute->get_taxonomy());
}
}
}
flush_rewrite_rules();
}
Please note that writing or providing custom code is not within the scope of our support policy. If you are still having problems, we recommend asking development questions on the #developers channel of the WooCommerce Community Slack. Many of our developers hang out there and will be able to offer insights into your question. You can also seek help from the following:
I wish I could help more, but hopefully, this gets you going in the right direction to get the job done.