// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
// js inside blog page
// shopping cart
frappe.provide("erpnext.shopping_cart");
var shopping_cart = erpnext.shopping_cart;
$.extend(shopping_cart, {
	show_error: function(title, text) {
		$("#cart-container").html('
' +
			title + '
' + text + '
\
			
\
				
\
					
' +
					(shipping_selector || '
%(description)s
') +
					'
\
				
\
			
\
			
\
				
%(formatted_tax_amount)s
\
			
\
		
");
					}
					$("#cart-error")
						.empty()
						.html(msg || frappe._("Something went wrong!"))
						.toggle(true);
				} else {
					$('.cart-container table').hide();
					$(btn).hide();
					window.location.href = '/orders/' + encodeURIComponent(r.message);
				}
			}
		});
	},
	request_quotation: function(btn) {
		return frappe.call({
			type: "POST",
			method: "erpnext.shopping_cart.cart.request_for_quotation",
			btn: btn,
			callback: function(r) {
				if(r.exc) {
					var msg = "";
					if(r._server_messages) {
						msg = JSON.parse(r._server_messages || []).join("
");
					}
					$("#cart-error")
						.empty()
						.html(msg || frappe._("Something went wrong!"))
						.toggle(true);
				} else {
					$('.cart-container table').hide();
					$(btn).hide();
					window.location.href = '/quotations/' + encodeURIComponent(r.message);
				}
			}
		});
	}
});
frappe.ready(function() {
	$(".cart-icon").hide();
	shopping_cart.bind_events();
});
function show_terms() {
	var html = $(".cart-terms").html();
	frappe.msgprint(html);
}