/*
 * This file is part of EC-CUBE
 *
 * This is a collection of custom-made javascript functions
 * (this file must be included in the site frame template - /data/Smarty/templates/<template_name>/site_frame.tpl)
 *
 */

// Add product to wishlist
//function addToWishlist(product_id) {
    // Make AJAX call to add product to wishlist in database
    // Display confirmation that product was added to wishlist
//    $.ajax({
//        type: "POST",
//        url: site_url+"custom/query_db.php",
//        dataType: "html",
//        data: "action=wishlist_add&product_id="+product_id,
//        success: function(data){
//            alert( "Product added to wishlist: " + data );
//        }
//    });
//}

function addToWishlist(product_id) {
    $.getJSON(site_url+"custom/query_db.php", { action: "wishlist_add", product_id: product_id }, function(json){
      if (json.result[0].status == 'success') {
        alert(json.result[0].message);
      } else if (json.result[0].status == 'failure') {
        alert(json.result[0].message);
      } else {
        alert("エラーがおこりました。お気に入りリストに追加出来ませんでした。");
      }
    });
}
