• Resolved NSPT

    (@nsptfr)


    Hello,

    I’m using add_action( ‘woocommerce_product_data_panels’, ” ); to modify some product metas while updating it.
    I wrote some code using the set_attributes() methode from WC_Product classes, but after saving the product using the save() methode, nothing appears in the Attributes pannel,

    Can you help me please ?

    Regards

Viewing 2 replies - 1 through 2 (of 2 total)
  • con

    (@conschneider)

    Engineer

    Hi there,

    Here is an approach that uses wp_ajax_woocommerce_save_attributes
    https://stackoverflow.com/questions/52283313/how-can-i-save-a-custom-field-of-an-attribute-in-woocommerce – maybe you can use this as a starting point.

    Kind regards,

    Thread Starter NSPT

    (@nsptfr)

    Hello,

    I’ll just give up… I’m tiered of working on that.

    mikejolley tells on github that ‘Using wp_ajax hooks is not ideal.’ https://github.com/woocommerce/woocommerce/issues/16934
    The exemple use neither the “_product_attributes” variable, or the “WC_product->set_attributes()” methode. And I don’t understand why.
    Even if I update “_product_attributes” variable, it is not a unique field and will only result on an other stack impossible to get.

    What I don’t understand is what blocking me from setting the attributes with the dedicated methode of the class… I can do anything else like setting tags and categories, but set_attributes always result in nothing.

    Thanks,

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘programmatically updating product’s attributes’ is closed to new replies.