From 1bd054d0509f597dbd06a19e001cd491fc827716 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Mon, 27 Apr 2015 15:42:38 -0500 Subject: [PATCH] * VRFS-3094 - update style and minor issues in shopping cart screen --- admin/config/application.rb | 2 +- ruby/lib/jam_ruby/models/anonymous_user.rb | 2 +- ruby/lib/jam_ruby/models/shopping_cart.rb | 2 +- web/app/assets/javascripts/shopping_cart.js | 15 ++++- .../stylesheets/client/shoppingCart.css.scss | 58 ++++++++++++++---- .../views/clients/_shopping_cart.html.haml | 61 ++++++++++--------- web/config/application.rb | 2 +- 7 files changed, 96 insertions(+), 46 deletions(-) diff --git a/admin/config/application.rb b/admin/config/application.rb index edb978be7..9add98380 100644 --- a/admin/config/application.rb +++ b/admin/config/application.rb @@ -117,7 +117,7 @@ module JamAdmin config.email_smtp_domain = 'www.jamkazam.com' config.email_smtp_authentication = :plain config.email_smtp_user_name = 'jamkazam' - config.email_smtp_password = 'jamjamblueberryjam' + config.email_smtp_password = 'snorkeltoesniffyfarce1' config.email_smtp_starttls_auto = true config.facebook_app_id = ENV['FACEBOOK_APP_ID'] || '468555793186398' diff --git a/ruby/lib/jam_ruby/models/anonymous_user.rb b/ruby/lib/jam_ruby/models/anonymous_user.rb index 0a843185a..bd3037922 100644 --- a/ruby/lib/jam_ruby/models/anonymous_user.rb +++ b/ruby/lib/jam_ruby/models/anonymous_user.rb @@ -11,7 +11,7 @@ module JamRuby end def shopping_carts - ShoppingCart.where(anonymous_user_id: @id) + ShoppingCart.where(anonymous_user_id: @id).order('created_at DESC') end def destroy_all_shopping_carts diff --git a/ruby/lib/jam_ruby/models/shopping_cart.rb b/ruby/lib/jam_ruby/models/shopping_cart.rb index 75faf2b7d..dc975bd40 100644 --- a/ruby/lib/jam_ruby/models/shopping_cart.rb +++ b/ruby/lib/jam_ruby/models/shopping_cart.rb @@ -25,7 +25,7 @@ module JamRuby def product_info product = self.cart_product - {name: product.name, price: product.price, product_id: cart_id, plan_code: product.plan_code, real_price: real_price(product), total_price: total_price(product), quantity: quantity, marked_for_redeem: marked_for_redeem, free: free?} unless product.nil? + {name: product.name, price: product.price, product_id: cart_id, plan_code: product.plan_code, real_price: real_price(product), total_price: total_price(product), quantity: quantity, marked_for_redeem: marked_for_redeem, free: free?, sales_region: product.sales_region} unless product.nil? end # multiply quantity by price diff --git a/web/app/assets/javascripts/shopping_cart.js b/web/app/assets/javascripts/shopping_cart.js index 667c5246d..ac115f175 100644 --- a/web/app/assets/javascripts/shopping_cart.js +++ b/web/app/assets/javascripts/shopping_cart.js @@ -75,13 +75,24 @@ function renderShoppingCarts(carts) { var data = {}; - var latest_cart = carts[carts.length - 1]; + + if(carts.length > 0) { + var latest_cart = carts[0]; + } var $latestCartHtml = ""; - + var any_in_us = false + context._.each(carts, function(cart) { + if(cart.product_info.sales_region == 'United States') { + any_in_us = true + } + }) if (latest_cart) { + + latest_cart.any_in_us = any_in_us + $latestCartHtml = $( context._.template( $('#template-shopping-cart-header').html(), diff --git a/web/app/assets/stylesheets/client/shoppingCart.css.scss b/web/app/assets/stylesheets/client/shoppingCart.css.scss index 082e04ca8..7621c93ee 100644 --- a/web/app/assets/stylesheets/client/shoppingCart.css.scss +++ b/web/app/assets/stylesheets/client/shoppingCart.css.scss @@ -8,7 +8,7 @@ } .checkout-image { - width: 10%; + margin-right:20px; float: left; } @@ -20,7 +20,7 @@ margin-bottom: 7px; } - div#note { + .note { font-style: italic; font-size: 13px; } @@ -35,22 +35,43 @@ } .cart-item-price { - text-align: right; + text-align: right; + width:120px; } .cart-item-quantity { - text-align: right; + text-align: left; + width:150px; } .cart-item-actions { //text-align: center; } + + .cart-item-price { + padding-right:11px; + } + + th.cart-item-quantity { + padding-left:15px; + } + + .remove-cart { + color:#fc0; + float:right; + margin-right:20px; + } + + .cart-value { + margin-left:63px; + } + .cart-items { - width: 100%; - min-height: 200px; + width: 80%; // overflow: auto; margin-top: 30px; + margin-bottom:20px; } .cart-item { @@ -58,12 +79,17 @@ } .shopping-sub-total { - width: 65%; - float: left; - text-align: right; - margin: 10px 0 20px; - font-weight: bold; - font-size: 17px; + margin-top:30px; + + .sub-total-text { + color:white; + float:left; + margin-left:10px; + } + + .sub-total-value { + color:white; + } } .no-cart-items { @@ -73,5 +99,13 @@ font-weight: bold; font-size: 15px; } + + .actions { + margin-right:20%; + } + + .proceed-checkout { + margin-right:2px; + } } } \ No newline at end of file diff --git a/web/app/views/clients/_shopping_cart.html.haml b/web/app/views/clients/_shopping_cart.html.haml index 77ba342be..ec4e1943c 100644 --- a/web/app/views/clients/_shopping_cart.html.haml +++ b/web/app/views/clients/_shopping_cart.html.haml @@ -15,41 +15,46 @@ 1 item added to shopping cart %div {{data.cart_type}}: {{data.product_info.name}} - #note + = "{% if (data.any_in_us) { %}" + .note Note: You must be in the United States to purchase this {{data.type}} due to licensing constraints. + = "{% } %}" .clearall %script{type: 'text/template', id: 'template-shopping-cart-body'} %table.cart-items - %tr - %th.cart-item-caption - YOUR SHOPPING CART NOW CONTAINS: - %th.cart-item-price - Price - %th.cart-item-quantity - Quantity - %th - = "{% if (data.carts.length == 0) { %}" - %tr - %td.no-cart-items colspan=4 Nothing in cart - = "{% } %}" + %thead + %tr + %th.cart-item-caption + YOUR SHOPPING CART NOW CONTAINS + %th.cart-item-price + PRICE + %th.cart-item-quantity + QUANTITY + %tbody + = "{% if (data.carts.length == 0) { %}" + %tr + %td.no-cart-items colspan=4 Nothing in cart + = "{% } %}" - = "{% _.each(data.carts, function(cart) { %}" - %tr.cart-item{"cart-id" => "{{cart.id}}"} - %td.cart-item-caption - {{cart.cart_type}}: {{cart.product_info.name}} - %td.cart-item-price - $ {{Number(cart.product_info.real_price).toFixed(2)}} - %td.cart-item-quantity - {{cart.quantity}} - %td.cart-item-actions - %a.button-grey.remove-cart{href: "#", "cart-id" => "{{cart.id}}"} - DELETE - = "{% }); %}" - .shopping-sub-total - Subtotal: $ {{data.sub_total.toFixed(2)}} + = "{% _.each(data.carts, function(cart, index) { %}" + %tr.cart-item{"cart-id" => "{{cart.id}}"} + %td.cart-item-caption + {{cart.cart_type}}: {{cart.product_info.name}} + %td.cart-item-price + $ {{Number(cart.product_info.real_price).toFixed(2)}} + = "{% if(index == data.carts.length - 1) { %}" + .shopping-sub-total + %span.sub-total-text Subtotal: + %span.sub-total-value $ {{data.sub_total.toFixed(2)}} + = "{% } %}" + + %td.cart-item-quantity + %span.cart-value {{cart.quantity}} + %a.remove-cart{href: "#", "cart-id" => "{{cart.id}}"} delete + = "{% }); %}" .clearall - .right + .right.actions %a.button-grey{href: "#"} HELP %a.button-orange{href: "/client#/jamtrackBrowse"} CONTINUE SHOPPING %a.button-orange.proceed-checkout{href: "#"} PROCEED TO CHECKOUT diff --git a/web/config/application.rb b/web/config/application.rb index ac6553438..63dd5400c 100644 --- a/web/config/application.rb +++ b/web/config/application.rb @@ -229,7 +229,7 @@ if defined?(Bundler) config.email_smtp_domain = 'www.jamkazam.com' config.email_smtp_authentication = :plain config.email_smtp_user_name = 'jamkazam' - config.email_smtp_password = 'jamjamblueberryjam' + config.email_smtp_password = 'snorkeltoesniffyfarce1' config.email_smtp_starttls_auto = true config.facebook_app_id = ENV['FACEBOOK_APP_ID'] || '468555793186398'