public function duplicate($new_product_id)
 {
     $new_fp = new Fancy_Product($new_product_id);
     foreach ($this->get_views() as $view) {
         $new_fp->add_view($view->title, $view->elements, $view->thumbnail, $view->view_order);
     }
 }
 public function create_views_from_template()
 {
     if (!isset($_POST['id']) || !isset($_POST['product_id'])) {
         exit;
     }
     check_ajax_referer('fpd_ajax_nonce', '_ajax_nonce');
     $id = trim($_POST['id']);
     $product_id = trim($_POST['product_id']);
     header('Content-Type: application/json');
     try {
         $views = json_decode(FPD_Admin_Template::get_views($id), true);
         $fancy_product = new Fancy_Product($product_id);
         $html = '';
         foreach ($views as $view) {
             $view_id = $fancy_product->add_view($view['title'], serialize($view['elements']), $view['thumbnail']);
             $html .= FPD_Admin_Manage_Fancy_Products::get_view_item_html($view_id, $view['thumbnail'], $view['title'], '');
         }
         echo json_encode(array('html' => $html, 'message' => __('Product successfully created!', 'radykal')));
     } catch (Exception $e) {
         echo json_encode(array('error' => 1, 'message' => __('Fancy Product could not be stored. Please try again!', 'radykal')));
     }
     die;
 }