shopp_product_saved

Called after product save in product editor.

add_action('shopp_product_saved', [callback] );

@param Product $Product the Product object.

Description

Triggered after a product is saved to the database from the product editor. The entire Product object is passed as an argument to the callback function.

Example

add_action('shopp_product_saved', 'my_function');
function my_function ( $Product ) {
// do stuff
}

See Also

  1. Avatar of James

    Note, if you’re calling this action in a meta and expecting to save your data in the typical manor..

    add_action('shopp_product_saved', array('my_meta_boxes', 'save_meta_box_data'));
    
    public function save_meta_box_data ($post_id) {
         echo $post_id ; //This will not work
    }
    
    //Instead do this
    public function save_meta_box_data () {
         echo shopp('product', 'get-id'); //This will work
    }
    

    I’m guessing the action runs too early for $post to be populated or something..

    May 23rd   #

  2. Avatar of Hiranthi

    As the doc mentions the entire $Product object is passed on to the function that hooks into the shopp_product_saved action, it doesn’t work as the save_post action of WP itself (that one does only get $post_id).

    To retrieve the post ID (which is the product ID) you can $Product->id inside your function. To get the $post object you could do something like this:

    $post = get_post($Product->id);
    
    June 20th   #

  3. Avatar of Clifton Griffin

    Warning: the $Product object passed to your function may have pre-save data. To protect against this, add this line:

    function my_product_save_func($Product) {
        // Load fresh data
        $Product->load_data();
    }
    
    November 27th   #

You must be logged in to post a comment.

© Ingenesis Limited. Shopp™ is a registered trademark of Ingenesis Limited.

Skip to toolbar