solidus_starter_frontend 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (301) hide show
  1. checksums.yaml +7 -0
  2. data/.circleci/config.yml +57 -0
  3. data/.erb-lint.yml +22 -0
  4. data/.eslintrc +5 -0
  5. data/.gem_release.yml +5 -0
  6. data/.github/pull_request_template.md +28 -0
  7. data/.github/stale.yml +17 -0
  8. data/.gitignore +17 -0
  9. data/.hound.yml +16 -0
  10. data/.rspec +2 -0
  11. data/.rubocop.yml +19 -0
  12. data/.rubocop_todo.yml +229 -0
  13. data/.scss-lint.yml +4 -0
  14. data/Gemfile +34 -0
  15. data/LICENSE +26 -0
  16. data/README.md +69 -0
  17. data/Rakefile +6 -0
  18. data/app/assets/config/solidus_starter_frontend_manifest.js +2 -0
  19. data/app/assets/javascripts/spree/frontend.js +6 -0
  20. data/app/assets/javascripts/spree/frontend/cart.js +26 -0
  21. data/app/assets/javascripts/spree/frontend/checkout.js +34 -0
  22. data/app/assets/javascripts/spree/frontend/checkout/address.js +124 -0
  23. data/app/assets/javascripts/spree/frontend/checkout/payment.js +44 -0
  24. data/app/assets/javascripts/spree/frontend/locale_selector.js +9 -0
  25. data/app/assets/javascripts/spree/frontend/product.js +21 -0
  26. data/app/assets/javascripts/spree/frontend/solidus_starter_frontend.js +9 -0
  27. data/app/assets/javascripts/spree/frontend/utils.js.erb +18 -0
  28. data/app/assets/stylesheets/spree/frontend.css +8 -0
  29. data/app/assets/stylesheets/spree/frontend/base/_base.scss +29 -0
  30. data/app/assets/stylesheets/spree/frontend/base/_reset.scss +179 -0
  31. data/app/assets/stylesheets/spree/frontend/base/_responsive.scss +21 -0
  32. data/app/assets/stylesheets/spree/frontend/components/account/_account_order.scss +23 -0
  33. data/app/assets/stylesheets/spree/frontend/components/account/_account_summary.scss +17 -0
  34. data/app/assets/stylesheets/spree/frontend/components/auth/_auth_container.scss +11 -0
  35. data/app/assets/stylesheets/spree/frontend/components/auth/_auth_form.scss +5 -0
  36. data/app/assets/stylesheets/spree/frontend/components/brand/_logo.scss +4 -0
  37. data/app/assets/stylesheets/spree/frontend/components/buttons/_button_inline.scss +8 -0
  38. data/app/assets/stylesheets/spree/frontend/components/buttons/_button_primary.scss +26 -0
  39. data/app/assets/stylesheets/spree/frontend/components/cart/_cart_adjustments.scss +6 -0
  40. data/app/assets/stylesheets/spree/frontend/components/cart/_cart_amount_row.scss +11 -0
  41. data/app/assets/stylesheets/spree/frontend/components/cart/_cart_empty.scss +10 -0
  42. data/app/assets/stylesheets/spree/frontend/components/cart/_cart_footer.scss +20 -0
  43. data/app/assets/stylesheets/spree/frontend/components/cart/_cart_header.scss +12 -0
  44. data/app/assets/stylesheets/spree/frontend/components/cart/_cart_item.scss +86 -0
  45. data/app/assets/stylesheets/spree/frontend/components/cart/_cart_link.scss +22 -0
  46. data/app/assets/stylesheets/spree/frontend/components/cart/_cart_page.scss +15 -0
  47. data/app/assets/stylesheets/spree/frontend/components/cart/_cart_secondary_actions.scss +19 -0
  48. data/app/assets/stylesheets/spree/frontend/components/cart/_coupon_code.scss +8 -0
  49. data/app/assets/stylesheets/spree/frontend/components/cart/_item_info.scss +19 -0
  50. data/app/assets/stylesheets/spree/frontend/components/checkout/_checkout.scss +27 -0
  51. data/app/assets/stylesheets/spree/frontend/components/checkout/_checkout_header.scss +19 -0
  52. data/app/assets/stylesheets/spree/frontend/components/checkout/_checkout_summary.scss +31 -0
  53. data/app/assets/stylesheets/spree/frontend/components/checkout/_existing_cards.scss +27 -0
  54. data/app/assets/stylesheets/spree/frontend/components/checkout/_payment_method_controls.scss +5 -0
  55. data/app/assets/stylesheets/spree/frontend/components/checkout/_payment_method_selector.scss +14 -0
  56. data/app/assets/stylesheets/spree/frontend/components/checkout/_progress_steps.scss +38 -0
  57. data/app/assets/stylesheets/spree/frontend/components/checkout/_proposed_shipment.scss +18 -0
  58. data/app/assets/stylesheets/spree/frontend/components/checkout/_shipment_items.scss +50 -0
  59. data/app/assets/stylesheets/spree/frontend/components/checkout/_shipping_methods.scss +9 -0
  60. data/app/assets/stylesheets/spree/frontend/components/checkout/payments/_gateway_payment_method.scss +11 -0
  61. data/app/assets/stylesheets/spree/frontend/components/checkout/steps/_address_step.scss +20 -0
  62. data/app/assets/stylesheets/spree/frontend/components/checkout/steps/_confirm_step.scss +13 -0
  63. data/app/assets/stylesheets/spree/frontend/components/checkout/steps/_delivery_step.scss +13 -0
  64. data/app/assets/stylesheets/spree/frontend/components/checkout/steps/_payment_step.scss +13 -0
  65. data/app/assets/stylesheets/spree/frontend/components/forms/_address_inputs.scss +13 -0
  66. data/app/assets/stylesheets/spree/frontend/components/forms/inputs/_checkbox_input.scss +3 -0
  67. data/app/assets/stylesheets/spree/frontend/components/forms/inputs/_radio_input.scss +3 -0
  68. data/app/assets/stylesheets/spree/frontend/components/forms/inputs/_select_input.scss +27 -0
  69. data/app/assets/stylesheets/spree/frontend/components/forms/inputs/_text.scss +32 -0
  70. data/app/assets/stylesheets/spree/frontend/components/forms/inputs/_textarea_input.scss +25 -0
  71. data/app/assets/stylesheets/spree/frontend/components/general/_flash.scss +20 -0
  72. data/app/assets/stylesheets/spree/frontend/components/layout/_aside.scss +4 -0
  73. data/app/assets/stylesheets/spree/frontend/components/layout/_breadcrumbs.scss +16 -0
  74. data/app/assets/stylesheets/spree/frontend/components/layout/_category_navigation.scss +3 -0
  75. data/app/assets/stylesheets/spree/frontend/components/layout/_footer.scss +8 -0
  76. data/app/assets/stylesheets/spree/frontend/components/layout/_header.scss +12 -0
  77. data/app/assets/stylesheets/spree/frontend/components/layout/_horizontal_input_group.scss +7 -0
  78. data/app/assets/stylesheets/spree/frontend/components/layout/_top_bar.scss +44 -0
  79. data/app/assets/stylesheets/spree/frontend/components/navigation/_auth_link.scss +11 -0
  80. data/app/assets/stylesheets/spree/frontend/components/navigation/_categories.scss +29 -0
  81. data/app/assets/stylesheets/spree/frontend/components/navigation/_locale_selector.scss +21 -0
  82. data/app/assets/stylesheets/spree/frontend/components/navigation/_taxonomies.scss +7 -0
  83. data/app/assets/stylesheets/spree/frontend/components/navigation/_taxonomy.scss +28 -0
  84. data/app/assets/stylesheets/spree/frontend/components/orders/_address_overview.scss +27 -0
  85. data/app/assets/stylesheets/spree/frontend/components/orders/_coupon_codes.scss +4 -0
  86. data/app/assets/stylesheets/spree/frontend/components/orders/_line_items.scss +20 -0
  87. data/app/assets/stylesheets/spree/frontend/components/orders/_order_details.scss +18 -0
  88. data/app/assets/stylesheets/spree/frontend/components/orders/_order_item.scss +85 -0
  89. data/app/assets/stylesheets/spree/frontend/components/orders/_order_page.scss +41 -0
  90. data/app/assets/stylesheets/spree/frontend/components/orders/_order_shipments.scss +27 -0
  91. data/app/assets/stylesheets/spree/frontend/components/orders/_payment_info.scss +29 -0
  92. data/app/assets/stylesheets/spree/frontend/components/presentation/_hero.scss +18 -0
  93. data/app/assets/stylesheets/spree/frontend/components/products/_product_card.scss +35 -0
  94. data/app/assets/stylesheets/spree/frontend/components/products/_product_image.scss +7 -0
  95. data/app/assets/stylesheets/spree/frontend/components/products/_product_info.scss +14 -0
  96. data/app/assets/stylesheets/spree/frontend/components/products/_product_page.scss +31 -0
  97. data/app/assets/stylesheets/spree/frontend/components/products/_product_properties.scss +23 -0
  98. data/app/assets/stylesheets/spree/frontend/components/products/_product_submit.scss +9 -0
  99. data/app/assets/stylesheets/spree/frontend/components/products/_product_taxons.scss +27 -0
  100. data/app/assets/stylesheets/spree/frontend/components/products/_product_thumbnails.scss +7 -0
  101. data/app/assets/stylesheets/spree/frontend/components/products/_product_variants.scss +20 -0
  102. data/app/assets/stylesheets/spree/frontend/components/products/_products.scss +13 -0
  103. data/app/assets/stylesheets/spree/frontend/components/products/_products_by_taxon.scss +6 -0
  104. data/app/assets/stylesheets/spree/frontend/components/products/_products_grid.scss +18 -0
  105. data/app/assets/stylesheets/spree/frontend/components/search/_filter.scss +32 -0
  106. data/app/assets/stylesheets/spree/frontend/components/search/_search_bar.scss +34 -0
  107. data/app/assets/stylesheets/spree/frontend/components/typography/_hero_title.scss +6 -0
  108. data/app/assets/stylesheets/spree/frontend/components/typography/_subtitle.scss +7 -0
  109. data/app/assets/stylesheets/spree/frontend/placeholders/main.scss +5 -0
  110. data/app/assets/stylesheets/spree/frontend/screen.scss +89 -0
  111. data/app/assets/stylesheets/spree/frontend/solidus_starter_frontend.css +7 -0
  112. data/app/assets/stylesheets/spree/frontend/variables/_colors.scss +20 -0
  113. data/app/controllers/concerns/solidus_starter_frontend/auth_views.rb +16 -0
  114. data/app/controllers/concerns/solidus_starter_frontend/taxonomies.rb +16 -0
  115. data/app/controllers/spree/checkout_controller.rb +249 -0
  116. data/app/controllers/spree/coupon_codes_controller.rb +35 -0
  117. data/app/controllers/spree/home_controller.rb +13 -0
  118. data/app/controllers/spree/locale_controller.rb +20 -0
  119. data/app/controllers/spree/orders_controller.rb +126 -0
  120. data/app/controllers/spree/products_controller.rb +51 -0
  121. data/app/controllers/spree/store_controller.rb +31 -0
  122. data/app/controllers/spree/taxons_controller.rb +30 -0
  123. data/app/helpers/spree/orders_helper.rb +18 -0
  124. data/app/helpers/spree/taxon_filters_helper.rb +13 -0
  125. data/app/views/spree/address/_form_hidden.html.erb +12 -0
  126. data/app/views/spree/checkout/_terms_and_conditions.en.html.erb +1 -0
  127. data/app/views/spree/checkout/edit.html.erb +16 -0
  128. data/app/views/spree/checkout/existing_payment/_gateway.html.erb +9 -0
  129. data/app/views/spree/checkout/payment/_check.html.erb +0 -0
  130. data/app/views/spree/checkout/payment/_gateway.html.erb +43 -0
  131. data/app/views/spree/components/auth/_change_form.html.erb +40 -0
  132. data/app/views/spree/components/auth/_forgot_form.html.erb +28 -0
  133. data/app/views/spree/components/auth/_guest_form.html.erb +31 -0
  134. data/app/views/spree/components/auth/_login_form.html.erb +42 -0
  135. data/app/views/spree/components/auth/_signup_form.html.erb +48 -0
  136. data/app/views/spree/components/brand/_logo.html.erb +3 -0
  137. data/app/views/spree/components/buttons/_button_inline.html.erb +23 -0
  138. data/app/views/spree/components/buttons/_button_primary.html.erb +29 -0
  139. data/app/views/spree/components/cart/_cart_adjustment.html.erb +15 -0
  140. data/app/views/spree/components/cart/_cart_adjustments.html.erb +47 -0
  141. data/app/views/spree/components/cart/_cart_amount_row.html.erb +12 -0
  142. data/app/views/spree/components/cart/_cart_empty.html.erb +9 -0
  143. data/app/views/spree/components/cart/_cart_footer.html.erb +15 -0
  144. data/app/views/spree/components/cart/_cart_header.html.erb +17 -0
  145. data/app/views/spree/components/cart/_cart_item.html.erb +52 -0
  146. data/app/views/spree/components/cart/_cart_items.html.erb +23 -0
  147. data/app/views/spree/components/cart/_cart_link.html.erb +9 -0
  148. data/app/views/spree/components/cart/_cart_secondary_actions.html.erb +17 -0
  149. data/app/views/spree/components/cart/_item_info.html.erb +26 -0
  150. data/app/views/spree/components/checkout/_checkout_header.html.erb +8 -0
  151. data/app/views/spree/components/checkout/_checkout_step.html.erb +21 -0
  152. data/app/views/spree/components/checkout/_checkout_summary.html.erb +70 -0
  153. data/app/views/spree/components/checkout/_existing_cards.html.erb +39 -0
  154. data/app/views/spree/components/checkout/_payment_method_controls.html.erb +10 -0
  155. data/app/views/spree/components/checkout/_payment_method_selector.html.erb +14 -0
  156. data/app/views/spree/components/checkout/_proposed_shipment.erb +18 -0
  157. data/app/views/spree/components/checkout/_shipment_items.html.erb +22 -0
  158. data/app/views/spree/components/checkout/_shipping_methods.html.erb +20 -0
  159. data/app/views/spree/components/checkout/_unshippable_items.html.erb +7 -0
  160. data/app/views/spree/components/checkout/steps/_address_step.html.erb +60 -0
  161. data/app/views/spree/components/checkout/steps/_confirm_step.html.erb +31 -0
  162. data/app/views/spree/components/checkout/steps/_delivery_step.html.erb +31 -0
  163. data/app/views/spree/components/checkout/steps/_payment_step.html.erb +25 -0
  164. data/app/views/spree/components/forms/_address_inputs.html.erb +152 -0
  165. data/app/views/spree/components/forms/inputs/_checkbox_input.html.erb +29 -0
  166. data/app/views/spree/components/forms/inputs/_collection_select.html.erb +42 -0
  167. data/app/views/spree/components/forms/inputs/_radio_input.html.erb +29 -0
  168. data/app/views/spree/components/forms/inputs/_select_input.html.erb +31 -0
  169. data/app/views/spree/components/forms/inputs/_text.html.erb +54 -0
  170. data/app/views/spree/components/forms/inputs/_textarea_input.html.erb +42 -0
  171. data/app/views/spree/components/layout/_category_navigation.html.erb +3 -0
  172. data/app/views/spree/components/layout/_footer.html.erb +7 -0
  173. data/app/views/spree/components/layout/_header.html.erb +8 -0
  174. data/app/views/spree/components/layout/_top_bar.html.erb +8 -0
  175. data/app/views/spree/components/navigation/_auth_link.html.erb +1 -0
  176. data/app/views/spree/components/navigation/_breadcrumbs.html.erb +47 -0
  177. data/app/views/spree/components/navigation/_categories.html.erb +12 -0
  178. data/app/views/spree/components/navigation/_locale_selector.html.erb +25 -0
  179. data/app/views/spree/components/navigation/_taxonomies.html.erb +17 -0
  180. data/app/views/spree/components/navigation/_taxons.html.erb +17 -0
  181. data/app/views/spree/components/navigation/_taxons_tree.html.erb +29 -0
  182. data/app/views/spree/components/orders/_address_overview.html.erb +40 -0
  183. data/app/views/spree/components/orders/_coupon_code.html.erb +22 -0
  184. data/app/views/spree/components/orders/_line_items.html.erb +55 -0
  185. data/app/views/spree/components/orders/_order_details.html.erb +35 -0
  186. data/app/views/spree/components/orders/_order_item.html.erb +33 -0
  187. data/app/views/spree/components/orders/_order_items.html.erb +5 -0
  188. data/app/views/spree/components/orders/_order_shipments.html.erb +25 -0
  189. data/app/views/spree/components/orders/_payment_info.html.erb +31 -0
  190. data/app/views/spree/components/presentation/_hero.html.erb +14 -0
  191. data/app/views/spree/components/products/_product-card.html.erb +36 -0
  192. data/app/views/spree/components/products/_product_availability.html.erb +19 -0
  193. data/app/views/spree/components/products/_product_form.html.erb +21 -0
  194. data/app/views/spree/components/products/_product_image.html.erb +6 -0
  195. data/app/views/spree/components/products/_product_info.html.erb +9 -0
  196. data/app/views/spree/components/products/_product_promotions.html.erb +25 -0
  197. data/app/views/spree/components/products/_product_properties.html.erb +19 -0
  198. data/app/views/spree/components/products/_product_submit.html.erb +39 -0
  199. data/app/views/spree/components/products/_product_taxons.html.erb +15 -0
  200. data/app/views/spree/components/products/_product_thumbnails.html.erb +19 -0
  201. data/app/views/spree/components/products/_product_variants.html.erb +36 -0
  202. data/app/views/spree/components/products/_products-grid.html.erb +13 -0
  203. data/app/views/spree/components/products/_products.html.erb +28 -0
  204. data/app/views/spree/components/products/_products_by_taxon.html.erb +7 -0
  205. data/app/views/spree/components/products/_variants_list.html.erb +12 -0
  206. data/app/views/spree/components/search/_filter.html.erb +42 -0
  207. data/app/views/spree/components/search/_filters.html.erb +20 -0
  208. data/app/views/spree/components/search/_form.html.erb +12 -0
  209. data/app/views/spree/components/search/_products_search.html.erb +36 -0
  210. data/app/views/spree/components/search/_search_bar.html.erb +36 -0
  211. data/app/views/spree/components/typography/_hero_title.html.erb +11 -0
  212. data/app/views/spree/components/typography/_subtitle.html.erb +11 -0
  213. data/app/views/spree/home/index.html.erb +7 -0
  214. data/app/views/spree/layouts/spree_application.html.erb +27 -0
  215. data/app/views/spree/orders/edit.html.erb +21 -0
  216. data/app/views/spree/orders/show.html.erb +29 -0
  217. data/app/views/spree/products/index.html.erb +22 -0
  218. data/app/views/spree/products/show.html.erb +18 -0
  219. data/app/views/spree/shared/_image.html.erb +12 -0
  220. data/app/views/spree/shared/_link_to_cart.html.erb +1 -0
  221. data/app/views/spree/shared/_login_bar_items.html.erb +1 -0
  222. data/app/views/spree/shared/_shipment_tracking.html.erb +11 -0
  223. data/app/views/spree/shared/unauthorized.html.erb +0 -0
  224. data/app/views/spree/taxons/show.html.erb +17 -0
  225. data/bin/console +17 -0
  226. data/bin/r +13 -0
  227. data/bin/rails +7 -0
  228. data/bin/rake +7 -0
  229. data/bin/rspec +29 -0
  230. data/bin/sandbox +84 -0
  231. data/bin/sandbox_rails +18 -0
  232. data/bin/setup +8 -0
  233. data/bin/solidus_compare +155 -0
  234. data/config/initializers/assets.rb +1 -0
  235. data/config/initializers/canonical_rails.rb +16 -0
  236. data/config/locales/en.yml +5 -0
  237. data/config/routes.rb +33 -0
  238. data/config/solidus_compare.yml +33 -0
  239. data/docs/development.md +28 -0
  240. data/exe/solidus_starter_frontend +9 -0
  241. data/lib/generators/solidus_starter_frontend/install/install_generator.rb +15 -0
  242. data/lib/generators/solidus_starter_frontend/solidus_starter_frontend_generator.rb +30 -0
  243. data/lib/generators/solidus_starter_frontend/views/override_generator.rb +50 -0
  244. data/lib/solidus_starter_frontend.rb +12 -0
  245. data/lib/solidus_starter_frontend/config.rb +7 -0
  246. data/lib/solidus_starter_frontend/engine.rb +34 -0
  247. data/lib/solidus_starter_frontend/factories.rb +4 -0
  248. data/lib/solidus_starter_frontend/solidus_support_extensions.rb +9 -0
  249. data/lib/solidus_starter_frontend/version.rb +5 -0
  250. data/lib/solidus_starter_frontend_configuration.rb +8 -0
  251. data/lib/views/auth/spree/checkout/registration.html.erb +7 -0
  252. data/lib/views/auth/spree/components/navigation/_auth_link.html.erb +5 -0
  253. data/lib/views/auth/spree/user_passwords/edit.html.erb +7 -0
  254. data/lib/views/auth/spree/user_passwords/new.html.erb +5 -0
  255. data/lib/views/auth/spree/user_registrations/new.html.erb +7 -0
  256. data/lib/views/auth/spree/user_sessions/guest.html.erb +5 -0
  257. data/lib/views/auth/spree/user_sessions/new.html.erb +7 -0
  258. data/lib/views/auth/spree/users/edit.html.erb +45 -0
  259. data/lib/views/auth/spree/users/show.html.erb +55 -0
  260. data/solidus_starter_frontend.gemspec +43 -0
  261. data/spec/controllers/controller_helpers_spec.rb +29 -0
  262. data/spec/controllers/locale_controller_spec.rb +57 -0
  263. data/spec/controllers/spree/checkout_controller_spec.rb +563 -0
  264. data/spec/controllers/spree/checkout_controller_with_views_spec.rb +37 -0
  265. data/spec/controllers/spree/current_order_tracking_spec.rb +33 -0
  266. data/spec/controllers/spree/home_controller_spec.rb +29 -0
  267. data/spec/controllers/spree/orders_controller_ability_spec.rb +90 -0
  268. data/spec/controllers/spree/orders_controller_spec.rb +241 -0
  269. data/spec/controllers/spree/orders_controller_transitions_spec.rb +33 -0
  270. data/spec/controllers/spree/products_controller_spec.rb +38 -0
  271. data/spec/controllers/spree/taxons_controller_spec.rb +14 -0
  272. data/spec/fixtures/thinking-cat.jpg +0 -0
  273. data/spec/generators/solidus/views/override_generator_spec.rb +50 -0
  274. data/spec/helpers/base_helper_spec.rb +13 -0
  275. data/spec/helpers/order_helper_spec.rb +14 -0
  276. data/spec/helpers/taxon_filters_helper_spec.rb +12 -0
  277. data/spec/spec_helper.rb +64 -0
  278. data/spec/support/shared_contexts/checkout_setup.rb +12 -0
  279. data/spec/support/shared_contexts/custom_products.rb +28 -0
  280. data/spec/support/shared_contexts/locales.rb +16 -0
  281. data/spec/system/address_spec.rb +87 -0
  282. data/spec/system/automatic_promotion_adjustments_spec.rb +49 -0
  283. data/spec/system/caching/products_spec.rb +48 -0
  284. data/spec/system/caching/taxons_spec.rb +35 -0
  285. data/spec/system/cart_spec.rb +81 -0
  286. data/spec/system/checkout_confirm_insufficient_stock_spec.rb +71 -0
  287. data/spec/system/checkout_spec.rb +699 -0
  288. data/spec/system/checkout_unshippable_spec.rb +37 -0
  289. data/spec/system/coupon_code_spec.rb +267 -0
  290. data/spec/system/currency_spec.rb +20 -0
  291. data/spec/system/first_order_promotion_spec.rb +59 -0
  292. data/spec/system/free_shipping_promotions_spec.rb +60 -0
  293. data/spec/system/locale_spec.rb +26 -0
  294. data/spec/system/order_spec.rb +57 -0
  295. data/spec/system/products_spec.rb +302 -0
  296. data/spec/system/promotion_code_invalidation_spec.rb +54 -0
  297. data/spec/system/quantity_promotions_spec.rb +130 -0
  298. data/spec/system/taxons_spec.rb +158 -0
  299. data/spec/system/template_rendering_spec.rb +20 -0
  300. data/spec/views/spree/checkout/_summary_spec.rb +11 -0
  301. metadata +542 -0
