• I am new to wordpress / woocommerce development and I hope I have posted this in the correct forum.

    I am writing a PHP sever side script to integrate a woocommerce website with a point of sale system. The POS regularly sends the product inventory as a text file and I am processing this file to create / update the products in woocommerce.

    I am having trouble setting the Product Categories for the products via the PHP script.

    I am using the function wp_set_object_terms as follows:

    wp_set_object_terms ($post_id, 'Brands', 'product_cat', 'true');

    This appears to be working correctly in that the ‘Brands’ Product Category category is ‘ticked’ when editing the product within the woocommerce backend product editor, but it doesn’t display on the website when viewing the ‘Brands’ category.

    However, if I then manually press the update button within woocommerce back end product editor for that product – then everything works as expected and the product appears in the ‘Brands’ category on the website.

    The ‘Update’ button in the backend is clearly doing something that I’m not !

    Any guidance would be greatly appreciated.

    Thanks

  • The topic ‘Post not updating categories properly from PHP script’ is closed to new replies.