Commit cb9b3dd2667e0bc72f88fe87af19bd35d6a174c1
1 parent
46f79722
Exists in
master
and in
28 other branches
Finish moving everything to /plugins/shopping_cart
Showing
9 changed files
with
87 additions
and
86 deletions
Show diff stats
plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb
@@ -3,6 +3,7 @@ require 'base64' | @@ -3,6 +3,7 @@ require 'base64' | ||
3 | class ShoppingCartPluginController < PublicController | 3 | class ShoppingCartPluginController < PublicController |
4 | 4 | ||
5 | include ShoppingCartPlugin::CartHelper | 5 | include ShoppingCartPlugin::CartHelper |
6 | + helper ShoppingCartPlugin::CartHelper | ||
6 | 7 | ||
7 | append_view_path File.join(File.dirname(__FILE__) + '/../views') | 8 | append_view_path File.join(File.dirname(__FILE__) + '/../views') |
8 | before_filter :login_required, :only => [] | 9 | before_filter :login_required, :only => [] |
@@ -10,14 +11,19 @@ class ShoppingCartPluginController < PublicController | @@ -10,14 +11,19 @@ class ShoppingCartPluginController < PublicController | ||
10 | before_filter :login_required, :only => [] | 11 | before_filter :login_required, :only => [] |
11 | 12 | ||
12 | def get | 13 | def get |
13 | - has_products = !cart.nil? && (cart[:items].keys.size > 0) || false | ||
14 | - config = { 'enterprise' => profile.identifier, 'hasProducts' => has_products } | 14 | + config = |
15 | + if cart.nil? | ||
16 | + { 'enterprise_id' => nil, 'hasProducts' => false } | ||
17 | + else | ||
18 | + { 'enterprise_id' => cart[:enterprise_id], 'hasProducts' => (cart[:items].keys.size > 0) } | ||
19 | + end | ||
15 | render :text => config.to_json | 20 | render :text => config.to_json |
16 | end | 21 | end |
17 | 22 | ||
18 | def add | 23 | def add |
19 | - self.cart = { :enterprise_id => profile.id, :items => {} } if self.cart.nil? | ||
20 | - if validate_same_enterprise && product = validate_enterprise_has_product(params[:id]) | 24 | + product = find_product(params[:id]) |
25 | + if product && enterprise = validate_same_enterprise(product) | ||
26 | + self.cart = { :enterprise_id => enterprise.id, :items => {} } if self.cart.nil? | ||
21 | self.cart[:items][product.id] = 0 if self.cart[:items][product.id].nil? | 27 | self.cart[:items][product.id] = 0 if self.cart[:items][product.id].nil? |
22 | self.cart[:items][product.id] += 1 | 28 | self.cart[:items][product.id] += 1 |
23 | render :text => { | 29 | render :text => { |
@@ -26,7 +32,7 @@ class ShoppingCartPluginController < PublicController | @@ -26,7 +32,7 @@ class ShoppingCartPluginController < PublicController | ||
26 | :products => [{ | 32 | :products => [{ |
27 | :id => product.id, | 33 | :id => product.id, |
28 | :name => product.name, | 34 | :name => product.name, |
29 | - :price => get_price(product, profile.environment), | 35 | + :price => get_price(product, enterprise.environment), |
30 | :description => product.description, | 36 | :description => product.description, |
31 | :picture => product.default_image(:minor), | 37 | :picture => product.default_image(:minor), |
32 | :quantity => self.cart[:items][product.id] | 38 | :quantity => self.cart[:items][product.id] |
@@ -54,7 +60,7 @@ class ShoppingCartPluginController < PublicController | @@ -54,7 +60,7 @@ class ShoppingCartPluginController < PublicController | ||
54 | product = Product.find(id) | 60 | product = Product.find(id) |
55 | { :id => product.id, | 61 | { :id => product.id, |
56 | :name => product.name, | 62 | :name => product.name, |
57 | - :price => get_price(product, profile.environment), | 63 | + :price => get_price(product, product.enterprise.environment), |
58 | :description => product.description, | 64 | :description => product.description, |
59 | :picture => product.default_image(:minor), | 65 | :picture => product.default_image(:minor), |
60 | :quantity => quantity | 66 | :quantity => quantity |
@@ -63,7 +69,6 @@ class ShoppingCartPluginController < PublicController | @@ -63,7 +69,6 @@ class ShoppingCartPluginController < PublicController | ||
63 | render :text => { | 69 | render :text => { |
64 | :ok => true, | 70 | :ok => true, |
65 | :error => {:code => 0}, | 71 | :error => {:code => 0}, |
66 | - :enterprise => Enterprise.find(self.cart[:enterprise_id]).identifier, | ||
67 | :products => products | 72 | :products => products |
68 | }.to_json | 73 | }.to_json |
69 | end | 74 | end |
@@ -93,16 +98,17 @@ class ShoppingCartPluginController < PublicController | @@ -93,16 +98,17 @@ class ShoppingCartPluginController < PublicController | ||
93 | end | 98 | end |
94 | 99 | ||
95 | def buy | 100 | def buy |
96 | - @environment = profile.environment | ||
97 | @cart = cart | 101 | @cart = cart |
102 | + @enterprise = environment.enterprises.find(cart[:enterprise_id]) | ||
98 | render :layout => false | 103 | render :layout => false |
99 | end | 104 | end |
100 | 105 | ||
101 | def send_request | 106 | def send_request |
102 | - register_order(params[:customer], self.cart[:items]) | 107 | + register_order(params[:customer], self.cart[:items]) |
103 | begin | 108 | begin |
104 | - ShoppingCartPlugin::Mailer.deliver_customer_notification(params[:customer], profile, self.cart[:items]) | ||
105 | - ShoppingCartPlugin::Mailer.deliver_supplier_notification(params[:customer], profile, self.cart[:items]) | 109 | + enterprise = Enterprise.find(cart[:enterprise_id]) |
110 | + ShoppingCartPlugin::Mailer.deliver_customer_notification(params[:customer], enterprise, self.cart[:items]) | ||
111 | + ShoppingCartPlugin::Mailer.deliver_supplier_notification(params[:customer], enterprise, self.cart[:items]) | ||
106 | render :text => { | 112 | render :text => { |
107 | :ok => true, | 113 | :ok => true, |
108 | :message => _('Request sent successfully. Check your email.'), | 114 | :message => _('Request sent successfully. Check your email.'), |
@@ -163,8 +169,8 @@ class ShoppingCartPluginController < PublicController | @@ -163,8 +169,8 @@ class ShoppingCartPluginController < PublicController | ||
163 | 169 | ||
164 | private | 170 | private |
165 | 171 | ||
166 | - def validate_same_enterprise | ||
167 | - if profile.id != self.cart[:enterprise_id] | 172 | + def validate_same_enterprise(product) |
173 | + if self.cart && self.cart[:enterprise_id] && product.enterprise_id != self.cart[:enterprise_id] | ||
168 | render :text => { | 174 | render :text => { |
169 | :ok => false, | 175 | :ok => false, |
170 | :error => { | 176 | :error => { |
@@ -172,9 +178,9 @@ class ShoppingCartPluginController < PublicController | @@ -172,9 +178,9 @@ class ShoppingCartPluginController < PublicController | ||
172 | :message => _("Can't join items from different enterprises.") | 178 | :message => _("Can't join items from different enterprises.") |
173 | } | 179 | } |
174 | }.to_json | 180 | }.to_json |
175 | - return false | 181 | + return nil |
176 | end | 182 | end |
177 | - true | 183 | + product.enterprise |
178 | end | 184 | end |
179 | 185 | ||
180 | def validate_cart_presence | 186 | def validate_cart_presence |
@@ -191,10 +197,11 @@ class ShoppingCartPluginController < PublicController | @@ -191,10 +197,11 @@ class ShoppingCartPluginController < PublicController | ||
191 | true | 197 | true |
192 | end | 198 | end |
193 | 199 | ||
194 | - def validate_enterprise_has_product(id) | 200 | + def find_product(id) |
195 | begin | 201 | begin |
196 | - product = profile.products.find(id) | ||
197 | - rescue | 202 | + $stderr.puts '*********** ' + id.inspect |
203 | + product = Product.find(id) | ||
204 | + rescue ActiveRecord::RecordNotFound | ||
198 | render :text => { | 205 | render :text => { |
199 | :ok => false, | 206 | :ok => false, |
200 | :error => { | 207 | :error => { |
@@ -243,7 +250,7 @@ class ShoppingCartPluginController < PublicController | @@ -243,7 +250,7 @@ class ShoppingCartPluginController < PublicController | ||
243 | new_items[id] = {:quantity => quantity, :price => price, :name => product.name} | 250 | new_items[id] = {:quantity => quantity, :price => price, :name => product.name} |
244 | end | 251 | end |
245 | ShoppingCartPlugin::PurchaseOrder.create!( | 252 | ShoppingCartPlugin::PurchaseOrder.create!( |
246 | - :seller => profile, | 253 | + :seller => Enterprise.find(cart[:enterprise_id]), |
247 | :customer => user, | 254 | :customer => user, |
248 | :status => ShoppingCartPlugin::PurchaseOrder::Status::OPENED, | 255 | :status => ShoppingCartPlugin::PurchaseOrder::Status::OPENED, |
249 | :products_list => new_items, | 256 | :products_list => new_items, |
@@ -277,7 +284,7 @@ class ShoppingCartPluginController < PublicController | @@ -277,7 +284,7 @@ class ShoppingCartPluginController < PublicController | ||
277 | else | 284 | else |
278 | cookies[cookie_key] = { | 285 | cookies[cookie_key] = { |
279 | :value => Base64.encode64(@cart.to_yaml), | 286 | :value => Base64.encode64(@cart.to_yaml), |
280 | - :path => "/profile/#{profile.identifier}/plugin/shopping_cart" | 287 | + :path => "/plugin/shopping_cart" |
281 | } | 288 | } |
282 | end | 289 | end |
283 | end | 290 | end |
plugins/shopping_cart/lib/shopping_cart_plugin.rb
@@ -11,12 +11,13 @@ class ShoppingCartPlugin < Noosfero::Plugin | @@ -11,12 +11,13 @@ class ShoppingCartPlugin < Noosfero::Plugin | ||
11 | _("A shopping basket feature for enterprises") | 11 | _("A shopping basket feature for enterprises") |
12 | end | 12 | end |
13 | 13 | ||
14 | - def add_to_cart_button(item, enterprise = context.profile) | 14 | + def add_to_cart_button(item) |
15 | + enterprise = item.enterprise | ||
15 | if enterprise.shopping_cart && item.available | 16 | if enterprise.shopping_cart && item.available |
16 | lambda { | 17 | lambda { |
17 | link_to(_('Add to basket'), "add:#{item.name}", | 18 | link_to(_('Add to basket'), "add:#{item.name}", |
18 | :class => 'cart-add-item', | 19 | :class => 'cart-add-item', |
19 | - :onclick => "Cart.addItem('#{enterprise.identifier}', #{item.id}, this); return false" | 20 | + :onclick => "Cart.addItem(#{item.id}, this); return false" |
20 | ) | 21 | ) |
21 | } | 22 | } |
22 | end | 23 | end |
plugins/shopping_cart/lib/shopping_cart_plugin/mailer.rb
1 | class ShoppingCartPlugin::Mailer < Noosfero::Plugin::MailerBase | 1 | class ShoppingCartPlugin::Mailer < Noosfero::Plugin::MailerBase |
2 | 2 | ||
3 | + include ShoppingCartPlugin::CartHelper | ||
4 | + | ||
3 | def customer_notification(customer, supplier, items) | 5 | def customer_notification(customer, supplier, items) |
4 | domain = supplier.hostname || supplier.environment.default_hostname | 6 | domain = supplier.hostname || supplier.environment.default_hostname |
5 | recipients customer[:email] | 7 | recipients customer[:email] |
plugins/shopping_cart/public/cart.js
@@ -11,10 +11,9 @@ function Cart(config) { | @@ -11,10 +11,9 @@ function Cart(config) { | ||
11 | $(".cart-buy", this.cartElem).button({ icons: { primary: 'ui-icon-cart'} }); | 11 | $(".cart-buy", this.cartElem).button({ icons: { primary: 'ui-icon-cart'} }); |
12 | if (!this.empty) { | 12 | if (!this.empty) { |
13 | $(this.cartElem).show(); | 13 | $(this.cartElem).show(); |
14 | - this.enterprise = config.enterprise; | ||
15 | me = this; | 14 | me = this; |
16 | $.ajax({ | 15 | $.ajax({ |
17 | - url: '/profile/'+ this.enterprise +'/plugin/shopping_cart/visibility', | 16 | + url: '/plugin/shopping_cart/visibility', |
18 | dataType: 'json', | 17 | dataType: 'json', |
19 | success: function(data, status, ajax){ | 18 | success: function(data, status, ajax){ |
20 | me.visible = /^true$/i.test(data); | 19 | me.visible = /^true$/i.test(data); |
@@ -25,7 +24,7 @@ function Cart(config) { | @@ -25,7 +24,7 @@ function Cart(config) { | ||
25 | alert('Visibility - HTTP '+status+': '+errorThrown); | 24 | alert('Visibility - HTTP '+status+': '+errorThrown); |
26 | } | 25 | } |
27 | }); | 26 | }); |
28 | - $(".cart-buy", this.cartElem).colorbox({href: '/profile/' + this.enterprise + '/plugin/shopping_cart/buy'}); | 27 | + $(".cart-buy", this.cartElem).colorbox({ href: '/plugin/shopping_cart/buy' }); |
29 | } | 28 | } |
30 | } | 29 | } |
31 | 30 | ||
@@ -34,7 +33,7 @@ function Cart(config) { | @@ -34,7 +33,7 @@ function Cart(config) { | ||
34 | Cart.prototype.listProducts = function() { | 33 | Cart.prototype.listProducts = function() { |
35 | var me = this; | 34 | var me = this; |
36 | $.ajax({ | 35 | $.ajax({ |
37 | - url: '/profile/'+ this.enterprise +'/plugin/shopping_cart/list', | 36 | + url: '/plugin/shopping_cart/list', |
38 | dataType: 'json', | 37 | dataType: 'json', |
39 | success: function(data, ststus, ajax){ | 38 | success: function(data, ststus, ajax){ |
40 | if ( !data.ok ) alert(data.error.message); | 39 | if ( !data.ok ) alert(data.error.message); |
@@ -61,7 +60,7 @@ function Cart(config) { | @@ -61,7 +60,7 @@ function Cart(config) { | ||
61 | '<span class="item-name">'+ item.name +'</span>' + | 60 | '<span class="item-name">'+ item.name +'</span>' + |
62 | '<div class="item-price">' + | 61 | '<div class="item-price">' + |
63 | '<input size="1" value="'+item.quantity+'" />'+ (item.price ? '× '+ item.price : '') +'</div>' + | 62 | '<input size="1" value="'+item.quantity+'" />'+ (item.price ? '× '+ item.price : '') +'</div>' + |
64 | - ' <a href="remove:'+item.name+'" onclick="Cart.removeItem(\''+this.enterprise+'\', '+item.id+'); return false"' + | 63 | + ' <a href="remove:'+item.name+'" onclick="Cart.removeItem('+item.id+'); return false"' + |
65 | ' class="button icon-remove"><span>remove</span></a>' | 64 | ' class="button icon-remove"><span>remove</span></a>' |
66 | ).appendTo(li); | 65 | ).appendTo(li); |
67 | var input = $("input", li)[0]; | 66 | var input = $("input", li)[0]; |
@@ -100,7 +99,7 @@ function Cart(config) { | @@ -100,7 +99,7 @@ function Cart(config) { | ||
100 | var me = this; | 99 | var me = this; |
101 | if( quantity == NaN ) return input.value = input.lastValue; | 100 | if( quantity == NaN ) return input.value = input.lastValue; |
102 | $.ajax({ | 101 | $.ajax({ |
103 | - url: '/profile/'+ this.enterprise +'/plugin/shopping_cart/update_quantity/'+ itemId +'?quantity='+ quantity, | 102 | + url: '/plugin/shopping_cart/update_quantity/'+ itemId +'?quantity='+ quantity, |
104 | dataType: 'json', | 103 | dataType: 'json', |
105 | success: function(data, status, ajax){ | 104 | success: function(data, status, ajax){ |
106 | if ( !data.ok ) { | 105 | if ( !data.ok ) { |
@@ -132,8 +131,7 @@ function Cart(config) { | @@ -132,8 +131,7 @@ function Cart(config) { | ||
132 | this.updateTotal(); | 131 | this.updateTotal(); |
133 | } | 132 | } |
134 | 133 | ||
135 | - Cart.addItem = function(enterprise, itemId, link) { | ||
136 | - // on the future, the instance may be found by the enterprise identifier. | 134 | + Cart.addItem = function(itemId, link) { |
137 | link.intervalId = setInterval(function() { | 135 | link.intervalId = setInterval(function() { |
138 | steps = ['w', 'n', 'e', 's']; | 136 | steps = ['w', 'n', 'e', 's']; |
139 | if( !link.step || link.step==3 ) link.step = 0; | 137 | if( !link.step || link.step==3 ) link.step = 0; |
@@ -144,18 +142,13 @@ function Cart(config) { | @@ -144,18 +142,13 @@ function Cart(config) { | ||
144 | clearInterval(link.intervalId); | 142 | clearInterval(link.intervalId); |
145 | $(link).button({ icons: { primary: 'ui-icon-cart'}, disable: false }); | 143 | $(link).button({ icons: { primary: 'ui-icon-cart'}, disable: false }); |
146 | }; | 144 | }; |
147 | - this.instance.addItem(enterprise, itemId, stopBtLoading); | 145 | + this.instance.addItem(itemId, stopBtLoading); |
148 | } | 146 | } |
149 | 147 | ||
150 | - Cart.prototype.addItem = function(enterprise, itemId, callback) { | ||
151 | - if(!this.enterprise) { | ||
152 | - this.enterprise = enterprise; | ||
153 | - $(".cart-buy", this.cartElem).colorbox({href: '/profile/' + this.enterprise + '/plugin/shopping_cart/buy'}); | ||
154 | -// $(this.cartElem).show(); | ||
155 | - } | 148 | + Cart.prototype.addItem = function(itemId, callback) { |
156 | var me = this; | 149 | var me = this; |
157 | $.ajax({ | 150 | $.ajax({ |
158 | - url: '/profile/'+ enterprise +'/plugin/shopping_cart/add/'+ itemId, | 151 | + url: '/plugin/shopping_cart/add/'+ itemId, |
159 | dataType: 'json', | 152 | dataType: 'json', |
160 | success: function(data, status, ajax){ | 153 | success: function(data, status, ajax){ |
161 | if ( !data.ok ) alert(data.error.message); | 154 | if ( !data.ok ) alert(data.error.message); |
@@ -169,16 +162,16 @@ function Cart(config) { | @@ -169,16 +162,16 @@ function Cart(config) { | ||
169 | }); | 162 | }); |
170 | } | 163 | } |
171 | 164 | ||
172 | - Cart.removeItem = function(enterprise, itemId) { | 165 | + Cart.removeItem = function(itemId) { |
173 | var message = this.instance.cartElem.getAttribute('data-l10nRemoveItem'); | 166 | var message = this.instance.cartElem.getAttribute('data-l10nRemoveItem'); |
174 | - if( confirm(message) ) this.instance.removeItem(enterprise, itemId); | 167 | + if( confirm(message) ) this.instance.removeItem(itemId); |
175 | } | 168 | } |
176 | 169 | ||
177 | - Cart.prototype.removeItem = function(enterprise, itemId) { | 170 | + Cart.prototype.removeItem = function(itemId) { |
178 | if ($("li", this.itemsBox).size() < 2) return this.clean(); | 171 | if ($("li", this.itemsBox).size() < 2) return this.clean(); |
179 | var me = this; | 172 | var me = this; |
180 | $.ajax({ | 173 | $.ajax({ |
181 | - url: '/profile/'+ enterprise +'/plugin/shopping_cart/remove/'+ itemId, | 174 | + url: '/plugin/shopping_cart/remove/'+ itemId, |
182 | dataType: 'json', | 175 | dataType: 'json', |
183 | success: function(data, status, ajax){ | 176 | success: function(data, status, ajax){ |
184 | if ( !data.ok ) alert(data.error.message); | 177 | if ( !data.ok ) alert(data.error.message); |
@@ -200,7 +193,7 @@ function Cart(config) { | @@ -200,7 +193,7 @@ function Cart(config) { | ||
200 | 193 | ||
201 | Cart.prototype.show = function() { | 194 | Cart.prototype.show = function() { |
202 | $.ajax({ | 195 | $.ajax({ |
203 | - url: '/profile/'+ this.enterprise +'/plugin/shopping_cart/show', | 196 | + url: '/plugin/shopping_cart/show', |
204 | dataType: 'json', | 197 | dataType: 'json', |
205 | cache: false, | 198 | cache: false, |
206 | error: function(ajax, status, errorThrown) { | 199 | error: function(ajax, status, errorThrown) { |
@@ -215,7 +208,7 @@ function Cart(config) { | @@ -215,7 +208,7 @@ function Cart(config) { | ||
215 | } | 208 | } |
216 | Cart.prototype.hide = function() { | 209 | Cart.prototype.hide = function() { |
217 | $.ajax({ | 210 | $.ajax({ |
218 | - url: '/profile/'+ this.enterprise +'/plugin/shopping_cart/hide', | 211 | + url: '/plugin/shopping_cart/hide', |
219 | dataType: 'json', | 212 | dataType: 'json', |
220 | cache: false, | 213 | cache: false, |
221 | error: function(ajax, status, errorThrown) { | 214 | error: function(ajax, status, errorThrown) { |
@@ -252,7 +245,7 @@ function Cart(config) { | @@ -252,7 +245,7 @@ function Cart(config) { | ||
252 | Cart.prototype.clean = function() { | 245 | Cart.prototype.clean = function() { |
253 | var me = this; | 246 | var me = this; |
254 | $.ajax({ | 247 | $.ajax({ |
255 | - url: '/profile/'+ me.enterprise +'/plugin/shopping_cart/clean', | 248 | + url: '/plugin/shopping_cart/clean', |
256 | dataType: 'json', | 249 | dataType: 'json', |
257 | success: function(data, status, ajax){ | 250 | success: function(data, status, ajax){ |
258 | if ( !data.ok ) alert(data.error.message); | 251 | if ( !data.ok ) alert(data.error.message); |
@@ -261,7 +254,6 @@ function Cart(config) { | @@ -261,7 +254,6 @@ function Cart(config) { | ||
261 | $(me.cartElem).slideUp(500, function() { | 254 | $(me.cartElem).slideUp(500, function() { |
262 | $(me.itemsBox).empty(); | 255 | $(me.itemsBox).empty(); |
263 | me.hide(); | 256 | me.hide(); |
264 | - me.enterprise = null; | ||
265 | me.updateTotal(); | 257 | me.updateTotal(); |
266 | me.empty = true; | 258 | me.empty = true; |
267 | }); | 259 | }); |
@@ -284,7 +276,7 @@ function Cart(config) { | @@ -284,7 +276,7 @@ function Cart(config) { | ||
284 | var me = this; | 276 | var me = this; |
285 | $.ajax({ | 277 | $.ajax({ |
286 | type: 'POST', | 278 | type: 'POST', |
287 | - url: '/profile/'+ me.enterprise +'/plugin/shopping_cart/send_request', | 279 | + url: '/plugin/shopping_cart/send_request', |
288 | data: params, | 280 | data: params, |
289 | dataType: 'json', | 281 | dataType: 'json', |
290 | success: function(data, status, ajax){ | 282 | success: function(data, status, ajax){ |
@@ -310,9 +302,8 @@ function Cart(config) { | @@ -310,9 +302,8 @@ function Cart(config) { | ||
310 | 302 | ||
311 | $(function(){ | 303 | $(function(){ |
312 | 304 | ||
313 | - var profile = 'foo'; // FIXME | ||
314 | $.ajax({ | 305 | $.ajax({ |
315 | - url: "/profile/" + profile + "/plugin/shopping_cart/get", | 306 | + url: "/plugin/shopping_cart/get", |
316 | dataType: 'json', | 307 | dataType: 'json', |
317 | success: function(data) { | 308 | success: function(data) { |
318 | new Cart(data); | 309 | new Cart(data); |
plugins/shopping_cart/views/cart.html.erb
@@ -7,7 +7,7 @@ | @@ -7,7 +7,7 @@ | ||
7 | <a href="cart:clean" onclick="Cart.clean(this); return false" class="cart-clean"><%=_('Clean basket')%></a> | 7 | <a href="cart:clean" onclick="Cart.clean(this); return false" class="cart-clean"><%=_('Clean basket')%></a> |
8 | <ul class="cart-items"></ul> | 8 | <ul class="cart-items"></ul> |
9 | <div class="cart-total"><%=_('Total:')%> <b></b></div> | 9 | <div class="cart-total"><%=_('Total:')%> <b></b></div> |
10 | - <a href="cart:buy" class="cart-buy"><%=_('Shopping checkout')%></a> | 10 | + <a href="/plugin/shopping_cart/buy" class="cart-buy"><%=_('Shopping checkout')%></a> |
11 | </div> | 11 | </div> |
12 | <a href="#" onclick="Cart.toggle(this); return false" class="cart-toggle"> | 12 | <a href="#" onclick="Cart.toggle(this); return false" class="cart-toggle"> |
13 | <span class="str-show"><%=_('Show basket')%></span> | 13 | <span class="str-show"><%=_('Show basket')%></span> |
plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb
0 → 100644
@@ -0,0 +1,35 @@ | @@ -0,0 +1,35 @@ | ||
1 | +<% person = user.nil? ? Person.new : user %> | ||
2 | +<div id='cart-request-box'> | ||
3 | + <% form_for(:customer, person, :url => {:action => 'send_request'}, | ||
4 | + :html => {:onsubmit => "return Cart.send_request(this)", :id => 'cart-request-form' }) do |f| %> | ||
5 | + <div id="cart-form-main"> | ||
6 | + <%= labelled_form_field('* ' + _("Name"), f.text_field(:name, :class => 'required') ) %> | ||
7 | + <%= labelled_form_field('* ' + _("Email"), f.text_field(:email, :class => 'required email') ) %> | ||
8 | + <%= labelled_form_field('* ' + _("Contact phone"), f.text_field(:contact_phone, :class => 'required') ) %> | ||
9 | + </div> | ||
10 | + <fieldset><legend><%=_('Delivery Address')%></legend> | ||
11 | + <%= labelled_form_field(_('Address (street and number)'), f.text_field(:address)) %> | ||
12 | + <%= labelled_form_field( _("City"), f.text_field(:city)) %> | ||
13 | + <%= labelled_form_field(_('ZIP code'), f.text_field(:zip_code)) %> | ||
14 | + </fieldset> | ||
15 | + <div id="cart-form-actions"> | ||
16 | + <%= submit_button(:send, _('Send buy request')) %> | ||
17 | + </div> | ||
18 | + <% end %> | ||
19 | + <%= items_table(@cart[:items], @enterprise) %> | ||
20 | + <%= link_to '', '#', :onclick => "Cart.colorbox_close(this);", :class => 'cart-box-close icon-cancel' %> | ||
21 | +</div> | ||
22 | + | ||
23 | +<script type="text/javascript"> | ||
24 | +//<![CDATA[ | ||
25 | + jQuery(document).ready(function(){ | ||
26 | + jQuery("#cart-request-form").validate({ | ||
27 | + submitHandler: function(form) { | ||
28 | + jQuery(form).find('input.submit').attr('disabled', true); | ||
29 | + jQuery('#cboxLoadingOverlay').show().addClass('loading'); | ||
30 | + jQuery('#cboxLoadingGraphic').show().addClass('loading'); | ||
31 | + } | ||
32 | + }); | ||
33 | + }); | ||
34 | +//]]> | ||
35 | +</script> |
plugins/shopping_cart/views/shopping_cart_plugin/send_request.html.erb
0 → 100644
@@ -0,0 +1 @@ | @@ -0,0 +1 @@ | ||
1 | +<%= _("Request sent successfully check your email.")%> |
plugins/shopping_cart/views/shopping_cart_plugin_profile/buy.html.erb
@@ -1,35 +0,0 @@ | @@ -1,35 +0,0 @@ | ||
1 | -<% person = user.nil? ? Person.new : user %> | ||
2 | -<div id='cart-request-box'> | ||
3 | - <% form_for(:customer, person, :url => {:action => 'send_request'}, | ||
4 | - :html => {:onsubmit => "return Cart.send_request(this)", :id => 'cart-request-form' }) do |f| %> | ||
5 | - <div id="cart-form-main"> | ||
6 | - <%= labelled_form_field('* ' + _("Name"), f.text_field(:name, :class => 'required') ) %> | ||
7 | - <%= labelled_form_field('* ' + _("Email"), f.text_field(:email, :class => 'required email') ) %> | ||
8 | - <%= labelled_form_field('* ' + _("Contact phone"), f.text_field(:contact_phone, :class => 'required') ) %> | ||
9 | - </div> | ||
10 | - <fieldset><legend><%=_('Delivery Address')%></legend> | ||
11 | - <%= labelled_form_field(_('Address (street and number)'), f.text_field(:address)) %> | ||
12 | - <%= labelled_form_field( _("City"), f.text_field(:city)) %> | ||
13 | - <%= labelled_form_field(_('ZIP code'), f.text_field(:zip_code)) %> | ||
14 | - </fieldset> | ||
15 | - <div id="cart-form-actions"> | ||
16 | - <%= submit_button(:send, _('Send buy request')) %> | ||
17 | - </div> | ||
18 | - <% end %> | ||
19 | - <%= items_table(@cart[:items], profile) %> | ||
20 | - <%= link_to '', '#', :onclick => "Cart.colorbox_close(this);", :class => 'cart-box-close icon-cancel' %> | ||
21 | -</div> | ||
22 | - | ||
23 | -<script type="text/javascript"> | ||
24 | -//<![CDATA[ | ||
25 | - jQuery(document).ready(function(){ | ||
26 | - jQuery("#cart-request-form").validate({ | ||
27 | - submitHandler: function(form) { | ||
28 | - jQuery(form).find('input.submit').attr('disabled', true); | ||
29 | - jQuery('#cboxLoadingOverlay').show().addClass('loading'); | ||
30 | - jQuery('#cboxLoadingGraphic').show().addClass('loading'); | ||
31 | - } | ||
32 | - }); | ||
33 | - }); | ||
34 | -//]]> | ||
35 | -</script> |
plugins/shopping_cart/views/shopping_cart_plugin_profile/send_request.html.erb
@@ -1 +0,0 @@ | @@ -1 +0,0 @@ | ||
1 | -<%= _("Request sent successfully check your email.")%> |