@@ -0,0 +1,7 @@
1
+ /*
2
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
3
+ * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4
+ * the top of the compiled file, but it's generally better to create a new file per style scope.
5
+ *
6
+ *= require spree/frontend/screen
7
+ */
@@ -0,0 +1,20 @@
1
+ /*--------------------------------------*/
2
+ /* Colors
3
+ /*--------------------------------------*/
4
+
5
+ $color_accent: #3C76f0;
6
+
7
+ $color-background-alert: #fdd200;
8
+ $color-background-dark: #24282f;
9
+ $color-background-error: #e4361b;
10
+ $color-background-light: #f2f2f2;
11
+ $color-background-success: #1bc16d;
12
+
13
+ $color-border: #ddd;
14
+ $color-border-dark: #222;
15
+ $color-border-medium: #d8d8d8;
16
+ $color-border-light: #f2f2f2;
17
+
18
+ $color-copy: #222;
19
+ $color-copy-light: #777;
20
+ $color-copy-bright: #fff;
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidusStarterFrontend
4
+ module AuthViews
5
+ extend ActiveSupport::Concern
6
+ included do
7
+ before_action :configure_views
8
+ end
9
+
10
+ protected
11
+
12
+ def configure_views
13
+ prepend_view_path Engine.root.join('lib', 'views', 'auth')
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidusStarterFrontend
4
+ module Taxonomies
5
+ extend ActiveSupport::Concern
6
+ included do
7
+ helper_method :taxonomies
8
+ end
9
+
10
+ protected
11
+
12
+ def taxonomies
13
+ @taxonomies ||= Spree::Taxonomy.includes(root: :children)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,249 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spree
4
+ # This is somewhat contrary to standard REST convention since there is not
5
+ # actually a Checkout object. There's enough distinct logic specific to
6
+ # checkout which has nothing to do with updating an order that this approach
7
+ # is warranted.
8
+ class CheckoutController < Spree::StoreController
9
+ before_action :load_order
10
+ around_action :lock_order
11
+
12
+ before_action :ensure_order_is_not_skipping_states
13
+ before_action :ensure_order_not_completed
14
+ before_action :ensure_checkout_allowed
15
+ before_action :ensure_sufficient_stock_lines
16
+ before_action :ensure_valid_state
17
+
18
+ before_action :associate_user
19
+ before_action :check_authorization
20
+
21
+ before_action :setup_for_current_state, only: [:edit, :update]
22
+
23
+ helper 'spree/orders'
24
+
25
+ rescue_from Spree::Core::GatewayError, with: :rescue_from_spree_gateway_error
26
+ rescue_from Spree::Order::InsufficientStock, with: :insufficient_stock_error
27
+
28
+ # Updates the order and advances to the next state (when possible.)
29
+ def update
30
+ if update_order
31
+
32
+ assign_temp_address
33
+
34
+ unless transition_forward
35
+ redirect_on_failure
36
+ return
37
+ end
38
+
39
+ if @order.completed?
40
+ finalize_order
41
+ else
42
+ send_to_next_state
43
+ end
44
+
45
+ else
46
+ render :edit
47
+ end
48
+ end
49
+
50
+ private
51
+
52
+ def update_order
53
+ OrderUpdateAttributes.new(@order, update_params, request_env: request.headers.env).apply
54
+ end
55
+
56
+ def assign_temp_address
57
+ @order.temporary_address = !params[:save_user_address]
58
+ end
59
+
60
+ def redirect_on_failure
61
+ flash[:error] = @order.errors.full_messages.join("\n")
62
+ redirect_to(checkout_state_path(@order.state))
63
+ end
64
+
65
+ def transition_forward
66
+ if @order.can_complete?
67
+ @order.complete
68
+ else
69
+ @order.next
70
+ end
71
+ end
72
+
73
+ def finalize_order
74
+ @current_order = nil
75
+ set_successful_flash_notice
76
+ redirect_to completion_route
77
+ end
78
+
79
+ def set_successful_flash_notice
80
+ flash.notice = t('spree.order_processed_successfully')
81
+ flash['order_completed'] = true
82
+ end
83
+
84
+ def send_to_next_state
85
+ redirect_to checkout_state_path(@order.state)
86
+ end
87
+
88
+ def update_params
89
+ case params[:state].to_sym
90
+ when :address
91
+ massaged_params.require(:order).permit(
92
+ permitted_checkout_address_attributes
93
+ )
94
+ when :delivery
95
+ massaged_params.require(:order).permit(
96
+ permitted_checkout_delivery_attributes
97
+ )
98
+ when :payment
99
+ massaged_params.require(:order).permit(
100
+ permitted_checkout_payment_attributes
101
+ )
102
+ else
103
+ massaged_params.fetch(:order, {}).permit(
104
+ permitted_checkout_confirm_attributes
105
+ )
106
+ end
107
+ end
108
+
109
+ def massaged_params
110
+ massaged_params = params.deep_dup
111
+
112
+ move_payment_source_into_payments_attributes(massaged_params)
113
+ move_wallet_payment_source_id_into_payments_attributes(massaged_params)
114
+ set_payment_parameters_amount(massaged_params, @order)
115
+
116
+ massaged_params
117
+ end
118
+
119
+ def ensure_valid_state
120
+ unless skip_state_validation?
121
+ if (params[:state] && !@order.has_checkout_step?(params[:state])) ||
122
+ (!params[:state] && !@order.has_checkout_step?(@order.state))
123
+ @order.state = 'cart'
124
+ redirect_to checkout_state_path(@order.checkout_steps.first)
125
+ end
126
+ end
127
+
128
+ # Fix for https://github.com/spree/spree/issues/4117
129
+ # If confirmation of payment fails, redirect back to payment screen
130
+ if params[:state] == "confirm" && @order.payment_required? && @order.payments.valid.empty?
131
+ flash.keep
132
+ redirect_to checkout_state_path("payment")
133
+ end
134
+ end
135
+
136
+ # Should be overriden if you have areas of your checkout that don't match
137
+ # up to a step within checkout_steps, such as a registration step
138
+ def skip_state_validation?
139
+ false
140
+ end
141
+
142
+ def load_order
143
+ @order = current_order
144
+ redirect_to(spree.cart_path) && return unless @order
145
+ end
146
+
147
+ # Allow the customer to only go back or stay on the current state
148
+ # when trying to change it via params[:state]. It's not allowed to
149
+ # jump forward and skip states (unless #skip_state_validation? is
150
+ # truthy).
151
+ def ensure_order_is_not_skipping_states
152
+ if params[:state]
153
+ redirect_to checkout_state_path(@order.state) if @order.can_go_to_state?(params[:state]) && !skip_state_validation?
154
+ @order.state = params[:state]
155
+ end
156
+ end
157
+
158
+ def set_state_if_present
159
+ ensure_order_is_not_skipping_states
160
+ end
161
+ deprecate set_state_if_present: :prevent_order_from_skipping_states, deprecator: Spree::Deprecation
162
+
163
+ def ensure_checkout_allowed
164
+ unless @order.checkout_allowed?
165
+ redirect_to spree.cart_path
166
+ end
167
+ end
168
+
169
+ def ensure_order_not_completed
170
+ redirect_to spree.cart_path if @order.completed?
171
+ end
172
+
173
+ def ensure_sufficient_stock_lines
174
+ if @order.insufficient_stock_lines.present?
175
+ out_of_stock_items = @order.insufficient_stock_lines.collect(&:name).to_sentence
176
+ flash[:error] = t('spree.inventory_error_flash_for_insufficient_quantity', names: out_of_stock_items)
177
+ redirect_to spree.cart_path
178
+ end
179
+ end
180
+
181
+ # Provides a route to redirect after order completion
182
+ def completion_route
183
+ spree.order_path(@order)
184
+ end
185
+
186
+ def setup_for_current_state
187
+ method_name = :"before_#{@order.state}"
188
+ send(method_name) if respond_to?(method_name, true)
189
+ end
190
+
191
+ def before_address
192
+ @order.assign_default_user_addresses
193
+ # If the user has a default address, the previous method call takes care
194
+ # of setting that; but if he doesn't, we need to build an empty one here
195
+ @order.bill_address ||= Spree::Address.build_default
196
+ @order.ship_address ||= Spree::Address.build_default if @order.checkout_steps.include?('delivery')
197
+ end
198
+
199
+ def before_delivery
200
+ return if params[:order].present?
201
+
202
+ packages = @order.shipments.map(&:to_package)
203
+ @differentiator = Spree::Stock::Differentiator.new(@order, packages)
204
+ end
205
+
206
+ def before_payment
207
+ if @order.checkout_steps.include? "delivery"
208
+ packages = @order.shipments.map(&:to_package)
209
+ @differentiator = Spree::Stock::Differentiator.new(@order, packages)
210
+ @differentiator.missing.each do |variant, quantity|
211
+ @order.contents.remove(variant, quantity)
212
+ end
213
+ end
214
+
215
+ if try_spree_current_user && try_spree_current_user.respond_to?(:wallet)
216
+ @wallet_payment_sources = try_spree_current_user.wallet.wallet_payment_sources
217
+ @default_wallet_payment_source = @wallet_payment_sources.detect(&:default) ||
218
+ @wallet_payment_sources.first
219
+ end
220
+ end
221
+
222
+ def rescue_from_spree_gateway_error(exception)
223
+ flash.now[:error] = t('spree.spree_gateway_error_flash_for_checkout')
224
+ @order.errors.add(:base, exception.message)
225
+ render :edit
226
+ end
227
+
228
+ def check_authorization
229
+ authorize!(:edit, current_order, cookies.signed[:guest_token])
230
+ end
231
+
232
+ def insufficient_stock_error
233
+ packages = @order.shipments.map(&:to_package)
234
+ if packages.empty?
235
+ flash[:error] = I18n.t('spree.insufficient_stock_for_order')
236
+ redirect_to cart_path
237
+ else
238
+ availability_validator = Spree::Stock::AvailabilityValidator.new
239
+ unavailable_items = @order.line_items.reject { |line_item| availability_validator.validate(line_item) }
240
+ if unavailable_items.any?
241
+ item_names = unavailable_items.map(&:name).to_sentence
242
+ flash[:error] = t('spree.inventory_error_flash_for_insufficient_shipment_quantity', unavailable_items: item_names)
243
+ @order.restart_checkout_flow
244
+ redirect_to spree.checkout_state_path(@order.state)
245
+ end
246
+ end
247
+ end
248
+ end
249
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spree
4
+ class CouponCodesController < Spree::StoreController
5
+ before_action :load_order, only: :create
6
+ around_action :lock_order, only: :create
7
+
8
+ def create
9
+ authorize! :update, @order, cookies.signed[:guest_token]
10
+
11
+ if params[:coupon_code].present?
12
+ @order.coupon_code = params[:coupon_code]
13
+ handler = PromotionHandler::Coupon.new(@order).apply
14
+
15
+ respond_with(@order) do |format|
16
+ format.html do
17
+ if handler.successful?
18
+ flash[:success] = handler.success
19
+ else
20
+ flash[:error] = handler.error
21
+ end
22
+
23
+ redirect_back fallback_location: cart_path
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ def load_order
32
+ @order = current_order
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spree
4
+ class HomeController < Spree::StoreController
5
+ helper 'spree/products'
6
+ respond_to :html
7
+
8
+ def index
9
+ @searcher = build_searcher(params.merge(include_images: true))
10
+ @products = @searcher.retrieve_products
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spree
4
+ class LocaleController < Spree::StoreController
5
+ def set
6
+ available_locales = Spree.i18n_available_locales
7
+ requested_locale = params[:switch_to_locale] || params[:locale]
8
+
9
+ if requested_locale && available_locales.map(&:to_s).include?(requested_locale)
10
+ session[set_user_language_locale_key] = requested_locale
11
+ I18n.locale = requested_locale
12
+ flash.notice = t('spree.locale_changed')
13
+ else
14
+ flash[:error] = t('spree.locale_not_changed')
15
+ end
16
+
17
+ redirect_to spree.root_path
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,126 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spree
4
+ class OrdersController < Spree::StoreController
5
+ helper 'spree/products', 'spree/orders'
6
+
7
+ respond_to :html
8
+
9
+ before_action :store_guest_token
10
+ before_action :assign_order, only: :update
11
+ # note: do not lock the #edit action because that's where we redirect when we fail to acquire a lock
12
+ around_action :lock_order, only: :update
13
+ skip_before_action :verify_authenticity_token, only: [:populate]
14
+
15
+ def show
16
+ @order = Spree::Order.find_by!(number: params[:id])
17
+ authorize! :read, @order, cookies.signed[:guest_token]
18
+ end
19
+
20
+ def update
21
+ authorize! :update, @order, cookies.signed[:guest_token]
22
+ if @order.contents.update_cart(order_params)
23
+ @order.next if params.key?(:checkout) && @order.cart?
24
+
25
+ respond_with(@order) do |format|
26
+ format.html do
27
+ if params.key?(:checkout)
28
+ redirect_to checkout_state_path(@order.checkout_steps.first)
29
+ else
30
+ redirect_to cart_path
31
+ end
32
+ end
33
+ end
34
+ else
35
+ respond_with(@order)
36
+ end
37
+ end
38
+
39
+ # Shows the current incomplete order from the session
40
+ def edit
41
+ @order = current_order(build_order_if_necessary: true)
42
+ authorize! :read, @order, cookies.signed[:guest_token]
43
+ associate_user
44
+ if params[:id] && @order.number != params[:id]
45
+ flash[:error] = t('spree.cannot_edit_orders')
46
+ redirect_to cart_path
47
+ end
48
+ end
49
+
50
+ # Adds a new item to the order (creating a new order if none already exists)
51
+ def populate
52
+ @order = current_order(create_order_if_necessary: true)
53
+ authorize! :update, @order, cookies.signed[:guest_token]
54
+
55
+ variant = Spree::Variant.find(params[:variant_id])
56
+ quantity = params[:quantity].present? ? params[:quantity].to_i : 1
57
+
58
+ # 2,147,483,647 is crazy. See issue https://github.com/spree/spree/issues/2695.
59
+ if !quantity.between?(1, 2_147_483_647)
60
+ @order.errors.add(:base, t('spree.please_enter_reasonable_quantity'))
61
+ else
62
+ begin
63
+ @line_item = @order.contents.add(variant, quantity)
64
+ rescue ActiveRecord::RecordInvalid => e
65
+ @order.errors.add(:base, e.record.errors.full_messages.join(", "))
66
+ end
67
+ end
68
+
69
+ respond_with(@order) do |format|
70
+ format.html do
71
+ if @order.errors.any?
72
+ flash[:error] = @order.errors.full_messages.join(", ")
73
+ redirect_back_or_default(spree.root_path)
74
+ return
75
+ else
76
+ redirect_to cart_path
77
+ end
78
+ end
79
+ end
80
+ end
81
+
82
+ def populate_redirect
83
+ flash[:error] = t('spree.populate_get_error')
84
+ redirect_to spree.cart_path
85
+ end
86
+
87
+ def empty
88
+ if @order = current_order
89
+ authorize! :update, @order, cookies.signed[:guest_token]
90
+ @order.empty!
91
+ end
92
+
93
+ redirect_to spree.cart_path
94
+ end
95
+
96
+ def accurate_title
97
+ if @order && @order.completed?
98
+ t('spree.order_number', number: @order.number)
99
+ else
100
+ t('spree.shopping_cart')
101
+ end
102
+ end
103
+
104
+ private
105
+
106
+ def store_guest_token
107
+ cookies.permanent.signed[:guest_token] = params[:token] if params[:token]
108
+ end
109
+
110
+ def order_params
111
+ if params[:order]
112
+ params[:order].permit(*permitted_order_attributes)
113
+ else
114
+ {}
115
+ end
116
+ end
117
+
118
+ def assign_order
119
+ @order = current_order
120
+ unless @order
121
+ flash[:error] = t('spree.order_not_found')
122
+ redirect_to(root_path) && return
123
+ end
124
+ end
125
+ end
126
+ end