Save custom attributes of product in woocommerce

Finally I got it working with next code: $product = wc_get_product($productId); $attrName=”my_attribute”; $attrValue=”some value” $attr = new WC_Product_Attribute(); $attr->set_name( $attrName ); $attr->set_options( [$attrValue] ); $attr->set_visible(1); $attr->set_variation(1); $attr->set_position(0); $attr->set_id( 0 ); $attrs[$attrName] = $attr; $product->set_attributes($attrs); $product->save();

Woo Related Products How to override the plugin script?

Copy js file to: wp-content/themes/child-storefront-theme/assets/js/woo-related-products-refresh-on-reload/woo-related-products-public.js function custom_woo_related_products() { wp_dequeue_script(‘woo-related-products’); wp_enqueue_script(‘custom-woo-related-products’, get_stylesheet_directory_uri().’/assets/js/woo-related-products-refresh-on-reload/woo-related-products-public.js’, array(‘jquery’)); } add_action(‘wp_enqueue_scripts’, ‘custom_woo_related_products’, 100); Why 100? To be dequeued, the script must have been enqueued. Attempting to dequeue a script before the script is enqueued will have no effect.