LemonStand Documentation

shop:onAfterProductFileAdded event

The shop:onAfterProductFileAdded event is triggered after a file is added to the product on the Product Details page. Please read this article to learn about implementing the file uploading on the product details page. The event handler should accept two parameters: the product object (Shop_Product) and the file object (Db_File). 

Event handler example:

public function subscribeEvents()
{
  Backend::$events->addEvent('shop:onAfterProductFileAdded', $this, 'after_file_added');
}
 
public function after_file_added($product, $new_file)
{
  // Replace existing files with the new one
  $files = $product->list_uploaded_files();
  foreach ($files as $file)
  {
    if ($file->id != $new_file->id)
      $file->delete();
  }
}

Next: shop:onOrderError event
Previous: shop:onBeforeProductFileAdded event
Return to Handling LemonStand events