Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Danny

    (@daining1298)

    The code is like this, but quite strange, when create a new product, its short description is not set. But if I copy from one existing product, it does not copy existing product’s short description, and use “shortdescription” as copied product’s short description.

    add_action( 'save_post_product', 'auto_add_product_attributes', 50, 3 );
    function auto_add_product_attributes( $post_id, $post, $update  ) {
        // Exit if it's an update
        if( $update )
            return $post_id;
        $product = wc_get_product( $post_id );
        $short_description = "shortdescription";
        $product->set_short_description($short_description);
        $product->save(); // Save the product
    	
        return $post_id;
    }
    • This reply was modified 3 years, 1 month ago by Danny.
    Mirko P.

    (@rainfallnixfig)

    Hi there,

    Thanks for reaching out.

    This is a more development-oriented question. I’ll go ahead and leave this thread open for a while in case anyone else wants to chime in, but in the meantime, I can also recommend the following resources for help:

    Cheers.

    Mirko P.

    (@rainfallnixfig)

    Hi there,

    We’ve not seen any activity on this thread for a while, so I’m marking this thread as resolved.

    Hopefully, you were able to find a solution and the above resources for developers were helpful. If you have further questions, please feel free to open a new topic.

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Set product description and short description’ is closed to new replies.