• I am able to populate a custom field called _affiliate_link in the default post type using:

    $.ajax({
        url: wpApiSettings.root + 'wp/v2/posts',
        method: 'POST',
        beforeSend: function (xhr) {
            xhr.setRequestHeader('X-WP-Nonce', wpApiSettings.nonce);
        },
        data: {
            'title': 'New Post Title',
            'fields': {
                '_affiliate_link': 'testing-123'
            }
        }
    }).done(function (response) {
        console.log(response);
    });
    

    But, I cannot update the same custom field for Products:

    
    $.ajax({
        url: wpApiSettings.root + 'wc/v3/products?consumer_key=ck_removed_for_post&consumer_secret=cs_remove_for_post',
        method: 'POST',
        beforeSend: function (xhr) {
            xhr.setRequestHeader('X-WP-Nonce', wpApiSettings.nonce);
        },
        data: {
            'name': 'New Post Title',
            'fields': {
                '_affiliate_link': 'testing-123'
            }
        }
    }).done(function (response) {
        console.log(response);
    });
    

    I get this in the response:

    
    acf:
    _affiliate_link: null
    

    Am I missing anything to update a custom field for a product?

    • This topic was modified 4 years, 2 months ago by whurst.
  • The topic ‘WooCommerce Product ACF not updating’ is closed to new replies.