'
+ end
+
+end
diff --git a/plugins/shopping_cart/lib/shopping_cart_plugin/mailer.rb b/plugins/shopping_cart/lib/shopping_cart_plugin/mailer.rb
new file mode 100644
index 0000000..140f6c7
--- /dev/null
+++ b/plugins/shopping_cart/lib/shopping_cart_plugin/mailer.rb
@@ -0,0 +1,28 @@
+include ApplicationHelper
+
+class ShoppingCartPlugin::Mailer < ActionMailer::Base
+
+ prepend_view_path(ShoppingCartPlugin.root_path+'/views')
+
+ def customer_notification(customer, supplier, items)
+ recipients customer[:email]
+ from supplier.contact_email
+ subject _("[%s] Your buy request was performed successfully.") % supplier[:name]
+ content_type 'text/html'
+ body :customer => customer,
+ :supplier => supplier,
+ :items => items,
+ :environment => supplier.environment
+ end
+
+ def supplier_notification(customer, supplier, items)
+ recipients supplier.contact_email
+ from customer[:email]
+ subject _("[%s] You have a new buy request from %s.") % [supplier.environment.name, customer[:name]]
+ content_type 'text/html'
+ body :customer => customer,
+ :supplier => supplier,
+ :items => items,
+ :environment => supplier.environment
+ end
+end
diff --git a/plugins/shopping_cart/public/cart.js b/plugins/shopping_cart/public/cart.js
index 91828bb..0fd02ec 100644
--- a/plugins/shopping_cart/public/cart.js
+++ b/plugins/shopping_cart/public/cart.js
@@ -241,25 +241,17 @@ function Cart(config) {
});
}
- Cart.send_request = function(button) {
- var params = {};
- params['name'] = $('#name', button.parentNode).val();
- params['email'] = $('#email', button.parentNode).val();
- params['contact_phone'] = $('#contact_phone', button.parentNode).val();
- params['address'] = $('#address', button.parentNode).val();
- Cart.instance.send_request(params);
+ Cart.send_request = function(form) {
+ Cart.instance.send_request($(form).serialize());
+ return false;
}
- Cart.prototype.send_request = function(p) {
- params = "?";
- for( var attribute in p ) {
- var value = p[attribute];
- params += attribute+'='+value+'&';
- }
- params = params.substring(0, params.length-1);
+ Cart.prototype.send_request = function(params) {
var me = this;
$.ajax({
- url: '/profile/'+ me.enterprise +'/plugins/shopping_cart/send_request'+params,
+ type: 'POST',
+ url: '/profile/'+ me.enterprise +'/plugins/shopping_cart/send_request',
+ data: params,
dataType: 'json',
success: function(data, status, ajax){
if ( !data.ok ) display_notice(data.error.message);
diff --git a/plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb b/plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb
new file mode 100644
index 0000000..73d3419
--- /dev/null
+++ b/plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb
@@ -0,0 +1,24 @@
+<% environment = @environment %>
+
<%= _('Hi %s!') % @customer[:name] %>
+
+<%= _('This is a notification e-mail about your buy request on %s.') % link_to(@supplier.name, @supplier.url) %>
+<%= _('The supplier already received your buy request and may contact you for confirmation.') %>
+<%= _('Please check if your information below is correct:') %>
+